Add (almost complete) slash command support

This commit is contained in:
Nathaniel Mason 2022-04-22 05:44:02 +01:00
parent e3318d26c7
commit ab2cd6bd7d
27 changed files with 585 additions and 443 deletions

View File

@ -11,32 +11,37 @@ module.exports = {
type: Constants.ApplicationCommandOptionTypes.STRING
}],
async execute (client, message, args, config) {
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')));
},
handle (client, config, user, question) {
const index = Math.floor(Math.random() * config.answers.length);
const answer = config.answers[index];
const question = args.slice(0).join(' ');
const avatarURL = message.author.displayAvatarURL();
const avatarURL = user.displayAvatarURL();
if (!question) {
await message.channel.send(client.generateErrorMessage('You need to ask a question!', avatarURL));
} else {
await message.channel.send({
embeds: [{
title: ':8ball: 8Ball',
description: `Your amazing question: **${question}**`,
color: 9442302,
footer: {
icon_url: avatarURL,
text: config.footerTxt
},
fields: [
{
name: 'Answer',
value: `${answer}`
}
]
}]
});
}
if (!question) return client.generateErrorMessage('You need to ask a question!', avatarURL);
return {
embeds: [{
title: ':8ball: 8Ball',
description: `Your amazing question: **${question}**`,
color: 9442302,
footer: {
icon_url: avatarURL,
text: config.footerTxt
},
fields: [
{
name: 'Answer',
value: `${answer}`
}
]
}]
};
}
};

View File

@ -14,24 +14,32 @@ module.exports = {
name: 'userid',
description: "Another user's ID",
required: false,
type: Constants.ApplicationCommandOptionTypes.INTEGER
type: Constants.ApplicationCommandOptionTypes.STRING
}],
async execute (client, message, args, config) {
const user = message.mentions.users.first() || client.users.cache.get(args[0]) || message.author;
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));
},
await message.channel.send({
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));
},
handle (_, config, user, target) {
return {
embeds: [{
title: `:frame_photo: ${user.username}'s Beautiful Avatar!`,
title: `:frame_photo: ${target.username}'s Beautiful Avatar!`,
color: 9442302,
footer: {
icon_url: message.author.displayAvatarURL(),
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
image: {
url: user.displayAvatarURL()
url: target.displayAvatarURL()
}
}]
});
};
}
};

View File

@ -11,27 +11,30 @@ module.exports = {
type: Constants.ApplicationCommandOptionTypes.USER
}],
async execute (client, message, _, config) {
const taggedUser = message.mentions.users.first();
const avatarURL = message.author.displayAvatarURL();
async parseMessage (client, config, message) {
await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first()));
},
if (!taggedUser) {
await message.channel.send(client.generateErrorMessage('You need to @mention a user!', avatarURL));
} else {
await message.channel.send({
embeds: [{
title: '<a:SylvBonk:801185845847130113> Bonk',
description: `${taggedUser} You have been bonked by ${message.author}!`,
color: 9442302,
footer: {
icon_url: avatarURL,
text: config.footerTxt
},
image: {
url: 'https://cdn.discordapp.com/attachments/793537380330111028/801194481549312060/HappyBONK.gif'
}
}]
});
}
async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user')));
},
handle (client, config, user, target) {
if (!target) return client.generateErrorMessage('You need to @mention a user!', user.displayAvatarURL());
return {
embeds: [{
title: '<a:SylvBonk:801185845847130113> Bonk',
description: `${target} You have been bonked by ${user}!`,
color: 9442302,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
image: {
url: 'https://cdn.discordapp.com/attachments/793537380330111028/801194481549312060/HappyBONK.gif'
}
}]
};
}
};

View File

