diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-06-27 18:08:14 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-06-27 18:08:14 -0400 |
commit | 747b3c8302245699294b671d19b3d31d63f80bc1 (patch) | |
tree | ad3d987bb38d5bdaed67e6aca1263fb06331f746 /src/commands/config | |
parent | 4176b6258e44e4a095376aaf0f4c687244243a69 (diff) | |
download | tanzanite-747b3c8302245699294b671d19b3d31d63f80bc1.tar.gz tanzanite-747b3c8302245699294b671d19b3d31d63f80bc1.tar.bz2 tanzanite-747b3c8302245699294b671d19b3d31d63f80bc1.zip |
did this a while ago so I don't remeber what I did
Diffstat (limited to 'src/commands/config')
-rw-r--r-- | src/commands/config/muteRole.ts | 21 | ||||
-rw-r--r-- | src/commands/config/prefix.ts | 49 | ||||
-rw-r--r-- | src/commands/config/welcomeChannel.ts | 63 |
3 files changed, 66 insertions, 67 deletions
diff --git a/src/commands/config/muteRole.ts b/src/commands/config/muteRole.ts index f51c5ce..a354bcc 100644 --- a/src/commands/config/muteRole.ts +++ b/src/commands/config/muteRole.ts @@ -1,8 +1,8 @@ +import { ApplicationCommandOptionType } from 'discord-api-types'; import { Role } from 'discord.js'; import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushSlashMessage } from '../../lib/extensions/BushInteractionMessage'; import { BushMessage } from '../../lib/extensions/BushMessage'; -import { Guild } from '../../lib/models'; +import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; import AllowedMentions from '../../lib/utils/AllowedMentions'; export default class MuteRoleCommand extends BushCommand { @@ -11,7 +11,7 @@ export default class MuteRoleCommand extends BushCommand { aliases: ['muterole'], category: 'config', description: { - content: 'Set the prefix of the current server (resets to default if prefix is not given)', + content: 'Configure what role to use when muting users.', usage: 'prefix [prefix]', examples: ['prefix', 'prefix +'] }, @@ -31,9 +31,9 @@ export default class MuteRoleCommand extends BushCommand { slash: true, slashOptions: [ { - type: 'ROLE', + type: ApplicationCommandOptionType.ROLE, name: 'role', - description: 'The mute role for this server.', + description: "What would you like to set the server's mute role to?", required: true } ] @@ -41,16 +41,9 @@ export default class MuteRoleCommand extends BushCommand { } async exec(message: BushMessage | BushSlashMessage, args: { role: Role }): Promise<void> { - let row = await Guild.findByPk(message.guild.id); - if (!row) { - row = Guild.build({ - id: message.guild.id - }); - } - row.muteRole = args.role.id; - await row.save(); + await message.guild.setSetting('muteRole', args.role.id); await message.util.send({ - content: `${this.client.util.emojis.success} Changed the mute role to <@&${args.role.id}>.`, + content: `${this.client.util.emojis.success} Changed the server's mute role to <@&${args.role.id}>.`, allowedMentions: AllowedMentions.none() }); } diff --git a/src/commands/config/prefix.ts b/src/commands/config/prefix.ts index 5b73a1a..fc7b3bf 100644 --- a/src/commands/config/prefix.ts +++ b/src/commands/config/prefix.ts @@ -1,13 +1,20 @@ +import { ApplicationCommandOptionType } from 'discord-api-types'; import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushSlashMessage } from '../../lib/extensions/BushInteractionMessage'; import { BushMessage } from '../../lib/extensions/BushMessage'; -import { Guild } from '../../lib/models'; +import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; export default class PrefixCommand extends BushCommand { constructor() { super('prefix', { aliases: ['prefix'], category: 'config', + description: { + content: 'Set or reset the prefix for the server.', + usage: 'prefix [prefix]', + examples: ['prefix', 'prefix +'] + }, + clientPermissions: ['SEND_MESSAGES'], + userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'], args: [ { id: 'prefix', @@ -19,37 +26,31 @@ export default class PrefixCommand extends BushCommand { } } ], - clientPermissions: ['SEND_MESSAGES'], - userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'], - description: { - content: 'Set the prefix of the current server (resets to default if prefix is not given)', - usage: 'prefix [prefix]', - examples: ['prefix', 'prefix +'] - }, + slash: true, slashOptions: [ { - type: 'STRING', + type: ApplicationCommandOptionType.STRING, name: 'prefix', - description: 'The prefix to set for this server', + description: 'What would you like the new prefix to be?', required: false } - ], - slash: true + ] }); } - async exec(message: BushMessage | BushSlashMessage, { prefix }: { prefix?: string }): Promise<void> { - let row = await Guild.findByPk(message.guild.id); - if (!row) { - row = Guild.build({ - id: message.guild.id - }); - } - await row.update({ prefix: prefix || this.client.config.prefix }); - if (prefix) { - await message.util.send(`${this.client.util.emojis.success} changed prefix from \`${prefix}\` to `); + async exec(message: BushMessage | BushSlashMessage, args: { prefix?: string }): Promise<unknown> { + const oldPrefix = message.guild.getSetting('prefix'); + await message.guild.setSetting('prefix', args.prefix ?? this.client.config.prefix); + if (args.prefix) { + return await message.util.send( + `${this.client.util.emojis.success} changed the server's prefix ${oldPrefix ? `from \`${oldPrefix}\`` : ''} to \`${ + args.prefix + }\`.` + ); } else { - await message.util.send(`${this.client.util.emojis.success} reset prefix to \`${this.client.config.prefix}\``); + return await message.util.send( + `${this.client.util.emojis.success} reset the server's prefix to \`${this.client.config.prefix}\`.` + ); } } } diff --git a/src/commands/config/welcomeChannel.ts b/src/commands/config/welcomeChannel.ts index 72e55f1..8cab33c 100644 --- a/src/commands/config/welcomeChannel.ts +++ b/src/commands/config/welcomeChannel.ts @@ -1,7 +1,8 @@ -import { User } from 'discord.js'; +import { ApplicationCommandOptionType } from 'discord-api-types'; +import { Channel } from 'discord.js'; import { BushCommand } from '../../lib/extensions/BushCommand'; import { BushMessage } from '../../lib/extensions/BushMessage'; -import { Global } from '../../lib/models'; +import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; export default class WelcomeChannelCommand extends BushCommand { public constructor() { @@ -9,41 +10,45 @@ export default class WelcomeChannelCommand extends BushCommand { aliases: ['welcomechannel', 'wc'], category: 'config', description: { - content: 'Configure the what channel you want the bot to send a message in when someone joins the server.', + content: 'Configure the what channel you want BushBot to send a message in when someone joins the server.', usage: 'welcomechannel [channel]', examples: ['welcomechannel #welcome'] }, clientPermissions: ['SEND_MESSAGES'], - ownerOnly: true + userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'], + args: [ + { + id: 'channel', + type: 'channel', + prompt: { + start: 'What channel would you like me to send welcome messages in?', + retry: '{error} Choose a valid channel', + optional: true + } + } + ], + slash: true, + slashOptions: [ + { + type: ApplicationCommandOptionType.CHANNEL, + name: 'channel', + description: 'What channel would you like me to send welcome messages in?', + required: false + } + ] }); } - public async exec(message: BushMessage, args: { action: 'add' | 'remove'; user: User }): Promise<unknown> { - if (!this.client.config.owners.includes(message.author.id)) - return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command...`); - - const superUsers = (await Global.findByPk(this.client.config.dev ? 'development' : 'production')).superUsers; - let success; - if (args.action === 'add') { - if (superUsers.includes(args.user.id)) { - return message.util.reply(`${this.client.util.emojis.warn} \`${args.user.tag}\` is already a superuser.`); - } - success = await this.client.util.insertOrRemoveFromGlobal('add', 'superUsers', args.user.id).catch(() => false); - } else { - if (!superUsers.includes(args.user.id)) { - return message.util.reply(`${this.client.util.emojis.warn} \`${args.user.tag}\` is not superuser.`); - } - success = await this.client.util.insertOrRemoveFromGlobal('remove', 'superUsers', args.user.id).catch(() => false); - } - if (success) { - const responses = [args.action == 'remove' ? `` : 'made', args.action == 'remove' ? 'is no longer' : '']; - return message.util.reply( - `${this.client.util.emojis.success} ${responses[0]} \`${args.user.tag}\` ${responses[1]} a superuser.` + public async exec(message: BushMessage | BushSlashMessage, args: { channel: Channel }): Promise<unknown> { + const oldChannel = await message.guild.getSetting('welcomeChannel'); + await message.guild.setSetting('welcomeChannel', args.channel.id ?? undefined); + if (args.channel) { + return await message.util.send( + `${this.client.util.emojis.success} changed the server's welcome channel ${ + oldChannel ? `from <#${oldChannel}>` : '' + } to <#${args.channel.id}>.` ); } else { - const response = [args.action == 'remove' ? `removing` : 'making', args.action == 'remove' ? `from` : 'to']; - return message.util.reply( - `${this.client.util.emojis.error} There was an error ${response[0]} \`${args.user.tag}\` ${response[1]} the superuser list.` - ); + return await message.util.send(`${this.client.util.emojis.success} removed the server's welcome channel.`); } } } |