From a47ef150fd38fff3666faccd6f976f660fdbf9f3 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Tue, 31 Aug 2021 18:45:23 -0400 Subject: cleanup and deprecated old config commands --- src/commands/admin/channelPermissions.ts | 2 +- src/commands/config/autoPublishChannel.ts | 48 +++--------------------- src/commands/config/features.ts | 3 +- src/commands/config/joinRoles.ts | 39 +++---------------- src/commands/config/muteRole.ts | 34 +++-------------- src/commands/config/prefix.ts | 43 +++------------------ src/commands/config/punishmentFooter.ts | 39 +++---------------- src/commands/config/welcomeChannel.ts | 38 ++----------------- src/commands/dev/servers.ts | 2 +- src/commands/dev/sh.ts | 1 + src/commands/dev/superUser.ts | 2 + src/commands/dev/test.ts | 1 - src/commands/leveling/leaderboard.ts | 4 ++ src/commands/leveling/level.ts | 5 +++ src/commands/moulberry-bush/serverStatus.ts | 58 +++++++++++++++++++++++++++++ src/commands/utilities/serverStatus.ts | 58 ----------------------------- src/listeners/client/interactionCreate.ts | 16 +++----- 17 files changed, 109 insertions(+), 284 deletions(-) create mode 100644 src/commands/moulberry-bush/serverStatus.ts delete mode 100644 src/commands/utilities/serverStatus.ts (limited to 'src') diff --git a/src/commands/admin/channelPermissions.ts b/src/commands/admin/channelPermissions.ts index 83230f7..ea97343 100644 --- a/src/commands/admin/channelPermissions.ts +++ b/src/commands/admin/channelPermissions.ts @@ -3,7 +3,7 @@ import { BushCommand, BushMessage } from '../../lib'; export default class ChannelPermissionsCommand extends BushCommand { public constructor() { - super('channelpermissions', { + super('channelPermissions', { aliases: ['channelperms', 'cperms', 'cperm', 'chanperms', 'chanperm', 'channelpermissions'], category: 'admin', typing: true, diff --git a/src/commands/config/autoPublishChannel.ts b/src/commands/config/autoPublishChannel.ts index a58f32f..d691a7f 100644 --- a/src/commands/config/autoPublishChannel.ts +++ b/src/commands/config/autoPublishChannel.ts @@ -1,59 +1,23 @@ -import { AllowedMentions, BushCommand, BushMessage } from '@lib'; -import { Channel } from 'discord.js'; +import { BushCommand, BushMessage } from '@lib'; export default class AutoPublishChannelCommand extends BushCommand { public constructor() { - super('autopublishchannel', { + super('autoPublishChannel', { aliases: ['autopublishchannel', 'apc', 'publishchannel', 'autopublishchannels', 'publishchannels', 'autopublish'], category: 'config', description: { - content: 'A command to add/remove channels from being automatically published.', + content: 'This command has been deprecated, please use the config command instead', usage: 'autopublishchannel ', examples: ['autopublishchannel #github'] }, - args: [ - { - id: 'channel', - type: 'channel', - match: 'content', - prompt: { - start: 'What channel would you like to toggle auto publishing in?', - retry: '{error} Choose a valid channel.', - optional: false - } - } - ], - slash: true, - slashOptions: [ - { - name: 'channel', - description: 'What channel would you like me to send welcome messages in?', - type: 'CHANNEL', - required: true - } - ], channel: 'guild', + hidden: true, clientPermissions: ['SEND_MESSAGES'], userPermissions: ['MANAGE_GUILD', 'SEND_MESSAGES'] }); } - public override async exec(message: BushMessage, { channel }: { channel: Channel }): Promise { - const autoPublishChannels = await message.guild!.getSetting('autoPublishChannels'); - const newValue = util.addOrRemoveFromArray( - autoPublishChannels.includes(channel.id) ? 'remove' : 'add', - autoPublishChannels, - channel.id - ); - await message.guild!.setSetting('autoPublishChannels', newValue); - client.logger.debugRaw(autoPublishChannels); - client.logger.debugRaw(channel.id); - client.logger.debugRaw(autoPublishChannels.includes(channel.id)); - return await message.util.reply({ - content: `${util.emojis.success} Successfully ${ - autoPublishChannels.includes(channel.id) ? 'enabled' : 'disabled' - } auto publishing in <#${channel.id}>.`, - allowedMentions: AllowedMentions.none() - }); + public override async exec(message: BushMessage): Promise { + return message.util.reply(`${util.emojis.error} 'This command has been deprecated, please use the config command instead'`); } } diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts index 9a5fa5b..7a7c3bb 100644 --- a/src/commands/config/features.ts +++ b/src/commands/config/features.ts @@ -14,8 +14,7 @@ export default class FeaturesCommand extends BushCommand { slash: true, channel: 'guild', clientPermissions: ['SEND_MESSAGES', 'EMBED_LINKS'], - userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'], - ownerOnly: true + userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'] }); } public override async exec(message: BushMessage | BushSlashMessage): Promise { diff --git a/src/commands/config/joinRoles.ts b/src/commands/config/joinRoles.ts index 0b9ac21..2a3031e 100644 --- a/src/commands/config/joinRoles.ts +++ b/src/commands/config/joinRoles.ts @@ -1,5 +1,4 @@ -import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage } from '@lib'; -import { Role } from 'discord.js'; +import { BushCommand, BushMessage, BushSlashMessage } from '@lib'; export default class JoinRolesCommand extends BushCommand { public constructor() { @@ -7,46 +6,18 @@ export default class JoinRolesCommand extends BushCommand { aliases: ['joinroles', 'joinrole', 'jr'], category: 'config', description: { - content: 'Configure what roles to assign to someone when they join the server.', + content: 'This command has been deprecated, please use the config command instead', usage: 'joinroles ', examples: ['joinroles @member'] }, - args: [ - { - id: 'role', - type: 'role', - prompt: { - start: 'What role would you like me to assign to users when they join the server?', - retry: '{error} Choose a valid role', - optional: true - } - } - ], - slash: true, - slashOptions: [ - { - name: 'role', - description: 'What role would you like me to assign to users when they join the server?', - type: 'ROLE', - required: false - } - ], channel: 'guild', + hidden: true, clientPermissions: ['SEND_MESSAGES'], userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'] }); } - public override async exec(message: BushMessage | BushSlashMessage, { role }: { role: Role }): Promise { - const joinRoles = await message.guild!.getSetting('joinRoles'); - const includes = joinRoles.includes(role.id); - const newValue = util.addOrRemoveFromArray(includes ? 'remove' : 'add', joinRoles, role.id); - await message.guild!.setSetting('joinRoles', newValue); - return await message.util.reply({ - content: `${util.emojis.success} Successfully ${includes ? 'removed' : 'added'} <@&${role.id}> ${ - includes ? 'from' : 'to' - }from being assigned to members when they join the server.`, - allowedMentions: AllowedMentions.none() - }); + public override async exec(message: BushMessage | BushSlashMessage): Promise { + return message.util.reply(`${util.emojis.error} 'This command has been deprecated, please use the config command instead'`); } } diff --git a/src/commands/config/muteRole.ts b/src/commands/config/muteRole.ts index c7a6e75..6d3c9f6 100644 --- a/src/commands/config/muteRole.ts +++ b/src/commands/config/muteRole.ts @@ -1,5 +1,4 @@ -import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage } from '@lib'; -import { Role } from 'discord.js'; +import { BushCommand, BushMessage, BushSlashMessage } from '@lib'; export default class MuteRoleCommand extends BushCommand { public constructor() { @@ -7,41 +6,18 @@ export default class MuteRoleCommand extends BushCommand { aliases: ['muterole'], category: 'config', description: { - content: 'Configure what role to use when muting users.', + content: 'This command has been deprecated, please use the config command instead', usage: 'muterole ', examples: ['muterole 748912426581229690'] }, - 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: [ - { - name: 'role', - description: "What would you like to set the server's mute role to?", - type: 'ROLE', - required: true - } - ], channel: 'guild', + hidden: true, clientPermissions: ['SEND_MESSAGES'], userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'] }); } - override async exec(message: BushMessage | BushSlashMessage, args: { role: Role }): Promise { - await message.guild!.setSetting('muteRole', args.role.id); - await message.util.send({ - content: `${util.emojis.success} Changed the server's mute role to <@&${args.role.id}>.`, - allowedMentions: AllowedMentions.none() - }); + override async exec(message: BushMessage | BushSlashMessage): Promise { + return message.util.reply(`${util.emojis.error} 'This command has been deprecated, please use the config command instead'`); } } diff --git a/src/commands/config/prefix.ts b/src/commands/config/prefix.ts index 9d707e0..5cd75b3 100644 --- a/src/commands/config/prefix.ts +++ b/src/commands/config/prefix.ts @@ -1,4 +1,4 @@ -import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage } from '@lib'; +import { BushCommand, BushMessage, BushSlashMessage } from '@lib'; export default class PrefixCommand extends BushCommand { public constructor() { @@ -6,51 +6,18 @@ export default class PrefixCommand extends BushCommand { aliases: ['prefix'], category: 'config', description: { - content: 'Set or reset the prefix for the server.', + content: 'This command has been deprecated, please use the config command instead', usage: 'prefix [prefix]', examples: ['prefix', 'prefix -'] }, - args: [ - { - id: 'prefix', - type: 'string', - prompt: { - start: 'What would you like the new prefix to be?', - retry: '{error} Choose a valid prefix', - optional: true - } - } - ], - slash: true, - slashOptions: [ - { - name: 'prefix', - description: 'What would you like the new prefix to be?', - type: 'STRING', - required: false - } - ], channel: 'guild', + hidden: true, clientPermissions: ['SEND_MESSAGES'], userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'] }); } - override async exec(message: BushMessage | BushSlashMessage, args: { prefix?: string }): Promise { - const oldPrefix = await message.guild!.getSetting('prefix'); - await message.guild!.setSetting('prefix', args.prefix ?? client.config.prefix); - if (args.prefix) { - return await message.util.send({ - content: `${util.emojis.success} changed the server's prefix ${oldPrefix ? `from \`${oldPrefix}\`` : ''} to \`${ - args.prefix - }\`.`, - allowedMentions: AllowedMentions.none() - }); - } else { - return await message.util.send({ - content: `${util.emojis.success} reset the server's prefix to \`${client.config.prefix}\`.`, - allowedMentions: AllowedMentions.none() - }); - } + override async exec(message: BushMessage | BushSlashMessage): Promise { + return message.util.reply(`${util.emojis.error} 'This command has been deprecated, please use the config command instead'`); } } diff --git a/src/commands/config/punishmentFooter.ts b/src/commands/config/punishmentFooter.ts index d07ce4f..79e3df3 100644 --- a/src/commands/config/punishmentFooter.ts +++ b/src/commands/config/punishmentFooter.ts @@ -1,5 +1,4 @@ -import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage } from '@lib'; -import { Util } from 'discord.js'; +import { BushCommand, BushMessage, BushSlashMessage } from '@lib'; export default class PunishmentFooterCommand extends BushCommand { public constructor() { @@ -7,46 +6,18 @@ export default class PunishmentFooterCommand extends BushCommand { aliases: ['punishmentfooter'], category: 'config', description: { - content: 'Configure or reset what should follow all punishment related dms.', + content: 'This command has been deprecated, please use the config command instead', usage: 'punishmentfooter [message]', examples: ['punishmentfooter', 'prefix you can appeal at https://example.com.'] }, - args: [ - { - id: 'ending', - type: 'string', - match: 'restContent', - prompt: { - start: 'What message would you like to follow punishment dms?', - retry: '{error} Choose a valid role.', - optional: true - } - } - ], - slash: true, - slashOptions: [ - { - name: 'ending', - description: 'What message would you like to follow punishment dms?', - type: 'STRING', - required: false - } - ], channel: 'guild', + hidden: true, clientPermissions: ['SEND_MESSAGES'], userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'] }); } - override async exec(message: BushMessage | BushSlashMessage, args: { ending: string }): Promise { - await message.guild!.setSetting('punishmentEnding', args.ending || ''); - if (args.ending) - return await message.util.send({ - content: `${util.emojis.success} Changed the server's punishment footer to \n\`\`\`${Util.cleanCodeBlockContent( - args.ending - )}\`\`\`.`, - allowedMentions: AllowedMentions.none() - }); - else return await message.util.send(`${util.emojis.success} Removed he server's punishment footer.`); + override async exec(message: BushMessage | BushSlashMessage): Promise { + return message.util.reply(`${util.emojis.error} 'This command has been deprecated, please use the config command instead'`); } } diff --git a/src/commands/config/welcomeChannel.ts b/src/commands/config/welcomeChannel.ts index fc56607..c94b416 100644 --- a/src/commands/config/welcomeChannel.ts +++ b/src/commands/config/welcomeChannel.ts @@ -1,5 +1,4 @@ import { BushCommand, BushMessage, BushSlashMessage } from '@lib'; -import { Channel } from 'discord.js'; export default class WelcomeChannelCommand extends BushCommand { public constructor() { @@ -7,46 +6,17 @@ export default class WelcomeChannelCommand extends BushCommand { aliases: ['welcomechannel', 'wc'], category: 'config', description: { - content: 'Configure the what channel you want BushBot to send a message in when someone joins the server.', + content: 'This command has been deprecated, please use the config command instead', usage: 'welcomechannel [channel]', examples: ['welcomechannel #welcome'] }, - 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: [ - { - name: 'channel', - description: 'What channel would you like me to send welcome messages in?', - type: 'CHANNEL', - required: false - } - ], channel: 'guild', + hidden: true, clientPermissions: ['SEND_MESSAGES'], userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'] }); } - public override async exec(message: BushMessage | BushSlashMessage, args: { channel: Channel }): Promise { - const oldChannel = await message.guild!.getSetting('welcomeChannel'); - await message.guild!.setSetting('welcomeChannel', args.channel.id ?? undefined); - if (args.channel) { - return await message.util.send( - `${util.emojis.success} changed the server's welcome channel ${oldChannel ? `from <#${oldChannel}>` : ''} to <#${ - args.channel.id - }>.` - ); - } else { - return await message.util.send(`${util.emojis.success} removed the server's welcome channel.`); - } + public override async exec(message: BushMessage | BushSlashMessage): Promise { + return message.util.reply(`${util.emojis.error} 'This command has been deprecated, please use the config command instead'`); } } diff --git a/src/commands/dev/servers.ts b/src/commands/dev/servers.ts index d8799f5..c86e889 100644 --- a/src/commands/dev/servers.ts +++ b/src/commands/dev/servers.ts @@ -13,7 +13,7 @@ export default class ServersCommand extends BushCommand { }, clientPermissions: ['SEND_MESSAGES'], userPermissions: ['SEND_MESSAGES'], - superUserOnly: true + ownerOnly: true }); } diff --git a/src/commands/dev/sh.ts b/src/commands/dev/sh.ts index 025a308..93f0d40 100644 --- a/src/commands/dev/sh.ts +++ b/src/commands/dev/sh.ts @@ -11,6 +11,7 @@ const clean = (text: string | any) => { return (text = Util.cleanCodeBlockContent(text)); } else return text; }; + export default class ShCommand extends BushCommand { public constructor() { super('sh', { diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts index 1b2fd7c..4bab8a1 100644 --- a/src/commands/dev/superUser.ts +++ b/src/commands/dev/superUser.ts @@ -16,6 +16,7 @@ export default class SuperUserCommand extends BushCommand { ownerOnly: true }); } + *args(): IterableIterator { const action = yield { id: 'action', @@ -38,6 +39,7 @@ export default class SuperUserCommand extends BushCommand { }; return { action, user }; } + public override async exec( message: BushMessage | BushSlashMessage, args: { action: 'add' | 'remove'; user: User } diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts index aa421cd..bb0807b 100644 --- a/src/commands/dev/test.ts +++ b/src/commands/dev/test.ts @@ -29,7 +29,6 @@ export default class TestCommand extends BushCommand { }); } - // eslint-disable-next-line require-await public override async exec(message: BushMessage, args: { feature: string }): Promise { const responses = [ 'Yes master.', diff --git a/src/commands/leveling/leaderboard.ts b/src/commands/leveling/leaderboard.ts index d29c15e..953a6c5 100644 --- a/src/commands/leveling/leaderboard.ts +++ b/src/commands/leveling/leaderboard.ts @@ -39,6 +39,10 @@ export default class LeaderboardCommand extends BushCommand { public override async exec(message: BushMessage | BushSlashMessage, args: { page: number }): Promise { if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be run in a server.`); + if (!(await message.guild.hasFeature('leveling'))) + return await message.util.reply( + `${util.emojis.error} This command can only be run in commands with the leveling feature enabled.` + ); const ranks = (await Level.findAll({ where: { guild: message.guild.id } })).sort((a, b) => b.xp - a.xp); const mapedRanks = ranks.map( (val, index) => `\`${index + 1}\` <@${val.user}> - Level ${val.level} (${val.xp.toLocaleString()} xp)` diff --git a/src/commands/leveling/level.ts b/src/commands/leveling/level.ts index 6640744..f22ed8d 100644 --- a/src/commands/leveling/level.ts +++ b/src/commands/leveling/level.ts @@ -126,6 +126,11 @@ export default class LevelCommand extends BushCommand { } public override async exec(message: BushMessage | BushSlashMessage, args: { user?: BushUser }): Promise { + if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be run in a server.`); + if (!(await message.guild.hasFeature('leveling'))) + return await message.util.reply( + `${util.emojis.error} This command can only be run in commands with the leveling feature enabled.` + ); const user = args.user ?? message.author; try { return await message.util.reply({ diff --git a/src/commands/moulberry-bush/serverStatus.ts b/src/commands/moulberry-bush/serverStatus.ts new file mode 100644 index 0000000..004329d --- /dev/null +++ b/src/commands/moulberry-bush/serverStatus.ts @@ -0,0 +1,58 @@ +import { MessageEmbed } from 'discord.js'; +import got from 'got'; +import { BushCommand, BushMessage } from '../../lib'; + +export default class ServerStatusCommand extends BushCommand { + public constructor() { + super('serverstatus', { + aliases: ['serverstatus', 'ss'], + category: "Moulberry's Bush", + description: { + usage: 'serverstatus', + examples: ['serverstatus', 'ss'], + content: "Gives the status of moulberry's server" + }, + ratelimit: 4, + cooldown: 4000, + clientPermissions: ['EMBED_LINKS', 'SEND_MESSAGES'], + slash: true + }); + } + + public override async exec(message: BushMessage): Promise { + const msgEmbed: MessageEmbed = new MessageEmbed() + .setTitle('Server status') + .setDescription(`Checking server:\n${util.emojis.loading}`) + .setColor(util.colors.default) + .setFooter('Checking https://moulberry.codes/lowestbin.json'); + await message.util.reply({ embeds: [msgEmbed] }); + let main; + try { + await got.get('https://moulberry.codes/lowestbin.json').json(); + main = util.emojis.success; + } catch (e) { + main = util.emojis.error; + } + await message.util.edit({ embeds: [msgEmbed.setDescription(`Checking server:\n${main}`)] }); + if (main == util.emojis.success) { + await message.util.edit({ + embeds: [ + msgEmbed + .addField('Status', 'The server is online, all features related to prices will likely work.') + .setColor(util.colors.success) + ] + }); + } else { + await message.util.edit({ + embeds: [ + msgEmbed + .addField( + 'Status', + "It appears Moulberry's server is offline, this means that everything related to prices will likely not work." + ) + .setColor(util.colors.error) + ] + }); + } + } +} diff --git a/src/commands/utilities/serverStatus.ts b/src/commands/utilities/serverStatus.ts deleted file mode 100644 index 02db638..0000000 --- a/src/commands/utilities/serverStatus.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { MessageEmbed } from 'discord.js'; -import got from 'got'; -import { BushCommand, BushMessage } from '../../lib'; - -export default class ServerStatusCommand extends BushCommand { - public constructor() { - super('serverstatus', { - aliases: ['serverstatus', 'ss'], - category: 'utilities', - description: { - usage: 'serverstatus', - examples: ['serverstatus', 'ss'], - content: "Gives the status of moulberry's server" - }, - ratelimit: 4, - cooldown: 4000, - clientPermissions: ['EMBED_LINKS', 'SEND_MESSAGES'], - slash: true - }); - } - - public override async exec(message: BushMessage): Promise { - const msgEmbed: MessageEmbed = new MessageEmbed() - .setTitle('Server status') - .setDescription(`Checking server:\n${util.emojis.loading}`) - .setColor(util.colors.default) - .setFooter('Checking https://moulberry.codes/lowestbin.json'); - await message.util.reply({ embeds: [msgEmbed] }); - let main; - try { - await got.get('https://moulberry.codes/lowestbin.json').json(); - main = util.emojis.success; - } catch (e) { - main = util.emojis.error; - } - await message.util.edit({ embeds: [msgEmbed.setDescription(`Checking server:\n${main}`)] }); - if (main == util.emojis.success) { - await message.util.edit({ - embeds: [ - msgEmbed - .addField('Status', 'The server is online, all features related to prices will likely work.') - .setColor(util.colors.success) - ] - }); - } else { - await message.util.edit({ - embeds: [ - msgEmbed - .addField( - 'Status', - "It appears Moulberry's server is offline, this means that everything related to prices will likely not work." - ) - .setColor(util.colors.error) - ] - }); - } - } -} diff --git a/src/listeners/client/interactionCreate.ts b/src/listeners/client/interactionCreate.ts index e755ad6..d07a084 100644 --- a/src/listeners/client/interactionCreate.ts +++ b/src/listeners/client/interactionCreate.ts @@ -12,17 +12,13 @@ export default class InteractionCreateListener extends BushListener { public override async exec(...[interaction]: BushClientEvents['interactionCreate']): Promise { if (!interaction) return; + void client.console.verbose( + 'interactionVerbose', + `An interaction of type <<${interaction.type.toLowerCase().replaceAll('_', '')}>> was received from <<${ + interaction.user.tag + }>>.` + ); if (interaction.isCommand()) { - void client.console.info( - 'slashCommand', - `The <<${interaction.commandName}>> command was used by <<${interaction.user.tag}>> in <<${ - interaction.channel - ? interaction.channel.type == 'DM' - ? interaction.channel.recipient + 's DMs' - : interaction.channel.name - : 'unknown' - }>>.` - ); return; } else if (interaction.isButton()) { if (interaction.customId.startsWith('paginate_') || interaction.customId.startsWith('command_')) return; -- cgit