@ -11,26 +11,30 @@ module.exports = {
type: Constants.ApplicationCommandOptionTypes.USER
}],
async execute (_0, message, _1, config) {
const taggedUser = message.mentions.users.first();
async parseMessage (client, config, message) {
await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first()));
},
if (!taggedUser) {
await message.channel.send('*slams cheese on desk*\n**Cheese.** https://www.youtube.com/watch?v=Or4IE8fkpn4');
} else {
await message.channel.send({
embeds: [{
title: ':cheese: Cheesed',
description: `${taggedUser} You have been cheesed by ${message.author}!`,
color: 16312092,
footer: {
icon_url: message.author.displayAvatarURL(),
text: config.footerTxt
},
image: {
url: 'https://cdn.discordapp.com/attachments/803658122299572255/812867714368536636/R06325af354168febcafd96b8328b7590.png'
}
}]
});
}
async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user')));
},
handle (_, config, user, target) {
if (!target) return '*slams cheese on desk*\n**Cheese.** https://www.youtube.com/watch?v=Or4IE8fkpn4';
return {
embeds: [{
title: ':cheese: Cheesed',
description: `${target} You have been cheesed by ${user}!`,
color: 16312092,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
image: {
url: 'https://cdn.discordapp.com/attachments/803658122299572255/812867714368536636/R06325af354168febcafd96b8328b7590.png'
}
}]
};
}
};

View File

@ -4,27 +4,32 @@ module.exports = {
description: 'Give some lines of input, and get one back at random',
options: [],
async execute (client, message, _, config) {
const avatarURL = message.author.displayAvatarURL();
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));
},
if (!options.length) {
await message.channel.send(client.generateErrorMessage('You need to provide some input!', avatarURL));
} else {
const answer = options[Math.floor(Math.random() * options.length)];
await message.channel.send({
embeds: [{
title: 'I have made my decision:',
description: answer,
color: 8311585,
footer: {
icon_url: avatarURL,
text: config.footerTxt
}
}]
});
}
// TODO: Figure out variable input
async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getString('question')));
},
handle (client, config, user, options) {
if (!options.length) return client.generateErrorMessage('You need to provide some input!', user.displayAvatarURL());
const answer = options[Math.floor(Math.random() * options.length)];
return {
embeds: [{
title: 'I have made my decision:',
description: answer,
color: 8311585,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
}
}]
};
}
};

View File

@ -4,14 +4,22 @@ module.exports = {
description: 'Attributions to open source components used by Anitrox',
options: [],
async execute (_0, message, _1, config) {
await message.channel.send({
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));
},
handle (config, user) {
return {
embeds: [{
title: 'Contributors',
description: 'Links to check out our contributors!',
color: 52508,
footer: {
icon_url: message.author.displayAvatarURL(),
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
thumbnail: {
@ -32,6 +40,6 @@ module.exports = {
}
]
}]
});
};
}
};

View File

@ -18,29 +18,31 @@ module.exports = {
type: Constants.ApplicationCommandOptionTypes.USER
}],
async execute (client, message, _, config) {
const taggedUser = message.mentions.users.first();
const index = Math.floor(Math.random() * gifchoices.length);
const gif = (gifchoices[index]);
const avatarURL = message.author.displayAvatarURL();
async parseMessage (client, config, message) {
await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first()));
},
if (!taggedUser) {
await message.channel.send(client.generateErrorMessage('You need to @mention a user!', avatarURL));
} else {
await message.channel.send({
embeds: [{
title: ':heart: Cuddle',
description: `${taggedUser} You have been cuddled by ${message.author}!`,
color: 9442302,
footer: {
icon_url: avatarURL,
text: config.footerTxt
},
image: {
url: gif
}
}]
});
}
async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user')));
},
handle (client, config, user, target) {
if (!target) return client.generateErrorMessage('You need to @mention a user!', user.displayAvatarURL());
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
return {
embeds: [{
title: ':heart: Cuddle',
description: `${target} You have been cuddled by ${user}!`,
color: 9442302,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
image: {
url: gif
}
}]
};
}
};

View File

