diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-06-28 18:54:18 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-06-28 18:54:18 -0400 |
commit | 6974a5859658b966954a59411a800223b7542df8 (patch) | |
tree | 9f1b4eae137d3253e1530bd30b78ab73b985c9ca /src | |
parent | b581073e0deb4f96510d72001513db64f3cc01ab (diff) | |
download | tanzanite-6974a5859658b966954a59411a800223b7542df8.tar.gz tanzanite-6974a5859658b966954a59411a800223b7542df8.tar.bz2 tanzanite-6974a5859658b966954a59411a800223b7542df8.zip |
fix breaking changes and bump dependencies
Diffstat (limited to 'src')
-rw-r--r-- | src/commands/config/muteRole.ts | 3 | ||||
-rw-r--r-- | src/commands/config/prefix.ts | 3 | ||||
-rw-r--r-- | src/commands/config/welcomeChannel.ts | 3 | ||||
-rw-r--r-- | src/commands/dev/eval.ts | 15 | ||||
-rw-r--r-- | src/commands/dev/reload.ts | 3 | ||||
-rw-r--r-- | src/commands/dev/setLevel.ts | 5 | ||||
-rw-r--r-- | src/commands/info/help.ts | 3 | ||||
-rw-r--r-- | src/commands/info/pronouns.ts | 3 | ||||
-rw-r--r-- | src/commands/moderation/ban.ts | 7 | ||||
-rw-r--r-- | src/commands/moderation/kick.ts | 5 | ||||
-rw-r--r-- | src/commands/moderation/mute.ts | 7 | ||||
-rw-r--r-- | src/commands/moderation/role.ts | 5 | ||||
-rw-r--r-- | src/commands/moulberry-bush/capePerms.ts | 3 | ||||
-rw-r--r-- | src/commands/moulberry-bush/level.ts | 3 | ||||
-rw-r--r-- | src/commands/moulberry-bush/rule.ts | 5 | ||||
-rw-r--r-- | src/lib/extensions/BushClient.ts | 16 | ||||
-rw-r--r-- | src/lib/extensions/BushClientUtil.ts | 14 | ||||
-rw-r--r-- | src/lib/extensions/BushGuild.ts | 4 | ||||
-rw-r--r-- | src/lib/utils/BushLogger.ts | 6 | ||||
-rw-r--r-- | src/tasks/unmute.ts | 2 |
20 files changed, 56 insertions, 59 deletions
diff --git a/src/commands/config/muteRole.ts b/src/commands/config/muteRole.ts index a354bcc..2dc34c3 100644 --- a/src/commands/config/muteRole.ts +++ b/src/commands/config/muteRole.ts @@ -1,4 +1,3 @@ -import { ApplicationCommandOptionType } from 'discord-api-types'; import { Role } from 'discord.js'; import { BushCommand } from '../../lib/extensions/BushCommand'; import { BushMessage } from '../../lib/extensions/BushMessage'; @@ -31,7 +30,7 @@ export default class MuteRoleCommand extends BushCommand { slash: true, slashOptions: [ { - type: ApplicationCommandOptionType.ROLE, + type: 'ROLE', name: 'role', description: "What would you like to set the server's mute role to?", required: true diff --git a/src/commands/config/prefix.ts b/src/commands/config/prefix.ts index fc7b3bf..b788d17 100644 --- a/src/commands/config/prefix.ts +++ b/src/commands/config/prefix.ts @@ -1,4 +1,3 @@ -import { ApplicationCommandOptionType } from 'discord-api-types'; import { BushCommand } from '../../lib/extensions/BushCommand'; import { BushMessage } from '../../lib/extensions/BushMessage'; import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; @@ -29,7 +28,7 @@ export default class PrefixCommand extends BushCommand { slash: true, slashOptions: [ { - type: ApplicationCommandOptionType.STRING, + type: 'STRING', name: 'prefix', description: 'What would you like the new prefix to be?', required: false diff --git a/src/commands/config/welcomeChannel.ts b/src/commands/config/welcomeChannel.ts index 8cab33c..d531c7d 100644 --- a/src/commands/config/welcomeChannel.ts +++ b/src/commands/config/welcomeChannel.ts @@ -1,4 +1,3 @@ -import { ApplicationCommandOptionType } from 'discord-api-types'; import { Channel } from 'discord.js'; import { BushCommand } from '../../lib/extensions/BushCommand'; import { BushMessage } from '../../lib/extensions/BushMessage'; @@ -30,7 +29,7 @@ export default class WelcomeChannelCommand extends BushCommand { slash: true, slashOptions: [ { - type: ApplicationCommandOptionType.CHANNEL, + type: 'CHANNEL', name: 'channel', description: 'What channel would you like me to send welcome messages in?', required: false diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index 04c5158..7f6a713 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -1,7 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import { exec } from 'child_process'; import { Constants } from 'discord-akairo'; -import { ApplicationCommandOptionType } from 'discord-api-types'; import { CommandInteraction, MessageEmbed, MessageEmbedOptions, Util } from 'discord.js'; import { transpile } from 'typescript'; import { inspect, promisify } from 'util'; @@ -80,43 +79,43 @@ export default class EvalCommand extends BushCommand { { name: 'code', description: 'The code you would like to evaluate.', - type: ApplicationCommandOptionType.STRING, + type: 'STRING', required: true }, { name: 'sel_depth', description: 'How deep to display the output.', - type: ApplicationCommandOptionType.INTEGER, + type: 'INTEGER', required: false }, { name: 'sudo', description: 'Whether or not to override checks.', - type: ApplicationCommandOptionType.BOOLEAN, + type: 'BOOLEAN', required: false }, { name: 'silent', description: 'Whether or not to make the response silent', - type: ApplicationCommandOptionType.BOOLEAN, + type: 'BOOLEAN', required: false }, { name: 'typescript', description: 'Whether or not to compile the code from typescript.', - type: ApplicationCommandOptionType.BOOLEAN, + type: 'BOOLEAN', required: false }, { name: 'hidden', description: 'Whether or not to show hidden items.', - type: ApplicationCommandOptionType.BOOLEAN, + type: 'BOOLEAN', required: false }, { name: 'show_proto', description: 'Show prototype.', - type: ApplicationCommandOptionType.BOOLEAN, + type: 'BOOLEAN', required: false } ] diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts index 07218f2..656bb34 100644 --- a/src/commands/dev/reload.ts +++ b/src/commands/dev/reload.ts @@ -1,4 +1,3 @@ -import { ApplicationCommandOptionType } from 'discord-api-types'; import { BushCommand } from '../../lib/extensions/BushCommand'; import { BushMessage } from '../../lib/extensions/BushMessage'; import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; @@ -24,7 +23,7 @@ export default class ReloadCommand extends BushCommand { typing: true, slashOptions: [ { - type: ApplicationCommandOptionType.BOOLEAN, + type: 'BOOLEAN', name: 'fast', description: 'Whether to use esbuild for fast compiling or not', required: false diff --git a/src/commands/dev/setLevel.ts b/src/commands/dev/setLevel.ts index 7e07ce0..6c8131a 100644 --- a/src/commands/dev/setLevel.ts +++ b/src/commands/dev/setLevel.ts @@ -1,4 +1,3 @@ -import { ApplicationCommandOptionType } from 'discord-api-types'; import { User } from 'discord.js'; import { BushCommand } from '../../lib/extensions/BushCommand'; import { BushMessage } from '../../lib/extensions/BushMessage'; @@ -37,13 +36,13 @@ export default class SetLevelCommand extends BushCommand { ownerOnly: true, slashOptions: [ { - type: /* 'USER' */ ApplicationCommandOptionType.USER, + type: /* 'USER' */ 'USER', name: 'user', description: 'The user to change the level of', required: true }, { - type: /* 'INTEGER' */ ApplicationCommandOptionType.INTEGER, + type: /* 'INTEGER' */ 'INTEGER', name: 'level', description: 'The level to set the user to', required: true diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index 30606e1..b58d73c 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -1,4 +1,3 @@ -import { ApplicationCommandOptionType } from 'discord-api-types'; import { MessageActionRow, MessageButton, MessageEmbed } from 'discord.js'; import { BushCommand } from '../../lib/extensions/BushCommand'; import { BushMessage } from '../../lib/extensions/BushMessage'; @@ -36,7 +35,7 @@ export default class HelpCommand extends BushCommand { slash: true, slashOptions: [ { - type: ApplicationCommandOptionType.STRING, + type: 'STRING', name: 'command', description: 'The command you would like to find information about.', required: false diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index 107af82..60d0c1a 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -1,4 +1,3 @@ -import { ApplicationCommandOptionType } from 'discord-api-types'; import { Message, MessageEmbed, User } from 'discord.js'; import got, { HTTPError } from 'got'; import { BushCommand } from '../../lib/extensions/BushCommand'; @@ -53,7 +52,7 @@ export default class PronounsCommand extends BushCommand { clientPermissions: ['SEND_MESSAGES'], slashOptions: [ { - type: ApplicationCommandOptionType.USER, + type: 'USER', name: 'user', description: 'The user to get pronouns for', required: false diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 9d7eb4d..7ce222a 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -1,5 +1,4 @@ import { Argument } from 'discord-akairo'; -import { ApplicationCommandOptionType } from 'discord-api-types'; import { CommandInteraction, Message, User } from 'discord.js'; import moment from 'moment'; import { BushCommand } from '../../lib/extensions/BushCommand'; @@ -53,19 +52,19 @@ export default class BanCommand extends BushCommand { }, slashOptions: [ { - type: ApplicationCommandOptionType.USER, + type: 'USER', name: 'user', description: 'Who would you like to ban?', required: true }, { - type: ApplicationCommandOptionType.STRING, + type: 'STRING', name: 'reason', description: 'Why are they getting banned?', required: false }, { - type: ApplicationCommandOptionType.STRING, + type: 'STRING', name: 'time', description: 'How long should they be banned for?', required: false diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index d7fdfbd..748753f 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -1,4 +1,3 @@ -import { ApplicationCommandOptionType } from 'discord-api-types'; import { CommandInteraction, GuildMember, Message } from 'discord.js'; import { BushCommand } from '../../lib/extensions/BushCommand'; import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; @@ -33,13 +32,13 @@ export default class KickCommand extends BushCommand { }, slashOptions: [ { - type: ApplicationCommandOptionType.USER, + type: 'USER', name: 'user', description: 'The user to kick', required: true }, { - type: ApplicationCommandOptionType.STRING, + type: 'STRING', name: 'reason', description: 'The reason to show in modlogs and audit log', required: false diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index eeb2d04..9b6ad70 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -1,5 +1,4 @@ import { Argument } from 'discord-akairo'; -import { ApplicationCommandOptionType } from 'discord-api-types'; import { CommandInteraction, Message, User } from 'discord.js'; import moment from 'moment'; import { BushCommand } from '../../lib/extensions/BushCommand'; @@ -44,19 +43,19 @@ export default class MuteCommand extends BushCommand { }, slashOptions: [ { - type: ApplicationCommandOptionType.USER, + type: 'USER', name: 'user', description: 'The user to mute.', required: true }, { - type: ApplicationCommandOptionType.STRING, + type: 'STRING', name: 'reason', description: 'Why the user is getting muted.', required: false }, { - type: ApplicationCommandOptionType.STRING, + type: 'STRING', name: 'time', description: 'How long the user should be muted for.', required: false diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts index 4eb745d..f0918f0 100644 --- a/src/commands/moderation/role.ts +++ b/src/commands/moderation/role.ts @@ -1,5 +1,4 @@ /* eslint-disable @typescript-eslint/no-empty-function */ -import { ApplicationCommandOptionType } from 'discord-api-types'; import { GuildMember, Message, Role } from 'discord.js'; import { BushCommand } from '../../lib/extensions/BushCommand'; import AllowedMentions from '../../lib/utils/AllowedMentions'; @@ -58,13 +57,13 @@ export default class RoleCommand extends BushCommand { ], slashOptions: [ { - type: ApplicationCommandOptionType.USER, + type: 'USER', name: 'user', description: 'The user to add/remove the role on', required: true }, { - type: ApplicationCommandOptionType.ROLE, + type: 'ROLE', name: 'role', description: 'The role to add/remove', required: true diff --git a/src/commands/moulberry-bush/capePerms.ts b/src/commands/moulberry-bush/capePerms.ts index 49e591a..d1850c8 100644 --- a/src/commands/moulberry-bush/capePerms.ts +++ b/src/commands/moulberry-bush/capePerms.ts @@ -1,5 +1,4 @@ import { Constants } from 'discord-akairo'; -import { ApplicationCommandOptionType } from 'discord-api-types'; import { MessageEmbed } from 'discord.js'; import got from 'got'; import { BushCommand } from '../../lib/extensions/BushCommand'; @@ -62,7 +61,7 @@ export default class CapePermissionsCommand extends BushCommand { { name: 'ign', description: 'The ign of the player you would like to view the capes permissions of.', - type: ApplicationCommandOptionType.STRING, + type: 'STRING', required: true } ] diff --git a/src/commands/moulberry-bush/level.ts b/src/commands/moulberry-bush/level.ts index ea51f94..e37fa2e 100644 --- a/src/commands/moulberry-bush/level.ts +++ b/src/commands/moulberry-bush/level.ts @@ -1,4 +1,3 @@ -import { ApplicationCommandOptionType } from 'discord-api-types'; import { Message, User } from 'discord.js'; import { BushCommand } from '../../lib/extensions/BushCommand'; import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; @@ -34,7 +33,7 @@ export default class LevelCommand extends BushCommand { ], slashOptions: [ { - type: ApplicationCommandOptionType.USER, + type: 'USER', name: 'user', description: 'The user to get the level of', required: false diff --git a/src/commands/moulberry-bush/rule.ts b/src/commands/moulberry-bush/rule.ts index 8aec247..3cd9ec6 100644 --- a/src/commands/moulberry-bush/rule.ts +++ b/src/commands/moulberry-bush/rule.ts @@ -1,5 +1,4 @@ import { Argument, Constants } from 'discord-akairo'; -import { ApplicationCommandOptionType } from 'discord-api-types'; import { MessageEmbed, User } from 'discord.js'; import { BushCommand } from '../../lib/extensions/BushCommand'; import { BushMessage } from '../../lib/extensions/BushMessage'; @@ -95,13 +94,13 @@ export default class RuleCommand extends BushCommand { { name: 'rule', description: 'The rule you would you like to have cited', - type: ApplicationCommandOptionType.INTEGER, + type: 'INTEGER', required: false }, { name: 'user', description: 'The user you would like to mention.', - type: ApplicationCommandOptionType.USER, + type: 'USER', required: false } ], diff --git a/src/lib/extensions/BushClient.ts b/src/lib/extensions/BushClient.ts index 73b0864..8dd8277 100644 --- a/src/lib/extensions/BushClient.ts +++ b/src/lib/extensions/BushClient.ts @@ -1,6 +1,16 @@ import chalk from 'chalk'; import { AkairoClient } from 'discord-akairo'; -import { APIMessage, Guild, Intents, Message, MessageOptions, Snowflake, UserResolvable } from 'discord.js'; +import { + Guild, + Intents, + Message, + MessageEditOptions, + MessageOptions, + MessagePayload, + ReplyMessageOptions, + Snowflake, + UserResolvable +} from 'discord.js'; import * as path from 'path'; import { exit } from 'process'; import readline from 'readline'; @@ -20,7 +30,9 @@ import { BushListenerHandler } from './BushListenerHandler'; import { BushTaskHandler } from './BushTaskHandler'; export type BotConfig = typeof config; -export type BushMessageType = string | APIMessage | (MessageOptions & { split?: false }); +export type BushReplyMessageType = string | MessagePayload | ReplyMessageOptions; +export type BushEditMessageType = string | MessageEditOptions | MessagePayload; +export type BushSendMessageType = string | MessagePayload | MessageOptions; const rl = readline.createInterface({ input: process.stdin, diff --git a/src/lib/extensions/BushClientUtil.ts b/src/lib/extensions/BushClientUtil.ts index 34a9e83..d79a139 100644 --- a/src/lib/extensions/BushClientUtil.ts +++ b/src/lib/extensions/BushClientUtil.ts @@ -8,7 +8,6 @@ import { CommandInteraction, Constants, GuildMember, - InteractionReplyOptions, Message, MessageActionRow, MessageButton, @@ -16,6 +15,7 @@ import { MessageEditOptions, MessageEmbed, MessageOptions, + MessagePayload, Snowflake, TextChannel, User, @@ -271,7 +271,7 @@ export class BushClientUtil extends ClientUtil { }); const filter = (interaction: ButtonInteraction) => interaction.customID.startsWith('paginate_') && interaction.message == msg; - const collector = msg.createMessageComponentInteractionCollector(filter, { time: 300000 }); + const collector = msg.createMessageComponentInteractionCollector({ filter, time: 300000 }); collector.on('collect', async (interaction: MessageComponentInteraction) => { if (interaction.user.id == message.author.id || this.client.config.owners.includes(interaction.user.id)) { switch (interaction.customID) { @@ -360,7 +360,7 @@ export class BushClientUtil extends ClientUtil { updateOptions(); const msg = await message.util.reply(options as MessageOptions & { split?: false }); const filter = (interaction: ButtonInteraction) => interaction.customID == 'paginate__stop' && interaction.message == msg; - const collector = msg.createMessageComponentInteractionCollector(filter, { time: 300000 }); + const collector = msg.createMessageComponentInteractionCollector({ filter, time: 300000 }); collector.on('collect', async (interaction: MessageComponentInteraction) => { if (interaction.user.id == message.author.id || this.client.config.owners.includes(interaction.user.id)) { await interaction.deferUpdate().catch(() => undefined); @@ -418,9 +418,9 @@ export class BushClientUtil extends ClientUtil { public async slashRespond( interaction: CommandInteraction, - responseOptions: string | InteractionReplyOptions - ): Promise<Message | APIMessage | void> { - let newResponseOptions: InteractionReplyOptions | WebhookEditMessageOptions = {}; + responseOptions: string | MessagePayload | WebhookEditMessageOptions + ): Promise<Message | APIMessage> { + let newResponseOptions: string | MessagePayload | WebhookEditMessageOptions = {}; if (typeof responseOptions === 'string') { newResponseOptions.content = responseOptions; } else { @@ -429,7 +429,7 @@ export class BushClientUtil extends ClientUtil { if (interaction.replied || interaction.deferred) { //@ts-expect-error: stop being dumb delete newResponseOptions.ephemeral; // Cannot change a preexisting message to be ephemeral - return (await interaction.editReply(newResponseOptions)) as APIMessage; + return (await interaction.editReply(newResponseOptions)) as Message | APIMessage; } else { await interaction.reply(newResponseOptions); return await interaction.fetchReply().catch(() => undefined); diff --git a/src/lib/extensions/BushGuild.ts b/src/lib/extensions/BushGuild.ts index 470e93a..3c04bd6 100644 --- a/src/lib/extensions/BushGuild.ts +++ b/src/lib/extensions/BushGuild.ts @@ -8,11 +8,11 @@ export class BushGuild extends Guild { super(client, data); } - public async getSetting(setting: keyof GuildModel) { + public async getSetting<K extends keyof GuildModel>(setting: K): Promise<GuildModel[K]> { return ((await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id })).get(setting); } - public async setSetting<K extends keyof GuildModel>(setting: K, value: GuildDB[K]) { + public async setSetting<K extends keyof GuildModel>(setting: K, value: GuildDB[K]): Promise<GuildDB> { const row = (await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id }); row[setting] = value; return await row.save(); diff --git a/src/lib/utils/BushLogger.ts b/src/lib/utils/BushLogger.ts index 6adacfd..f14a05b 100644 --- a/src/lib/utils/BushLogger.ts +++ b/src/lib/utils/BushLogger.ts @@ -3,7 +3,7 @@ import chalk from 'chalk'; import { MessageEmbed } from 'discord.js'; import { inspect } from 'util'; -import { BushClient, BushMessageType } from '../extensions/BushClient'; +import { BushClient, BushSendMessageType } from '../extensions/BushClient'; export class BushLogger { private client: BushClient; @@ -68,13 +68,13 @@ export class BushLogger { } /** Sends a message to the log channel */ - public async channelLog(message: BushMessageType): Promise<void> { + public async channelLog(message: BushSendMessageType): Promise<void> { const channel = await this.client.util.getConfigChannel('log'); await channel.send(message).catch(() => {}); } /** Sends a message to the error channel */ - public async channelError(message: BushMessageType): Promise<void> { + public async channelError(message: BushSendMessageType): Promise<void> { const channel = await this.client.util.getConfigChannel('error'); await channel.send(message).catch(() => {}); } diff --git a/src/tasks/unmute.ts b/src/tasks/unmute.ts index 33cbd92..2dfa2ab 100644 --- a/src/tasks/unmute.ts +++ b/src/tasks/unmute.ts @@ -26,7 +26,7 @@ export default class UnmuteTask extends BushTask { this.client.logger.verbose(`UnmuteTask`, `Queried mutes, found <<${rows.length}>> expired mutes.`); for (const row of rows) { const guild = this.client.guilds.cache.get(row.guild); - const muteRole = (await Guild.findByPk(row.guild)).muteRole; + const muteRole = (await Guild.findByPk(row.guild))?.muteRole; if (!guild) { await row.destroy(); continue; |