diff options
| author | Andrew Lee <andrew@alee14.me> | 2025-03-03 11:42:27 -0500 |
|---|---|---|
| committer | Andrew Lee <andrew@alee14.me> | 2025-03-03 11:42:27 -0500 |
| commit | fd7f8eba960981482fabf350995bf753feebb176 (patch) | |
| tree | 2bd0c85b09a04ecd8e1f20fc409eb4b8a22289a7 /bot/src/commands | |
| parent | cf1382d88c5e3298923c8cb243b7bc5751e68b53 (diff) | |
| download | AleeBot-fd7f8eba960981482fabf350995bf753feebb176.tar.gz AleeBot-fd7f8eba960981482fabf350995bf753feebb176.tar.bz2 AleeBot-fd7f8eba960981482fabf350995bf753feebb176.zip | |
More commands ported; Almost all 2.x features have been added
Diffstat (limited to 'bot/src/commands')
| -rw-r--r-- | bot/src/commands/ask.js | 2 | ||||
| -rw-r--r-- | bot/src/commands/attack.js | 17 | ||||
| -rw-r--r-- | bot/src/commands/info.js | 4 | ||||
| -rw-r--r-- | bot/src/commands/quote.js | 35 | ||||
| -rw-r--r-- | bot/src/commands/rm.js | 21 | ||||
| -rw-r--r-- | bot/src/commands/serverinfo.js | 31 | ||||
| -rw-r--r-- | bot/src/commands/userinfo.js | 2 |
7 files changed, 108 insertions, 4 deletions
diff --git a/bot/src/commands/ask.js b/bot/src/commands/ask.js index fec0846..4193e92 100644 --- a/bot/src/commands/ask.js +++ b/bot/src/commands/ask.js @@ -27,7 +27,7 @@ export default { ]; return await interaction.reply( - `<@${interaction.user.id}> asked:\n**${question}**\nMy answer:\n**${answers[Math.floor(Math.random() * answers.length)]}**` + `**${interaction.user.displayName}** asked:\n**${question}**\nMy answer:\n**${answers[Math.floor(Math.random() * answers.length)]}**` ); } }; diff --git a/bot/src/commands/attack.js b/bot/src/commands/attack.js new file mode 100644 index 0000000..2863e5a --- /dev/null +++ b/bot/src/commands/attack.js @@ -0,0 +1,17 @@ +import { SlashCommandBuilder } from 'discord.js'; + +export default { + data: new SlashCommandBuilder() + .setName('attack') + .setDescription('You don\'t like someone? Attack them!') + .addStringOption(option => + option + .setName('target') + .setDescription('Enter the target you want to attack.') + .setRequired(true)), + async execute(interaction) { + const target = interaction.options.getString('target'); + + return await interaction.reply(`${interaction.user.displayName} :right_facing_fist: ${target}`); + } +}; diff --git a/bot/src/commands/info.js b/bot/src/commands/info.js index 64d8f7a..33e1665 100644 --- a/bot/src/commands/info.js +++ b/bot/src/commands/info.js @@ -7,7 +7,7 @@ export default { .setName('info') .setDescription('Shows information about the host.'), async execute(interaction) { - const embed = new EmbedBuilder() + const hostEmbed = new EmbedBuilder() .setTitle('Information on AleeBot\'s Host') .addFields( { name: 'OS Hostname: ', value: hostname(), inline: true }, @@ -17,6 +17,6 @@ export default { { name: 'OS Version: ', value: release(), inline: true } ) .setColor(abEmbedColour); - return await interaction.reply({ embeds: [embed] }); + return await interaction.reply({ embeds: [hostEmbed] }); } }; diff --git a/bot/src/commands/quote.js b/bot/src/commands/quote.js new file mode 100644 index 0000000..eaac975 --- /dev/null +++ b/bot/src/commands/quote.js @@ -0,0 +1,35 @@ +import { SlashCommandBuilder, EmbedBuilder } from 'discord.js'; +import { quote as quoteDB } from '../models/quote.js'; +export default { + data: new SlashCommandBuilder() + .setName('quote') + .setDescription('It gives you a quote.') + .addNumberOption(option => + option + .setName('id') + .setDescription('Enter the quote ID to get a specific quote.')), + async execute(interaction) { + let quoteID = interaction.options.getNumber('id'); + + if (!quoteID) { + const quoteList = await quoteDB.findAll({ attributes: ['id'] }); + const random = crypto.getRandomValues(new Uint32Array(1)); + quoteID = quoteList[random[0] % quoteList.length].id; + } + + const quote = await quoteDB.findOne({ where: { id: quoteID } }); + + if (quote) { + let userSubmitter = await interaction.client.users.fetch(quote.submitter); + const quoteEmbed = new EmbedBuilder() + .setAuthor({ name: quote.author, iconURL: quote.authorImage }) + .setDescription(quote.quote) + .setColor('#1fd619') + .setFooter({ text: `- ${quote.year}\nSubmitted by ${userSubmitter.username}` }); + + return await interaction.reply({ embeds: [quoteEmbed] }); + } else { + return await interaction.reply('Cannot find quote, specify the correct quote id.'); + } + } +}; diff --git a/bot/src/commands/rm.js b/bot/src/commands/rm.js new file mode 100644 index 0000000..ec6f647 --- /dev/null +++ b/bot/src/commands/rm.js @@ -0,0 +1,21 @@ +import { SlashCommandBuilder, PermissionFlagsBits } from 'discord.js'; + +export default { + data: new SlashCommandBuilder() + .setName('rm') + .setDescription('Purges messages.') + .addNumberOption(option => + option + .setName('amount') + .setDescription('Enter the amount of messages you want to delete.') + .setRequired(true)) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages), + async execute(interaction) { + const amount = interaction.options.getNumber('amount'); + + if (amount > 100) return interaction.reply('Put a number less than 100.'); + + return await interaction.channel.bulkDelete(amount) + .then( (messages) => interaction.reply(`Deleted ${messages.size} messages.`)); + } +}; diff --git a/bot/src/commands/serverinfo.js b/bot/src/commands/serverinfo.js new file mode 100644 index 0000000..01b39e8 --- /dev/null +++ b/bot/src/commands/serverinfo.js @@ -0,0 +1,31 @@ +import { SlashCommandBuilder, EmbedBuilder } from 'discord.js'; +import { abEmbedColour } from '../storage/consts.js'; + +export default { + data: new SlashCommandBuilder() + .setName('serverinfo') + .setDescription('Information about this server.'), + async execute(interaction) { + // const listedChannels = []; + let guildOwner = await interaction.guild.fetchOwner(); + let memberCountNoBots = await interaction.guild.members.fetch().then((members) => members.filter(member => !member.user.bot).size); + + const serverEmbed = new EmbedBuilder() + .setAuthor({ name: `${interaction.guild.name}`, iconURL: interaction.guild.iconURL() }) + .setDescription('Server Information') + .setThumbnail(interaction.guild.iconURL()) + .addFields( + { name: 'Main Information', value: `**Server Name:** ${interaction.guild.name}\n**Server ID:** ${interaction.guild.id}\n**Server Owner:** ${guildOwner.user.tag}`}, + { name: 'Join Dates', value: `**Created At:** ${interaction.guild.createdAt.toUTCString()}\n**AleeBot Joined:** ${interaction.guild.joinedAt.toUTCString()}`}, + { name: 'Total Members (with bots)', value: `${interaction.guild.memberCount}` }, + { name: 'Total Members (without bots)', value: `${memberCountNoBots}` } + ) + /*message.guild.channels.cacheType.forEach(channel => { + listedChannels.push(channel) + })*/ + //.addField('Channels', `${listedChannels.join('\n')}`) + //.addField('Total Channels', message.guild.channelCountMode) + .setColor(abEmbedColour); + return await interaction.reply({ embeds: [serverEmbed] }); + } +}; diff --git a/bot/src/commands/userinfo.js b/bot/src/commands/userinfo.js index 01b7577..b51ef0a 100644 --- a/bot/src/commands/userinfo.js +++ b/bot/src/commands/userinfo.js @@ -16,6 +16,6 @@ export default { { name: 'Create and Join Times', value: `**Created At:** ${interaction.member.user.createdAt.toUTCString()}\n**Joined Guild At:** ${interaction.member.joinedAt.toUTCString()}`} ) .setColor(abEmbedColour); - return await interaction.reply({embeds: [userEmbed]}); + return await interaction.reply({ embeds: [userEmbed] }); } }; |