@ -1,37 +1,44 @@
const { Constants } = require('discord.js');
const { inspect } = require('util');
module.exports = {
name: require('path').parse(__filename).name,
description: 'Executes JS code',
description: 'handles JS code',
options: [{
name: 'text',
name: 'code',
description: 'The string to evaluate',
required: true,
type: Constants.ApplicationCommandOptionTypes.STRING
}],
async execute (_, message, args, config) {
if (message.author.id === config.ownerID) {
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')));
},
handle (_, config, user, code) {
if (user.id === config.ownerID) {
try {
const code = args.join(' ');
const evaled = inspect(eval(code));
await message.channel.send(evaled, { code: 'xl' });
// await message.channel.send(evaled, { code: 'xl' });
return `\`\`\`js\n${evaled}\n\`\`\``;
} catch (error) {
await message.channel.send({
return {
embeds: [{
title: '<:AnitroxError:809651936563429416> **Something went wrong! **',
color: 13632027,
footer: {
icon_url: message.author.displayAvatarURL(),
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
fields: [
{
name: '**What Happened?**',
value: 'The command you tried to run failed to execute due to an error.'
value: 'The command you tried to run failed to handle due to an error.'
},
{
name: 'Error Info',
@ -39,7 +46,7 @@ module.exports = {
}
]
}]
});
};
}
};
}

View File

@ -4,14 +4,22 @@ module.exports = {
description: 'Get help on anything from commands, to what the bot does! just not your homework..',
options: [],
async execute (_0, message, _1, config) {
await message.channel.send({
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));
},
handle (_, config, user) {
return {
embeds: [{
title: 'HELP! SEYMOUR! THE BOT IS ON FIRE!',
description: 'Get help on anything from commands, to what the bot does! just not your homework..',
color: 9442302,
footer: {
icon_url: message.author.displayAvatarURL(),
icon_url: user.displayAvatarURL(),
text: `${config.footerTxt} | No mother it's just the northern lights`
},
fields: [
@ -25,6 +33,6 @@ module.exports = {
}
]
}]
});
};
}
};

View File

@ -19,28 +19,31 @@ module.exports = {
type: Constants.ApplicationCommandOptionTypes.USER
}],
async execute (client, message, _, config) {
const taggedUser = message.mentions.users.first();
const avatarURL = message.author.displayAvatarURL();
async parseMessage (client, config, message) {
await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first()));
},
if (!taggedUser) {
await message.channel.send(client.generateErrorMessage('You need to @mention a user!', avatarURL));
} else {
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
await message.channel.send({
embeds: [{
title: '<a:ABlobCatHuggle:801232248035999784> Hug',
description: `${taggedUser} You have been hugged by ${message.author}!`,
color: 8311585,
footer: {
icon_url: avatarURL,
text: config.footerTxt
},
image: {
url: gif
}
}]
});
}
async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user')));
},
handle (client, config, user, target) {
if (!target) return client.generateErrorMessage('You need to @mention a user!', user.displayAvatarURL());
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
return {
embeds: [{
title: '<a:ABlobCatHuggle:801232248035999784> Hug',
description: `${target} You have been hugged by ${user}!`,
color: 8311585,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
image: {
url: gif
}
}]
};
}
};

View File

@ -20,18 +20,26 @@ module.exports = {
description: 'Shows bot and host information',
options: [],
async execute (client, message, _, config) {
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));
},
async handle (client, config, user) {
const os = require('os');
const osu = require('node-os-utils');
const cpu = osu.cpu;
await message.channel.send({
return {
embeds: [{
title: '<:AnitroxInfo:809651936831733791> Information about Anitrox',
description: "Everything you've ever wanted to know about your favorite bot, Anitrox!",
color: 9442302,
footer: {
icon_url: message.author.displayAvatarURL(),
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
thumbnail: {
@ -104,6 +112,6 @@ module.exports = {
}
]
}]
});
};
}
};

View File

@ -4,14 +4,22 @@ module.exports = {
description: 'Add Anitrox to your beautiful server!',
options: [],
async execute (_0, message, _1, config) {
await message.channel.send({
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')));
},
handle (_, config, user) {
return {
embeds: [{
title: 'Add Anitrox to your Server!',
description: 'Weather you want stable, or that squeaky clean fresh PTB build, we gotchu.',
color: 9442302,
footer: {
icon_url: message.author.displayAvatarURL(),
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
thumbnail: {
@ -32,6 +40,6 @@ module.exports = {
}
]
}]
});
};
}
};

View File

@ -19,28 +19,31 @@ module.exports = {
type: Constants.ApplicationCommandOptionTypes.USER
}],
async execute (client, message, _, config) {
const taggedUser = message.mentions.users.first();
const avatarURL = message.author.displayAvatarURL();
async parseMessage (client, config, message) {
await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first()));
},
if (!taggedUser) {
await message.channel.send(client.generateErrorMessage('You need to @mention a user!', avatarURL));
} else {
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
await message.channel.send({
embeds: [{
title: ':heart: Kiss',
description: `${taggedUser} You have been kissed by ${message.author}!`,
color: 9442302,
footer: {
icon_url: avatarURL,
text: config.footerTxt
},
image: {
url: gif
}
}]
});
}
async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user')));
},
handle (client, config, user, target) {
if (!target) return client.generateErrorMessage('You need to @mention a user!', user.displayAvaterURL());
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
return {
embeds: [{
title: ':heart: Kiss',
description: `${target} You have been kissed by ${user}!`,
color: 9442302,
footer: {
icon_url: user.displayAvaterURL(),
text: config.footerTxt
},
image: {
url: gif
}
}]
};
}
};

