diff --git a/src/Client.ts b/src/Client.ts index 18b97d8..9bb882b 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -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); }); diff --git a/src/client/events/messageCreate.js b/src/client/events/messageCreate.js new file mode 100644 index 0000000..782042c --- /dev/null +++ b/src/client/events/messageCreate.js @@ -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); + } + } +} \ No newline at end of file