Restoring capability to use messageCreate event.

This commit is contained in:
Christer Warén 2021-09-02 12:07:08 +03:00
parent 5e53a908e7
commit f786abebe4
2 changed files with 45 additions and 0 deletions

View File

@ -11,6 +11,7 @@ const GatewayIntents = new Discord.Intents();
GatewayIntents.add(
1 << 0, // GUILDS
1 << 7, // GUILD_VOICE_STATES
1 << 9 // GUILD_MESSAGES
);
class RadioClient extends Client {
@ -46,12 +47,19 @@ class RadioClient extends Client {
require(`${events}ready`).execute(this);
this.datastore = new Datastore();
});
this.on("messageCreate", msg => {
require(`${events}messageCreate`).execute(this, msg);
});
this.on("interactionCreate", interaction => {
require(`${events}interactionCreate`).execute(this, interaction);
});
this.on("voiceStateUpdate", (oldState, newState) => {
require(`${events}voiceStateUpdate`).execute(this, oldState, newState);
});
this.on("error", error => {
console.error(error);
});

View File

@ -0,0 +1,37 @@
import Discord from "discord.js";
module.exports = {
name: 'messageCreate',
async execute(client, msg) {
if (msg.author.bot || !msg.guild) return;
let prefix = "rx$";
if(client.user.username == "RadioX"){
prefix = "rx>";
} else if (client.user.username == "RadioX Beta"){
prefix = "rx-";
} else if (client.user.username == "RadioX Dev"){
prefix = "rx$";
} else if(msg.mentions.members.first() && msg.mentions.members.first().user.id === client.user.id){
prefix = "<@!" + client.user.id + "> ";
} else {
return;
}
const args = msg.content.slice(prefix.length).split(' ');
if (!msg.content.startsWith(prefix)) return;
if (!args[0]) return;
const commandName = args[0].toLowerCase();
if (commandName === 'none') return;
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)) || client.commandAliases.get(commandName);
if (!command && msg.content !== `${prefix}`) return;
const permissions = msg.channel.permissionsFor(msg.client.user);
if (!permissions.has('EMBED_LINKS')) return msg.channel.send(client.messages.noPermsEmbed);
try {
} catch (error) {
msg.reply(client.messages.runningCommandFailed);
console.error(error);
}
}
}