View File

@ -29,28 +29,31 @@ module.exports = {
type: Constants.ApplicationCommandOptionTypes.USER
}],
async execute (client, message, _, config) {
const taggedUser = message.mentions.users.first();
const avatarURL = message.author.displayAvatarURL();
async parseMessage (client, config, message) {
await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first()));
},
if (!taggedUser) {
await message.channel.send(client.generateErrorMessage('You need to @mention a user!', avatarURL));
} else {
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
await message.channel.send({
embeds: [{
title: ':heart: <:lesbian:803831629428686849> Kiss',
description: `${taggedUser} You have been kissed by ${message.author}!`,
color: 8311585,
footer: {
icon_url: avatarURL,
text: config.footerTxt
},
image: {
url: gif
}
}]
});
}
async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user')));
},
handle (client, config, user, target) {
if (!target) return client.generateErrorMessage('You need to @mention a user!', user.displayAvatarURL());
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
return {
embeds: [{
title: ':heart: <:lesbian:803831629428686849> Kiss',
description: `${target} You have been kissed by ${user}!`,
color: 8311585,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
image: {
url: gif
}
}]
};
}
};

View File

@ -18,28 +18,30 @@ module.exports = {
type: Constants.ApplicationCommandOptionTypes.USER
}],
async execute (client, message, _, config) {
const taggedUser = message.mentions.users.first();
const avatarURL = message.author.displayAvatarURL();
async parseMessage (client, config, message) {
await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first()));
},
if (!taggedUser) {
await message.channel.send(client.generateErrorMessage('You need to @mention a user!', avatarURL));
} else {
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
await message.channel.send({
embeds: [{
title: '<a:LeafeonLick:806396195089154058> Lick',
description: `${taggedUser} You have been licked by ${message.author}!`,
color: 8311585,
footer: {
icon_url: avatarURL,
text: config.footerTxt
},
image: {
url: gif
}
}]
});
}
async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user')));
},
handle (client, config, user, target) {
if (!target) return client.generateErrorMessage('You need to @mention a user!', user.displayAvatarURL());
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
return {
embeds: [{
title: '<a:LeafeonLick:806396195089154058> Lick',
description: `${target} You have been licked by ${user}!`,
color: 8311585,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
image: {
url: gif
}
}]
};
}
};

View File

@ -18,28 +18,31 @@ module.exports = {
type: Constants.ApplicationCommandOptionTypes.USER
}],
async execute (client, message, _, config) {
const taggedUser = message.mentions.users.first();
const avatarURL = message.author.displayAvatarURL();
async parseMessage (client, config, message) {
await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first()));
},
if (!taggedUser) {
await message.channel.send(client.generateErrorMessage('You need to @mention a user!', avatarURL));
} else {
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
await message.channel.send({
embeds: [{
title: '<:BlobNomBlob:801241117919805510> Nom',
description: `${taggedUser} You have been nommed by ${message.author}!`,
color: 8311585,
footer: {
icon_url: avatarURL,
text: config.footerTxt
},
image: {
url: gif
}
}]
});
}
async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user')));
},
handle (client, config, user, target) {
if (!target) return client.generateErrorMessage('You need to @mention a user!', user.displayAvatarURL());
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
return {
embeds: [{
title: '<:BlobNomBlob:801241117919805510> Nom',
description: `${target} You have been nommed by ${user}!`,
color: 8311585,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
image: {
url: gif
}
}]
};
}
};

View File

