From 52f8826e526f0c0aadb86c3e29975aef4dc1ab85 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sat, 8 Mar 2025 00:11:03 -0500 Subject: Bulk delete message event; Guild suggestions; sinfo + uinfo --- bot/src/commands/quote.js | 2 ++ bot/src/commands/serverinfo.js | 15 +++++++------- bot/src/commands/settings.js | 2 +- bot/src/commands/suggest.js | 46 +++++++++++++++++++++++++++++++++++++++++- bot/src/commands/userinfo.js | 14 ++++++------- 5 files changed, 63 insertions(+), 16 deletions(-) (limited to 'bot/src/commands') diff --git a/bot/src/commands/quote.js b/bot/src/commands/quote.js index 3ae1de3..5e5ae5b 100644 --- a/bot/src/commands/quote.js +++ b/bot/src/commands/quote.js @@ -110,6 +110,8 @@ export default { if (!quoteID) { const quoteList = await quoteDB.findAll({ attributes: ['id'] }); const random = crypto.getRandomValues(new Uint32Array(1)); + + if (quoteList.length === 0) return await interaction.reply({ content: 'No quotes are currently in the database. You can add one by doing `/quote add`.', flags: MessageFlags.Ephemeral }); quoteID = quoteList[random[0] % quoteList.length].id; } diff --git a/bot/src/commands/serverinfo.js b/bot/src/commands/serverinfo.js index 01b39e8..480087d 100644 --- a/bot/src/commands/serverinfo.js +++ b/bot/src/commands/serverinfo.js @@ -6,25 +6,26 @@ export default { .setName('serverinfo') .setDescription('Information about this server.'), async execute(interaction) { - // const listedChannels = []; + // let listedChannels = []; let guildOwner = await interaction.guild.fetchOwner(); let memberCountNoBots = await interaction.guild.members.fetch().then((members) => members.filter(member => !member.user.bot).size); + // interaction.guild.channels.cache.each(channel => { + // listedChannels.push(channel); + // }); + 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: 'Main Information', value: `**Server Name:** ${interaction.guild.name}\n**Server ID:** ${interaction.guild.id}\n**Server Owner:** ${guildOwner.user.username}`}, { name: 'Join Dates', value: `**Created At:** ${interaction.guild.createdAt.toUTCString()}\n**AleeBot Joined:** ${interaction.guild.joinedAt.toUTCString()}`}, + { name: 'Total Channels (without threads)', value: `${interaction.guild.channels.channelCountWithoutThreads}` }, + // { name: 'Channels', value: listedChannels.join(' ') }, { 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/settings.js b/bot/src/commands/settings.js index 5fdf0cd..88e108d 100644 --- a/bot/src/commands/settings.js +++ b/bot/src/commands/settings.js @@ -115,8 +115,8 @@ export default { const logSetting = await guildSettings.findOne({ where: { guildID: interaction.guild.id } }); guildEmbed.spliceFields(0, 1, { name: 'Logging', value: logSetting?.logChannelID ? `<#${logSetting.logChannelID}>` : 'N/A', inline: true }); - await interaction.editReply({ embeds: [guildEmbed], components: [row] }); + await interaction.deleteReply(); } diff --git a/bot/src/commands/suggest.js b/bot/src/commands/suggest.js index e4bed85..7bb91e2 100644 --- a/bot/src/commands/suggest.js +++ b/bot/src/commands/suggest.js @@ -8,6 +8,7 @@ import { EmbedBuilder } from 'discord.js'; import { abEmbedColour, featureSuggestChannel } from '../storage/consts.js'; +import { guildSettings } from '../models/guild-settings.js'; export default { data: new SlashCommandBuilder() @@ -50,7 +51,7 @@ export default { new EmbedBuilder() .setTitle('AleeBot Feature Suggestion') .setDescription(`This is an AleeBot feature suggested from ${modalInteraction.user.username}.`) - .addFields({ name: 'Suggestion Contents', value: feature }) + .addFields({ name: 'Suggestion Content', value: feature }) .setColor(abEmbedColour) .setFooter({ text: `Sending from ${modalInteraction.guild.name}`, iconURL: modalInteraction.guild.iconURL() }) ]}); @@ -62,5 +63,48 @@ export default { }); } + + if (interaction.options.getSubcommand() === 'guild') { + const guildSetting = await guildSettings.findOne({ where: { guildID: interaction.guild.id } }); + if (!guildSetting || !guildSetting.suggestionsChannelID) return await interaction.reply({ content: 'This server did not configure to have suggestions enabled.' }); + + const modal = new ModalBuilder() + .setCustomId(`suggest-${interaction.user.id}`) + .setTitle(`Suggestion for ${interaction.guild.name}`); + + const featureText = new TextInputBuilder() + .setCustomId('feature') + .setLabel('Suggestion') + .setMaxLength(200) + .setPlaceholder('Feature') + .setStyle(TextInputStyle.Paragraph); + + const firstActionRow = new ActionRowBuilder().addComponents(featureText); + + modal.addComponents(firstActionRow); + + await interaction.showModal(modal); + + const filter = (interaction) => interaction.customId === `suggest-${interaction.user.id}`; + + interaction.awaitModalSubmit({ filter, time: 1000 * 1200 }) + .then(async (modalInteraction) => { + const feature = modalInteraction.fields.getTextInputValue('feature'); + + modalInteraction.client.channels.cache.get(guildSetting.suggestionsChannelID).send({ embeds: [ + new EmbedBuilder() + .setTitle('Suggestion') + .setDescription(`This is a suggestion from ${interaction.user.username}.`) + .addFields({ name: 'Suggestion Content', value: feature }) + .setColor(abEmbedColour) + ]}); + + return await modalInteraction.reply({content: 'Your suggestion has been sent.', flags: MessageFlags.Ephemeral}); + }) + .catch((err) => { + console.error(err); + }); + + } } }; diff --git a/bot/src/commands/userinfo.js b/bot/src/commands/userinfo.js index c079661..0cf7332 100644 --- a/bot/src/commands/userinfo.js +++ b/bot/src/commands/userinfo.js @@ -10,16 +10,16 @@ export default { .setName('username') .setDescription('The user to get the information of')), async execute(interaction) { - const username = interaction.options.getUser('username') || interaction.user; - const member = interaction.guild.members.cache.get(username.id); + const user = interaction.options.getUser('username') || interaction.user; + const member = interaction.guild.members.cache.get(user.id); const userEmbed = new EmbedBuilder() - .setAuthor({ name: username.tag, iconURL: username.avatarURL() }) + .setAuthor({ name: user.username, iconURL: user.avatarURL() }) .setDescription('User Information') - .setThumbnail(username.avatarURL()) + .setThumbnail(user.avatarURL()) .addFields( - { name: 'Names', value: `**Display Name:** ${member.displayName}\n**Username:** ${username.username}`}, - { name: 'Identity', value: `**User ID:** ${username.id}` }, - { name: 'Create and Join Times', value: `**Created At:** ${username.createdAt.toUTCString()}\n**Joined Guild At:** ${member.joinedAt.toUTCString()}`} + { name: 'Names', value: `**Display Name:** ${member.displayName}\n**Username:** ${user.username}`}, + { name: 'Identity', value: `**User ID:** ${user.id}` }, + { name: 'Create and Join Times', value: `**Created At:** ${user.createdAt.toUTCString()}\n**Joined Guild At:** ${member.joinedAt.toUTCString()}`} ) .setColor(abEmbedColour); return await interaction.reply({ embeds: [userEmbed] }); -- cgit v1.2.3