Fixed discord.js v14 breaking changes

This commit is contained in:
2022-06-29 15:27:42 +07:00
parent 5c70395f50
commit 0f73f8f464
21 changed files with 340 additions and 326 deletions
+10 -9
View File
@@ -1,5 +1,5 @@
import {
MessageEmbed,
EmbedBuilder,
User,
MessagePayload,
MessageOptions,
@@ -11,7 +11,8 @@ import {
Message,
ColorResolvable,
Interaction,
InteractionReplyOptions
InteractionReplyOptions,
BaseInteraction
} from 'discord.js';
import App from '..';
@@ -43,7 +44,7 @@ interface EmbedDataPresets {
}
export function makeEmbed(data: EmbedData) {
const embed = new MessageEmbed();
const embed = new EmbedBuilder();
embed.setColor(data.color || '#FFFFFF');
if (!data.icon) embed.setTitle(data.title);
@@ -54,14 +55,14 @@ export function makeEmbed(data: EmbedData) {
if (data.setTimestamp) embed.setTimestamp();
if (data.user)
embed.footer = {
embed.setFooter({
text: `${data.user.username} | v${App.version}`,
iconURL: `${data.user.displayAvatarURL()}?size=4096`
};
});
else
embed.footer = {
embed.setFooter({
text: `v${App.version}`
};
});
if (data.fields) embed.addFields(data.fields);
@@ -160,8 +161,8 @@ export async function sendHybridInteractionMessageResponse(
data: HybridInteractionMessage,
payload: MessageOptions | InteractionReplyOptions,
replace = false
): Promise<Message | Interaction | undefined> {
if (data.isSlashCommand() || data.isButton() || data.isSelectMenu()) {
): Promise<Message | BaseInteraction | undefined> {
if (data.isApplicationCommand() || data.isButton() || data.isSelectMenu()) {
const messageComponent = data.getMessageComponentInteraction();
if (!messageComponent.replied) {
+9 -7
View File
@@ -8,7 +8,9 @@ import {
TextBasedChannel,
MessageComponentInteraction,
User,
SelectMenuInteraction
SelectMenuInteraction,
InteractionType,
BaseInteraction
} from 'discord.js';
export default class DiscordModule {
@@ -56,17 +58,17 @@ export default class DiscordModule {
}
export class HybridInteractionMessage {
public data: Interaction | Message;
constructor(data: Interaction | Message) {
public data: BaseInteraction | Message;
constructor(data: BaseInteraction | Message) {
this.data = data;
}
public isInteraction(): boolean {
return this.data instanceof Interaction;
return this.data instanceof BaseInteraction;
}
public isSlashCommand(): boolean {
return this.data instanceof CommandInteraction && this.data.isCommand();
public isApplicationCommand(): boolean {
return this.data instanceof CommandInteraction && this.data.type === InteractionType.ApplicationCommand;
}
public isButton(): boolean {
@@ -130,7 +132,7 @@ export class HybridInteractionMessage {
return this.data as Message;
}
public getRaw(): Interaction | Message {
public getRaw(): BaseInteraction | Message {
return this.data;
}
}