@ -17,28 +17,30 @@ module.exports = {
type: Constants.ApplicationCommandOptionTypes.USER
}],
async execute (client, message, _, config) {
const taggedUser = message.mentions.users.first();
const avatarURL = message.author.displayAvatarURL();
async parseMessage (client, config, message) {
await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first()));
},
if (!taggedUser) {
await message.channel.send(client.generateErrorMessage('You need to @mention a user!', avatarURL));
} else {
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
await message.channel.send({
embeds: [{
title: '<:pats:801238281286713355> Pat',
description: `${taggedUser} You have been patted by ${message.author}!`,
color: 8311585,
footer: {
icon_url: avatarURL,
text: config.footerTxt
},
image: {
url: gif
}
}]
});
}
async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user')));
},
handle (client, config, user, target) {
if (!target) return client.generateErrorMessage('You need to @mention a user!', user.displayAvatarURL());
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
return {
embeds: [{
title: '<:pats:801238281286713355> Pat',
description: `${target} You have been patted by ${user}!`,
color: 8311585,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
image: {
url: gif
}
}]
};
}
};

View File

@ -4,20 +4,28 @@ module.exports = {
description: 'Gets bot ping',
options: [],
async execute (client, message, _, config) {
async parseMessage (client, config, message, args) {
await message.channel.send(await this.handle(client, config, message.author, args.slice(0).join(' ')));
},
async parseInteraction (client, config, interaction) {
await interaction.reply(await this.handle(client, config, interaction.user, interaction.options.getString('question')));
},
async handle (client, config, user) {
const index = Math.floor(Math.random() * config.locations.length);
const location = config.locations[index];
await message.channel.send({
return {
embeds: [{
title: ':ping_pong: Ping',
description: `**Pong!** We pinged **${location}** and got ${client.ws.ping} ms.`,
color: 9442302,
footer: {
icon_url: message.author.displayAvatarURL(),
icon_url: user.displayAvatarURL(),
text: config.footerTxt
}
}]
});
};
}
};

View File

@ -17,28 +17,31 @@ module.exports = {
type: Constants.ApplicationCommandOptionTypes.USER
}],
async execute (client, message, _, config) {
const taggedUser = message.mentions.users.first();
const avatarURL = message.author.displayAvatarURL();
async parseMessage (client, config, message) {
await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first()));
},
if (!taggedUser) {
await message.channel.send(client.generateErrorMessage('You need to @mention a user!', avatarURL));
} else {
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
await message.channel.send({
embeds: [{
title: '👉 Poke!',
description: `${taggedUser} You have been poked by ${message.author}!`,
color: 8311585,
footer: {
icon_url: avatarURL,
text: config.footerTxt
},
image: {
url: gif
}
}]
});
}
async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user')));
},
handle (client, config, user, target) {
if (!target) return client.generateErrorMessage('You need to @mention a user!', user.displayAvatarURL());
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
return {
embeds: [{
title: '👉 Poke!',
description: `${target} You have been poked by ${user}!`,
color: 8311585,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
image: {
url: gif
}
}]
};
}
};

View File

@ -4,40 +4,50 @@ module.exports = {
description: 'Reloads a command',
options: [],
async execute (client, message, args, config) {
const avatarURL = message.author.displayAvatarURL();
if (message.author.id === config.ownerID) {
if (!args.length) {
await message.channel.send(client.generateErrorMessage('You forgot to provide anything to reload, you pillock', avatarURL));
}
async parseMessage (client, config, message, args) {
await message.channel.send(this.handle(client, config, message.author, args.split(' ')));
},
// TODO: figure out variable input (again)
async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user));
},
handle (client, config, user, args) {
if (user.id === config.ownerID) {
if (!args) return client.generateErrorMessage('You forgot to provide anything to reload, you pillock', user.displayAvatarURL());
let returnMessage = '';
args.forEach(async (arg) => {
const commandName = arg.toLowerCase();
const command = message.client.commands.get(commandName) ||
message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
const command = client.commands.get(commandName) ||
client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (!command) {
await message.channel.send(client.generateErrorMessage(`There is no command with name or alias \`${commandName}\`, ${message.author}!`, avatarURL));
returnMessage += `There is no command with name or alias \`${commandName}\`\n`;
} else {
delete require.cache[require.resolve(`./${command.name}.js`)];
try {
const newCommand = require(`./${command.name}.js`);
client.commands.set(newCommand.name, newCommand);
await message.channel.send(`<:AnitroxSuccess:809651936819019796> **Reloaded \`${command.name}\` successfully!**`);
returnMessage += `Successfully reloaded \`${commandName}\`\n`;
console.log(`User reloaded ${command.name}.`);
} catch (error) {
console.error(error);
await message.channel.send(client.generateErrorMessage(`There was an error while reloading \`${command.name}\`:\n\`${error.message}\``, avatarURL));
returnMessage += `There was an error while reloading \`${command.name}\`\n`;
}
}
});
return returnMessage;
} else {
message.channel.send({
return {
embeds: [{
title: '<:AnitroxDenied:809651936642203668> **403 Forbidden**',
color: 13632027,
footer: {
icon_url: avatarURL,
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
fields: [
@ -47,7 +57,7 @@ module.exports = {
}
]
}]
});
};
}
}
};

