diff --git a/commands/8ball.js b/commands/8ball.js index b4a5679..81b6ed8 100644 --- a/commands/8ball.js +++ b/commands/8ball.js @@ -11,6 +11,10 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.STRING }], + async parseMessage (client, config, message, args) { + await message.channel.send(this.handle(client, config, message.author, args.slice(0).join(' '))); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getString('question'))); }, diff --git a/commands/avatar.js b/commands/avatar.js index 4a01f82..519db6d 100644 --- a/commands/avatar.js +++ b/commands/avatar.js @@ -17,6 +17,11 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.STRING }], + async parseMessage (client, config, message, args) { + const target = message.mentions.users.first() || client.users.cache.get(args[0]) || message.author; + await message.channel.send(this.handle(client, config, message.author, target)); + }, + async parseInteraction (client, config, interaction) { const target = interaction.options.getUser('user') || client.users.cache.get(interaction.options.getString('userid')) || interaction.user; await interaction.reply(this.handle(client, config, interaction.user, target)); @@ -32,7 +37,7 @@ module.exports = { text: config.footerTxt }, image: { - url: target.displayAvatarURL() + url: target.displayAvatarURL({ dynamic: true }) } }] }; diff --git a/commands/bonk.js b/commands/bonk.js index f7f17a9..0dff2b4 100644 --- a/commands/bonk.js +++ b/commands/bonk.js @@ -11,6 +11,10 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.USER }], + async parseMessage (client, config, message) { + await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first())); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user'))); }, diff --git a/commands/cheese.js b/commands/cheese.js index fdfee7b..38b4f5e 100644 --- a/commands/cheese.js +++ b/commands/cheese.js @@ -11,6 +11,10 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.USER }], + async parseMessage (client, config, message) { + await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first())); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user'))); }, diff --git a/commands/choose.js b/commands/choose.js index f7a0dcb..cf841b2 100644 --- a/commands/choose.js +++ b/commands/choose.js @@ -11,6 +11,13 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.STRING })), + async parseMessage (client, config, message, args) { + let [head, ...options] = message.content.split(/\s*\n\s*/); + head = head.slice(this.name.length + config.prefix.length); + if (head) options.push(head); + await message.channel.send(this.handle(client, config, message.author, options)); + }, + async parseInteraction (client, config, interaction) { console.log([...Array(10).keys()].map(i => interaction.options.getString(`option${i + 1}`)).filter(str => str)); await interaction.reply(this.handle(client, config, interaction.user, [...Array(10).keys()].map(i => interaction.options.getString(`option${i + 1}`)).filter(str => str))); diff --git a/commands/contributors.js b/commands/contributors.js index 3658af5..9b11355 100644 --- a/commands/contributors.js +++ b/commands/contributors.js @@ -4,6 +4,10 @@ module.exports = { description: 'Attributions to open source components used by Anitrox', options: [], + async parseMessage (_, config, message) { + await message.channel.send(this.handle(config, message.author)); + }, + async parseInteraction (_, config, interaction) { await interaction.reply(this.handle(config, interaction.user)); }, diff --git a/commands/cuddle.js b/commands/cuddle.js index af515a0..bbf5e61 100644 --- a/commands/cuddle.js +++ b/commands/cuddle.js @@ -18,6 +18,10 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.USER }], + async parseMessage (client, config, message) { + await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first())); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user'))); }, diff --git a/commands/eval.js b/commands/eval.js index 48b6426..20b82d5 100644 --- a/commands/eval.js +++ b/commands/eval.js @@ -12,6 +12,10 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.STRING }], + async parseMessage (client, config, message, args) { + await message.channel.send(this.handle(client, config, message.author, args.join(' '))); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getString('code'))); }, diff --git a/commands/help.js b/commands/help.js index 4941fac..1b9eb6d 100644 --- a/commands/help.js +++ b/commands/help.js @@ -10,6 +10,9 @@ module.exports = { required: false, type: Constants.ApplicationCommandOptionTypes.STRING }], + async parseMessage (client, config, message, args) { + await message.channel.send(this.handle(client, config, message.author, args[0])); + }, async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getString('help'))); diff --git a/commands/hug.js b/commands/hug.js index e079159..b3d2f8e 100644 --- a/commands/hug.js +++ b/commands/hug.js @@ -19,6 +19,10 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.USER }], + async parseMessage (client, config, message) { + await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first())); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user'))); }, diff --git a/commands/info.js b/commands/info.js index 215f4b5..c87efd7 100644 --- a/commands/info.js +++ b/commands/info.js @@ -6,6 +6,11 @@ module.exports = { description: 'Bot and System information', options: [], + async parseMessage (client, config, message) { + await message.channel.send(this.handle(client, config, message.author)); + }, + // We'll be moving solely to Slash Commands in 1.4 + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user)); }, @@ -26,7 +31,7 @@ module.exports = { fields: [ { name: '<:anitrox:831193012699791361> Bot Information', value: '** **' }, { name: 'Bot Name', value: `${client.user.tag}`, inline: true }, - { name: 'Bot ID', value: '``' + `${client.user.id}` + '``', inline: true }, + { name: 'Bot ID', value: `${client.user.id}`, inline: true }, { name: 'Bot Owner', value: isNaN(process.env.OWNERID) ? "Owner didn't set an OwnerID :(" : client.users.cache.get(process.env.OWNERID).username, inline: true }, { name: 'Release Type', value: config.release, inline: true }, { name: 'Version', value: config.build, inline: true }, diff --git a/commands/invite.js b/commands/invite.js index d401c78..76f1033 100644 --- a/commands/invite.js +++ b/commands/invite.js @@ -4,6 +4,10 @@ module.exports = { description: 'Add Anitrox to your beautiful server!', options: [], + async parseMessage (client, config, message) { + await message.channel.send(this.handle(client, config, message.author)); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user)); }, @@ -23,8 +27,8 @@ module.exports = { }, fields: [ { name: 'Anitrox', value: 'Get the ripe off the vine Anitrox! \n [Add Anitrox to your server](https://discord.com/oauth2/authorize?client_id=576805923964715018&scope=bot&permissions=8)' }, - { name: 'Anitrox PTB (Public Test Build)', value: 'Anitrox PTB was discontinued on November 25th, 2022. \n [Learn More](https://docs.google.com/document/d/1cpmJjBEo-blxvirOtDsIT-Hrq40qVseRHBY7asBT47k/)' }, - { name: 'Anitrox Dev, Self hosting and more!', value: 'Self-host your own Anitrox (including dev!), Contribute, and more! The possibilites are endless.\n[Anitrox Source](https://github.com/IDeletedSystem64/anitrox)' }, + { name: 'Anitrox PTB (Public Test Build)', value: 'Anitrox PTB is going to be discontinued on November 25th, 2022. [Learn More](https://docs.google.com/document/d/1cpmJjBEo-blxvirOtDsIT-Hrq40qVseRHBY7asBT47k)' }, + { name: 'Anitrox Dev, Self hosting and more!', value: 'Self-host your own Anitrox (including dev!), Contribute, and more! The possibilites are endless. [Anitrox Source](https://github.com/IDeletedSystem64/anitrox)' }, { name: 'Need help?', value: 'Come join the Anitrox Support Server, for support and much more!\n [Anitrox Support Server](https://discord.gg/grebRGsBZ3)' } ] }] diff --git a/commands/kiss.js b/commands/kiss.js index 3e11842..d3c132a 100644 --- a/commands/kiss.js +++ b/commands/kiss.js @@ -19,6 +19,10 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.USER }], + async parseMessage (client, config, message) { + await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first())); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user'))); }, diff --git a/commands/leskiss.js b/commands/leskiss.js index f595539..89b34db 100644 --- a/commands/leskiss.js +++ b/commands/leskiss.js @@ -29,6 +29,10 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.USER }], + async parseMessage (client, config, message) { + await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first())); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user'))); }, diff --git a/commands/lick.js b/commands/lick.js index 80c038f..abf6257 100644 --- a/commands/lick.js +++ b/commands/lick.js @@ -18,6 +18,10 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.USER }], + async parseMessage (client, config, message) { + await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first())); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user'))); }, diff --git a/commands/nom.js b/commands/nom.js index c3dcfc3..c2ea792 100644 --- a/commands/nom.js +++ b/commands/nom.js @@ -18,6 +18,10 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.USER }], + async parseMessage (client, config, message) { + await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first())); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user'))); }, diff --git a/commands/pat.js b/commands/pat.js index 2737e1b..03baec6 100644 --- a/commands/pat.js +++ b/commands/pat.js @@ -17,6 +17,10 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.USER }], + async parseMessage (client, config, message) { + await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first())); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user'))); }, diff --git a/commands/ping.js b/commands/ping.js index f45e9af..ff623e2 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -4,6 +4,10 @@ module.exports = { description: 'Gets bot ping', options: [], + async parseMessage (client, config, message, args) { + await message.channel.send(await this.handle(client, config, message.author)); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(await this.handle(client, config, interaction.user)); }, diff --git a/commands/poke.js b/commands/poke.js index bb7c343..52a9c3f 100644 --- a/commands/poke.js +++ b/commands/poke.js @@ -17,6 +17,10 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.USER }], + async parseMessage (client, config, message) { + await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first())); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user'))); }, diff --git a/commands/reload.js b/commands/reload.js index a6f847f..9f89ac1 100644 --- a/commands/reload.js +++ b/commands/reload.js @@ -11,6 +11,10 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.STRING })), + async parseMessage (client, config, message, args) { + await message.channel.send(this.handle(client, config, message.author, args)); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user, [...Array(10).keys()].map(i => interaction.options.getString(`option${i + 1}`)).filter(str => str))); }, diff --git a/commands/restart.js b/commands/restart.js index 8c33365..51c91a2 100644 --- a/commands/restart.js +++ b/commands/restart.js @@ -4,6 +4,10 @@ module.exports = { description: 'Restarts the bot', options: [], + async parseMessage (client, config, message) { + await this.handle(client, config, message.author, message.channel); + }, + async parseInteraction (client, config, interaction) { await this.handle(client, config, interaction.user, interaction.channel); }, diff --git a/commands/slap.js b/commands/slap.js index 7a84464..c57ac8c 100644 --- a/commands/slap.js +++ b/commands/slap.js @@ -11,6 +11,10 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.USER }], + async parseMessage (client, config, message) { + await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first())); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user'))); }, diff --git a/commands/snuggle.js b/commands/snuggle.js index 6ecb14f..308202b 100644 --- a/commands/snuggle.js +++ b/commands/snuggle.js @@ -17,6 +17,10 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.USER }], + async parseMessage (client, config, message) { + await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first())); + }, + async parseInteraction (client, config, interaction) { await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user'))); }, diff --git a/commands/stop.js b/commands/stop.js index c0aca11..9035530 100644 --- a/commands/stop.js +++ b/commands/stop.js @@ -4,28 +4,32 @@ module.exports = { description: "IT'S TIME TO STOP!... the bot", options: [], - async parseInteraction (client, config, interaction) { - await this.handle(client, config, interaction); + async parseMessage (client, config, message) { + await this.handle(client, config, message.author, message.channel); }, - async handle (client, config, interaction) { - if (interaction.user.id === process.env.OWNERID) { - console.log('[SYSTEM] [INFO] ' + `The bot is going down for shut down. Shutdown requested by ${interaction.user.username}`); - await interaction.reply({ + async parseInteraction (client, config, interaction) { + await this.handle(client, config, interaction.user, interaction.channel); + }, + + async handle (client, config, user, channel) { + if (user.id === process.env.OWNERID) { + console.log('[SYSTEM] [INFO] ' + `The bot is going down for shut down. \nShutdown requested by ${user.username}`); + await channel.send({ embeds: [{ - title: 'Shutdown bot', - description: ' Shutting Down...', + title: '**Shut down the bot**', + description: ' **Shutting Down...**', color: 9442302, footer: { - icon_url: interaction.user.displayAvatarURL(), + icon_url: user.displayAvatarURL(), text: config.footerTxt } }] }); process.exit(); } else { - console.error('[SYSTEM] [ERR] User ' + interaction.user.username + " tried to shut down the bot, but doesn't have permission! If this was you, Check your config.json"); - await interaction.reply(client.generateErrorMessage('You do not have permission to run this command.', interaction.user.displayAvatarURL())); + console.error('[SYSTEM] [ERR] User ' + user.username + " tried to shut down the bot, but doesn't have permission! If this was you, Check your config.json"); + await channel.send(client.generateErrorMessage('You do not have permission to run this command.', user.displayAvatarURL())); } } }; diff --git a/commands/uinfo.js b/commands/uinfo.js index af3555b..106dbee 100644 --- a/commands/uinfo.js +++ b/commands/uinfo.js @@ -11,6 +11,11 @@ module.exports = { type: Constants.ApplicationCommandOptionTypes.USER }], + async parseMessage (client, config, message) { + const target = message.mentions.members.first() || message.member; + await message.channel.send(this.handle(client, config, message.author, target)); + }, + async parseInteraction (client, config, interaction) { const target = interaction.options.getUser('user') ? (await interaction.guild.members.fetch(interaction.options.getUser('user'))) : interaction.member; await interaction.reply(this.handle(client, config, interaction.user, target)); diff --git a/config-example.json b/config-example.json index b82129b..58500fc 100644 --- a/config-example.json +++ b/config-example.json @@ -1,4 +1,5 @@ { + "prefix": "n!", "release": "Developer Release", "build": "1.4dev", "footerTxt": "Anitrox, made with <3 by IDeletedSystem64 | 2018-2022", diff --git a/events/interactionCreate.js b/events/interactionCreate.js index 81241f4..fc3670f 100644 --- a/events/interactionCreate.js +++ b/events/interactionCreate.js @@ -8,7 +8,7 @@ module.exports = { await client.commands.get(interaction.commandName)?.parseInteraction(client, config, interaction); } catch (error) { console.error(error); - interaction.channel.send({ + interaction.reply({ embeds: [{ title: '<:AnitroxError:809651936563429416> **Something went wrong!**', description: error.stack, diff --git a/events/messageCreate.js b/events/messageCreate.js new file mode 100644 index 0000000..aa453a5 --- /dev/null +++ b/events/messageCreate.js @@ -0,0 +1,41 @@ +module.exports = { + event: require('path').parse(__filename).name, + once: false, + listener: (client, config) => + async (message) => { + if (!message.content.startsWith(config.prefix) || message.author.bot) return; + + const args = message.content.slice(config.prefix.length).split(/\s+/); + const command = args.shift()?.toLowerCase() ?? ''; + + if (!client.commands.has(command)) return; + + try { + message.channel.send({ + embeds: [{ + title: `<:AnitroxWarning:997565364718276669> Attention, ${message.author.username}!`, + description: `Anitrox will be moving entirely to slash commands in 1.4, You will no longer be able to use \`\` ${command} \`\` by typing ${config.prefix}${command}.\n Please use slash commands in the future. [Learn more](https://support.discord.com/hc/en-us/articles/1500000368501-Slash-Commands-FAQ)`, + color: 15548997, + footer: { + icon_url: message.author.displayAvatarURL(), + text: config.footerTxt + } + }] + }); + await client.commands.get(command)?.parseMessage(client, config, message, args); + } catch (error) { + console.error(error); + message.channel.send({ + embeds: [{ + title: '<:AnitroxError:809651936563429416> **Something went wrong!**', + description: error.stack, + color: 13632027, + footer: { + icon_url: message.author.displayAvatarURL(), + text: config.footerTxt + } + }] + }); + } + } +}; diff --git a/events/ready.js b/events/ready.js index e92c037..8447da3 100644 --- a/events/ready.js +++ b/events/ready.js @@ -48,7 +48,7 @@ module.exports = { console.log('/_/ |_/_/ /_/_/\\__/_/ \\____/_/|_| '); console.log(''); console.log(`${config.release}, ${config.build}`); - console.log('Bot ready. | Anitrox by IDeletedSystem64 | Now with 100% more slash commands!'); + console.log('Bot online. | Anitrox by IDeletedSystem64 | ALL MY CODE KEEPS BLOWING UP!'); // Statuses setInterval(async () => { // Picks a status from the config file diff --git a/package.json b/package.json index 9620294..8770d86 100644 --- a/package.json +++ b/package.json @@ -4,19 +4,19 @@ "description": "Discord Bot Based on Discord.JS", "main": "start.js", "dependencies": { - "discord.js": "^13.10.0", - "dotenv": "^16.0.3", - "node-fetch": "^3.2.10", - "node-os-utils": "^1.3.7", + "discord.js": "^13.6.0", + "dotenv": "^16.0.1", + "node-fetch": "^3.2.9", + "node-os-utils": "^1.3.2", "require-all": "^3.0.0" }, "author": "IDeletedSystem64", "license": "GPLv3", "devDependencies": { - "eslint": "^8.26.0", + "eslint": "^8.13.0", "eslint-config-standard": "^17.0.0", "eslint-plugin-import": "^2.26.0", - "eslint-plugin-n": "^15.3.0", - "eslint-plugin-promise": "^6.1.1" + "eslint-plugin-n": "^15.1.0", + "eslint-plugin-promise": "^6.0.0" } }