aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorMax Isom <[email protected]>2020-03-09 15:00:18 -0500
committerMax Isom <[email protected]>2020-03-09 15:00:18 -0500
commit652cc2e5efed6ddef593570ee90634cbc1c452bb (patch)
tree6df810ab7715051c6cfe0613e7d338906260f36a /src/commands
parenteca84c8b6964af29948510a02ebfeb5f23244921 (diff)
downloadmuse-652cc2e5efed6ddef593570ee90634cbc1c452bb.tar.xz
muse-652cc2e5efed6ddef593570ee90634cbc1c452bb.zip
Add config command
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/config.ts51
1 files changed, 45 insertions, 6 deletions
diff --git a/src/commands/config.ts b/src/commands/config.ts
index fb79059..80d5727 100644
--- a/src/commands/config.ts
+++ b/src/commands/config.ts
@@ -1,22 +1,61 @@
+import {TextChannel} from 'discord.js';
import {CommandHandler} from '../interfaces';
+import {Settings} from '../models';
const config: CommandHandler = {
name: 'config',
description: 'Change various bot settings.',
- execute: (msg, args) => {
+ execute: async (msg, args) => {
+ if (args.length === 0) {
+ // Show current settings
+ const settings = await Settings.findByPk(msg.guild!.id);
+
+ if (settings) {
+ let response = `prefix: \`${settings.prefix}\`\n`;
+ response += `channel: ${msg.guild!.channels.cache.get(settings.channel)!.toString()}`;
+
+ await msg.channel.send(response);
+ }
+
+ return;
+ }
+
const setting = args[0];
+ if (args.length !== 2) {
+ await msg.channel.send('🚫 incorrect number of arguments');
+ return;
+ }
+
switch (setting) {
- case 'prefix':
- msg.channel.send('Prefix set');
+ case 'prefix': {
+ const newPrefix = args[1];
+
+ await Settings.update({prefix: newPrefix}, {where: {guildId: msg.guild!.id}});
+
+ await msg.channel.send(`👍 prefix updated to \`${newPrefix}\``);
break;
+ }
+
+ case 'channel': {
+ const channel = msg.guild!.channels.cache.find(c => c.name === args[1]);
+
+ if (channel && channel.type === 'text') {
+ await Settings.update({channel: channel.id}, {where: {guildId: msg.guild!.id}});
+
+ await Promise.all([
+ (channel as TextChannel).send('hey apparently I\'m bound to this channel now'),
+ msg.react('👍')
+ ]);
+ } else {
+ await msg.channel.send('🚫 either that channel doesn\'t exist or you want me to become sentient and listen to a voice channel');
+ }
- case 'channel':
- msg.channel.send('Channel bound');
break;
+ }
default:
- msg.channel.send('Unknown setting');
+ await msg.channel.send('🚫 I\'ve never met this setting in my life');
}
}
};