View File

@ -4,18 +4,26 @@ module.exports = {
description: 'Restarts the bot',
options: [],
async execute (client, message, _, config) {
if (message.author.id === config.ownerID) {
async parseMessage (client, config, message, args) {
await message.channel.send(await this.handle(client, config, message.author, args.slice(0).join(' ')));
},
async parseInteraction (client, config, interaction) {
await interaction.reply(await this.handle(client, config, interaction.user, interaction.options.getString('question')));
},
async handle (client, config, user) {
if (user.id === config.ownerID) {
console.log('Anitrox is restarting now!');
await message.channel.send('<a:NyabotWorking:697147309531594843> Restarting...');
// await message.channel.send('<a:NyabotWorking:697147309531594843> Restarting...');
try {
client.destroy();
await client.login(config.token);
await message.channel.send('<:NyabotSuccess:697211376740859914> Restart Successful');
console.log('All systems go');
} catch (e) { console.log(e); }
return '<:NyabotSuccess:697211376740859914> Restart Successful';
} catch (e) { console.error(e); }
} else {
await message.channel.send('<:NyabotDenied:697145462565896194> Access Denied, You must be bot owner to execute this command.');
return '<:NyabotDenied:697145462565896194> Access Denied, You must be bot owner to execute this command.';
}
}
};

View File

@ -11,39 +11,49 @@ module.exports = {
type: Constants.ApplicationCommandOptionTypes.STRING
}],
async execute (client, message, args, config) {
const avatarURL = message.author.displayAvatarURL();
async parseMessage (client, config, message, args) {
await message.channel.send(this.handle(client, config, message.author, args.slice(0).join(' ')));
},
if (message.channel.permissionsFor(message.author).has('CHANGE_NICKNAME')) {
const newnick = args.slice(0).join(' ');
try {
await message.member.setNickname(newnick, "Nickname change requested by the server member. If you don't want users to be able to change their nickname disable 'CHANGE_NICKNAME' via Change Nickname in Roles.");
await message.channel.send({
embeds: [{
title: '<:AnitroxSuccess:809651936819019796> Nickname Changed',
color: 9442302,
footer: {
icon_url: message.author.displayAvatarURL(),
text: config.footerTxt
},
fields: [
{
name: 'Changed nickname successfully!',
value: `New Nickname: ${newnick}`
},
{
name: 'New Nickname',
value: newnick,
inline: true
}
]
}]
});
} catch (error) {
await message.channel.send(client.generateErrorMessage('Failed to set user nickname. Does the bot have the correct permissions?', avatarURL));
};
} else {
await message.channel.send(client.generateErrorMessage('You need to have permission ``CHANGE_NICKNAME`` to change your nick!', avatarURL));
}
async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getString('question')));
},
handle (client, config, user, newNick) {
return "Discord has an inbuilt slash command for this, so I think it's best we deprecate this";
// const avatarURL = message.author.displayAvatarURL();
// if (message.channel.permissionsFor(message.author).has('CHANGE_NICKNAME')) {
// const newnick = args.slice(0).join(' ');
// try {
// await message.member.setNickname(newnick, "Nickname change requested by the server member. If you don't want users to be able to change their nickname disable 'CHANGE_NICKNAME' via Change Nickname in Roles.");
// await message.channel.send({
// embeds: [{
// title: '<:AnitroxSuccess:809651936819019796> Nickname Changed',
// color: 9442302,
// footer: {
// icon_url: message.author.displayAvatarURL(),
// text: config.footerTxt
// },
// fields: [
// {
// name: 'Changed nickname successfully!',
// value: `New Nickname: ${newnick}`
// },
// {
// name: 'New Nickname',
// value: newnick,
// inline: true
// }
// ]
// }]
// });
// } catch (error) {
// await message.channel.send(client.generateErrorMessage('Failed to set user nickname. Does the bot have the correct permissions?', avatarURL));
// };
// } else {
// await message.channel.send(client.generateErrorMessage('You need to have permission ``CHANGE_NICKNAME`` to change your nick!', avatarURL));
// }
}
};

