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/lib | |
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/lib')
-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 |
4 files changed, 26 insertions, 14 deletions
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(() => {}); } |