Tidy DiscordRcon plugin

This commit is contained in:
Thomas Smyth 2020-10-05 23:18:03 +01:00
parent 47b8b3321a
commit cfde3b2f6a

View File

@ -42,17 +42,23 @@ export default class DiscordRcon extends BasePlugin {
let command = message.content;
if (options.prependAdminNameInBroadcast && command.match(/^adminbroadcast/i))
if (options.prependAdminNameInBroadcast)
command = command.replace(
/^AdminBroadcast /i,
`AdminBroadcast ${message.member.displayName}: `
);
for (const responseMessage of this.splitLongResponse(await server.rcon.execute(command)))
await message.channel.send(`\`\`\`${responseMessage}\`\`\``);
const response = await server.rcon.execute(command);
await this.respondToMessage(message, response);
});
}
async respondToMessage(message, response) {
for (const splitResponse of this.splitLongResponse(response))
await message.channel.send(`\`\`\`${splitResponse}\`\`\``);
}
splitLongResponse(response) {
const responseMessages = [''];