diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-06-24 00:56:16 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-06-24 00:56:16 -0400 |
commit | 4176b6258e44e4a095376aaf0f4c687244243a69 (patch) | |
tree | 3b9144be9a2045483c90d92fff05b3ca0b288e52 /src/commands/config | |
parent | e80446e23060c0325bbd6db620920d86694ec3ce (diff) | |
download | tanzanite-4176b6258e44e4a095376aaf0f4c687244243a69.tar.gz tanzanite-4176b6258e44e4a095376aaf0f4c687244243a69.tar.bz2 tanzanite-4176b6258e44e4a095376aaf0f4c687244243a69.zip |
feat(*): Began working on other punishment commands etc
Diffstat (limited to 'src/commands/config')
-rw-r--r-- | src/commands/config/muteRole.ts | 57 | ||||
-rw-r--r-- | src/commands/config/prefix.ts | 16 | ||||
-rw-r--r-- | src/commands/config/welcomeChannel.ts | 49 |
3 files changed, 117 insertions, 5 deletions
diff --git a/src/commands/config/muteRole.ts b/src/commands/config/muteRole.ts new file mode 100644 index 0000000..f51c5ce --- /dev/null +++ b/src/commands/config/muteRole.ts @@ -0,0 +1,57 @@ +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 AllowedMentions from '../../lib/utils/AllowedMentions'; + +export default class MuteRoleCommand extends BushCommand { + constructor() { + super('muteRole', { + aliases: ['muterole'], + category: 'config', + description: { + content: 'Set the prefix of the current server (resets to default if prefix is not given)', + usage: 'prefix [prefix]', + examples: ['prefix', 'prefix +'] + }, + clientPermissions: ['SEND_MESSAGES'], + userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'], + args: [ + { + id: 'role', + type: 'role', + prompt: { + start: "What would you like to set the server's mute role to?", + retry: '{error} Choose a valid role.', + optional: false + } + } + ], + slash: true, + slashOptions: [ + { + type: 'ROLE', + name: 'role', + description: 'The mute role for this server.', + required: true + } + ] + }); + } + + 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.util.send({ + content: `${this.client.util.emojis.success} Changed the mute role to <@&${args.role.id}>.`, + allowedMentions: AllowedMentions.none() + }); + } +} diff --git a/src/commands/config/prefix.ts b/src/commands/config/prefix.ts index 1326426..5b73a1a 100644 --- a/src/commands/config/prefix.ts +++ b/src/commands/config/prefix.ts @@ -1,6 +1,6 @@ -import { Message } 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'; export default class PrefixCommand extends BushCommand { @@ -11,10 +11,16 @@ export default class PrefixCommand extends BushCommand { args: [ { id: 'prefix', - type: 'string' + type: 'string', + prompt: { + start: 'What would you like the new prefix to be?', + retry: '{error} Choose a valid prefix', + optional: true + } } ], - userPermissions: ['MANAGE_GUILD'], + 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]', @@ -32,7 +38,7 @@ export default class PrefixCommand extends BushCommand { }); } - async exec(message: Message | BushSlashMessage, { prefix }: { prefix?: string }): Promise<void> { + async exec(message: BushMessage | BushSlashMessage, { prefix }: { prefix?: string }): Promise<void> { let row = await Guild.findByPk(message.guild.id); if (!row) { row = Guild.build({ @@ -41,7 +47,7 @@ export default class PrefixCommand extends BushCommand { } await row.update({ prefix: prefix || this.client.config.prefix }); if (prefix) { - await message.util.send(`${this.client.util.emojis.success} changed prefix from \`${prefix}\``); + await message.util.send(`${this.client.util.emojis.success} changed prefix from \`${prefix}\` to `); } else { await message.util.send(`${this.client.util.emojis.success} reset prefix to \`${this.client.config.prefix}\``); } diff --git a/src/commands/config/welcomeChannel.ts b/src/commands/config/welcomeChannel.ts new file mode 100644 index 0000000..72e55f1 --- /dev/null +++ b/src/commands/config/welcomeChannel.ts @@ -0,0 +1,49 @@ +import { User } from 'discord.js'; +import { BushCommand } from '../../lib/extensions/BushCommand'; +import { BushMessage } from '../../lib/extensions/BushMessage'; +import { Global } from '../../lib/models'; + +export default class WelcomeChannelCommand extends BushCommand { + public constructor() { + super('welcomeChannel', { + 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.', + usage: 'welcomechannel [channel]', + examples: ['welcomechannel #welcome'] + }, + clientPermissions: ['SEND_MESSAGES'], + ownerOnly: true + }); + } + 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.` + ); + } 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.` + ); + } + } +} |