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
+9 -9
View File
@@ -1,4 +1,4 @@
import { Guild, Client, GuildMember, Intents, Interaction, Message, TextChannel, BaseGuildTextChannel } from 'discord.js';
import { Guild, Client, GuildMember, IntentsBitField, Interaction, Message, TextChannel, BaseGuildTextChannel, TextBasedChannelMixin, ChannelType, BaseGuildVoiceChannel, InteractionType } from 'discord.js';
import Logger from '../libs/Logger';
import Environment from './Environment';
@@ -38,13 +38,13 @@ class Discord {
constructor() {
this.client = new Client({
//partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_PRESENCES,
Intents.FLAGS.GUILD_VOICE_STATES
IntentsBitField.Flags.MessageContent,
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildPresences,
IntentsBitField.Flags.GuildVoiceStates
]
});
}
@@ -127,7 +127,7 @@ class Discord {
if (interaction.guild) {
thisModule.GuildInteractionCreate(interaction);
if (interaction.isCommand() && interaction.commandName && thisModule.commandInteractionName) {
if (interaction.type === InteractionType.ApplicationCommand && interaction.commandName && thisModule.commandInteractionName) {
thisModule.GuildCommandInteractionCreate(interaction);
if (interaction.commandName.toLowerCase() === thisModule.commandInteractionName)
thisModule.GuildModuleCommandInteractionCreate(interaction);
@@ -160,7 +160,7 @@ class Discord {
// Handling guild commands
this.client.on('messageCreate', async (message: Message) => {
if (!(message.channel instanceof BaseGuildTextChannel)) return;
if (!(message.channel instanceof BaseGuildTextChannel || message.channel instanceof BaseGuildVoiceChannel)) return;
if (message.author.bot) return;
if (typeof message.guild?.id === 'undefined') return;