View File

@ -11,27 +11,29 @@ module.exports = {
type: Constants.ApplicationCommandOptionTypes.USER
}],
async execute (client, message, _, config) {
const taggedUser = message.mentions.users.first();
const avatarURL = message.author.displayAvatarURL();
async parseMessage (client, config, message) {
await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first()));
},
if (!taggedUser) {
await message.channel.send(client.generateErrorMessage('You need to @mention a user!', avatarURL));
} else {
await message.channel.send({
embeds: [{
title: ':anger: Slap',
description: `${taggedUser} You have been slapped by ${message.author}!`,
color: 9442302,
footer: {
icon_url: avatarURL,
text: config.footerTxt
},
image: {
url: 'https://media1.tenor.com/images/b6d8a83eb652a30b95e87cf96a21e007/tenor.gif?itemid=10426943'
}
}]
});
}
async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user')));
},
handle (client, config, user, target) {
if (!target) return client.generateErrorMessage('You need to @mention a user!', user.displayAvatarURL());
return {
embeds: [{
title: ':anger: Slap',
description: `${target} You have been slapped by ${user}!`,
color: 9442302,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
image: {
url: 'https://media1.tenor.com/images/b6d8a83eb652a30b95e87cf96a21e007/tenor.gif?itemid=10426943'
}
}]
};
}
};

View File

@ -17,28 +17,31 @@ module.exports = {
type: Constants.ApplicationCommandOptionTypes.USER
}],
async execute (client, message, _, config) {
const taggedUser = message.mentions.users.first();
const avatarURL = message.author.displayAvatarURL();
async parseMessage (client, config, message) {
await message.channel.send(this.handle(client, config, message.author, message.mentions.users.first()));
},
if (!taggedUser) {
await message.channel.send(client.generateErrorMessage('You need to @mention a user!', avatarURL));
} else {
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
await message.channel.send({
embeds: [{
title: '<:BlobSnuggleCat:806759753450782731> Snuggle',
description: `${taggedUser} You have been snuggled by ${message.author}!`,
color: 9442302,
footer: {
icon_url: avatarURL,
text: config.footerTxt
},
image: {
url: gif
}
}]
});
}
async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getUser('user')));
},
handle (client, config, user, target) {
if (!target) return client.generateErrorMessage('You need to @mention a user!', user.displayAvatarURL());
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
return {
embeds: [{
title: '<:BlobSnuggleCat:806759753450782731> Snuggle',
description: `${target} You have been snuggled by ${user}!`,
color: 9442302,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
image: {
url: gif
}
}]
};
}
};

View File

@ -4,33 +4,42 @@ module.exports = {
description: "IT'S TIME TO STOP!... the bot",
options: [],
async execute (_0, message, _1, config) {
if (message.author.id === config.ownerID) {
await message.channel.send({
async parseMessage (client, config, message, args) {
await message.channel.send(await this.handle(client, config, message.author, args.slice(0).join(' ')));
process.exit();
},
async parseInteraction (client, config, interaction) {
await interaction.reply(await this.handle(client, config, interaction.user, interaction.options.getString('question')));
process.exit();
},
async handle (_, config, user) {
if (user.id === config.ownerID) {
console.log('The bot is shutting down! Bye bye!');
return {
embeds: [{
title: '<a:AnitroxWorking:697147309531594843> **Shutting Down...**',
description: 'See you next time!',
color: 9442302,
footer: {
icon_url: message.author.displayAvatarURL(),
icon_url: user.displayAvatarURL(),
text: config.footerTxt
}
}]
});
console.log('The bot is shutting down! Bye bye!');
process.exit();
};
} else {
await message.channel.send({
return {
embeds: [{
title: '<:AnitroxDenied:809651936642203668> 403 Forbidden',
description: 'You need to be the bot owner to execute this command!',
color: 13632027,
footer: {
icon_url: message.author.displayAvatarURL(),
icon_url: user.displayAvatarURL(),
text: config.footerTxt
}
}]
});
};
}
}
};

View File

@ -9,66 +9,68 @@ module.exports = {
description: 'Another user',
required: false,
type: Constants.ApplicationCommandOptionTypes.USER
},
{
name: 'userid',
description: "Another user's ID",
required: false,
type: Constants.ApplicationCommandOptionTypes.INTEGER
}],
async execute (_0, message, _1, config) {
const user = message.mentions.users.first() || message.member;
async parseMessage (client, config, message) {
const target = message.mentions.members.first() || message.member;
await message.channel.send(this.handle(client, config, message.author, target));
},
await message.channel.send({
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));
},
handle (client, config, user, target) {
return {
embeds: [{
title: `Everything you've ever wanted to know about ${user.user}!`,
title: `Everything you've ever wanted to know about ${target}!`,
color: 9442302,
footer: {
icon_url: message.author.displayAvatarURL(),
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
thumbnail: {
url: user.user.displayAvatarURL()
url: target.displayAvatarURL()
},
fields: [
{
name: 'Username',
value: user.user.username,
value: target.user.username,
inline: true
},
{
name: 'Discriminator',
value: user.user.discriminator,
value: target.user.discriminator,
inline: true
},
{
name: 'Full Username',
value: user.user.tag,
value: target.user.tag,
inline: true
},
{
name: 'User Profile Picture',
value: user.user.displayAvatarURL()
value: target.user.displayAvatarURL()
},
{
name: 'User Status',
value: user.presence?.status ?? 'Error getting status, does the bot have the GUILD_PRESENCES intent?'
value: target.presence?.status ?? (config.intents.includes('GUILD_PRESENCES') ? 'Offline' : 'Missing GUILD_PRESENCES intent')
// IMPORTANT NOTE:
// There seems to be an issue where offline and invisible users return a null presense
// I'll try to patch this soon if I can figure out why
},
{
name: 'User ID',
value: `\`${user.user.id}\``
value: `\`${target.user.id}\``
},
{
name: 'User Joined Discord',
value: user.user.createdAt.toString(),
value: target.user.createdAt.toString(),
inline: true
}
]
}]
});
};
}
};

View File

@ -32,25 +32,26 @@ client.generateErrorMessage = (errorMsg, avatarURL) => ({
client.on('error', (e) => console.log(`[ERROR] ${e}`));
client.on('warn', (e) => (`[WARN] ${e}`));
client.once('ready', async () => {
const commands = config.sandbox ? client.guilds.cache.get(config.sandboxGuild)?.commands : client.application.commands;
// const commands = config.sandbox ? client.guilds.cache.get(config.sandboxGuild)?.commands : client.application.commands;
if (config.sandbox) {
console.log('deleting previous commands from sandbox');
const localCommands = await commands.fetch();
localCommands.forEach(async x => {
await commands.delete(x);
});
// if (config.sandbox) {
// console.log('deleting previous commands from sandbox');
// const localCommands = await commands.fetch();
// localCommands.forEach(async x => {
// await commands.delete(x);
// });
// console.log('deleting global commands');
// const globalCommands = await client.application.commands.fetch();
// globalCommands.forEach(async x => {
// await client.application.commands.delete(x);
// });
}
// console.log('deleting global commands');
// const globalCommands = await client.application.commands.fetch();
// globalCommands.forEach(async x => {
// await client.application.commands.delete(x);
// });
// }
client.commands.forEach(async command => {
await commands.create(command);
});
// client.commands.forEach(async command => {
// await commands.create(command);
// console.log(command);
// });
// console.clear();
console.log(' ___ _ __ ');
@ -78,9 +79,9 @@ client.on('messageCreate', async (message) => {
if (!client.commands.has(command)) return;
try {
await client.commands.get(command).execute(client, message, args, config);
await client.commands.get(command).parseMessage(client, config, message, args);
} catch (error) {
console.trace();
console.log(error);
message.channel.send({
embeds: [{
title: '<:AnitroxError:809651936563429416> **Something went wrong!**',
@ -95,4 +96,8 @@ client.on('messageCreate', async (message) => {
}
});
client.on('interactionCreate', async (interaction) => {
client.commands.get(interaction.commandName).parseInteraction(client, config, interaction);
});
client.login(config.token);