From cc06b8ed4e4e0aef02dfd8ab15df22a57a177a0a Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Tue, 4 Mar 2025 10:05:14 -0500 Subject: Readme change; Docker; Logging --- bot/src/commands/avatar.js | 8 ++---- bot/src/commands/rm.js | 5 ++-- bot/src/commands/settings.js | 61 +++++++++++++++++++++++++++++++++++++--- bot/src/commands/suggest.js | 66 ++++++++++++++++++++++++++++++++++++++++++++ bot/src/commands/userinfo.js | 18 ++++++++---- 5 files changed, 139 insertions(+), 19 deletions(-) create mode 100644 bot/src/commands/suggest.js (limited to 'bot/src/commands') diff --git a/bot/src/commands/avatar.js b/bot/src/commands/avatar.js index 3d98608..a1db300 100644 --- a/bot/src/commands/avatar.js +++ b/bot/src/commands/avatar.js @@ -14,7 +14,7 @@ export default { .setDescription('Gets the member\'s server profile picture.')), async execute(interaction) { - const username = interaction.options.getUser('username'); + const username = interaction.options.getUser('username') || interaction.user; const server = interaction.options.getBoolean('server'); if (username && server) { @@ -24,10 +24,6 @@ export default { return await interaction.reply(interaction.member.avatarURL({ dynamic: true, format: 'png', size: 1024 })); } - if (!username) { - return await interaction.reply(interaction.user.avatarURL({ dynamic: true, format: 'png', size: 1024 })); - } else { - return await interaction.reply(username.avatarURL({ dynamic: true, format: 'png', size: 1024 })); - } + return await interaction.reply(username.avatarURL({ dynamic: true, format: 'png', size: 1024 })); } }; diff --git a/bot/src/commands/rm.js b/bot/src/commands/rm.js index ec6f647..7a1351c 100644 --- a/bot/src/commands/rm.js +++ b/bot/src/commands/rm.js @@ -1,4 +1,4 @@ -import { SlashCommandBuilder, PermissionFlagsBits } from 'discord.js'; +import { SlashCommandBuilder, PermissionFlagsBits, MessageFlags } from 'discord.js'; export default { data: new SlashCommandBuilder() @@ -12,8 +12,7 @@ export default { .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages), async execute(interaction) { const amount = interaction.options.getNumber('amount'); - - if (amount > 100) return interaction.reply('Put a number less than 100.'); + if (amount > 100) return interaction.reply({ content: 'Put a number less than 100.', flags: MessageFlags.Ephemeral }); return await interaction.channel.bulkDelete(amount) .then( (messages) => interaction.reply(`Deleted ${messages.size} messages.`)); diff --git a/bot/src/commands/settings.js b/bot/src/commands/settings.js index 5d32a67..00f7caf 100644 --- a/bot/src/commands/settings.js +++ b/bot/src/commands/settings.js @@ -1,4 +1,5 @@ -import { MessageFlags, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js'; +import { EmbedBuilder, MessageFlags, PermissionFlagsBits, SlashCommandBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder, ComponentType } from 'discord.js'; +import { abEmbedColour } from '../storage/consts.js'; export default { data: new SlashCommandBuilder() @@ -14,13 +15,65 @@ export default { .setDescription('Change settings for the user.')), async execute(interaction) { if (interaction.options.getSubcommand() === 'guild') { - if (!interaction.member.permissions.has(PermissionFlagsBits.ManageGuild)) return await interaction.reply({ content: 'You do not have the permission to manage this guild.', flags: MessageFlags.Ephemeral }); + //if (!interaction.member.permissions.has(PermissionFlagsBits.ManageGuild)) return await interaction.reply({ content: 'You do not have the permission to manage this guild.', flags: MessageFlags.Ephemeral }); - return await interaction.reply('recieved'); + const logging = new ButtonBuilder() + .setCustomId('logging') + .setLabel('Logging') + .setStyle(ButtonStyle.Primary); + + const suggestions = new ButtonBuilder() + .setCustomId('suggestions') + .setLabel('Suggestions') + .setStyle(ButtonStyle.Primary); + + const row = new ActionRowBuilder() + .addComponents(logging, suggestions); + + const guildEmbed = new EmbedBuilder() + .setAuthor({ name: 'AleeBot Guild Settings', iconURL: interaction.client.user.avatarURL() }) + .setDescription('Select the options') + .addFields( + { name: 'Logging', value: 'logchannel', inline: true }, + { name: 'Suggestions', value: 'channel', inline: true }, + { name: 'LLM Chatbot', value: 'Enabled', inline: true }, + { name: 'Quote of the Day', value: 'logchannel', inline: true }, + { name: 'QOTD Channel', value: 'logchannel', inline: true } + ) + .setColor(abEmbedColour); + + const guildSetup = await interaction.reply({ embeds: [guildEmbed], components: [row] }); + + const filter = (i) => i.user.id === interaction.user.id; + + const guildCollector = guildSetup.createMessageComponentCollector({ + componentType: ComponentType.Button, + filter, + time: 1000 * 120 + }); + + guildCollector.on('collect', async (interaction) => { + if (interaction.customId === 'logging') { + await interaction.reply({ content: 'Clicked on logging' }); + } + + if (interaction.customId === 'suggestions') { + await interaction.reply({ content: 'Clicked on suggestions' }); + } + }); } if (interaction.options.getSubcommand() === 'user') { - return; + const userEmbed = new EmbedBuilder() + .setAuthor({ name: 'AleeBot User Settings', iconURL: interaction.client.user.avatarURL() }) + .setDescription('Select the options') + .addFields( + { name: 'Language', value: 'logchannel', inline: true }, + { name: 'Location', value: 'channel', inline: true } + ) + .setColor(abEmbedColour); + + return await interaction.reply({ embeds: [userEmbed] }); } } }; diff --git a/bot/src/commands/suggest.js b/bot/src/commands/suggest.js new file mode 100644 index 0000000..8f75915 --- /dev/null +++ b/bot/src/commands/suggest.js @@ -0,0 +1,66 @@ +import { + ActionRowBuilder, + MessageFlags, + ModalBuilder, + SlashCommandBuilder, + TextInputBuilder, + TextInputStyle, + EmbedBuilder +} from 'discord.js'; +import { abEmbedColour, featureSuggestChannel } from '../storage/consts.js'; + +export default { + data: new SlashCommandBuilder() + .setName('suggest') + .setDescription('Suggest something either for AleeBot or this server.') + .addSubcommand(subcommand => + subcommand + .setName('feature') + .setDescription('Suggest a feature in AleeBot.')) + .addSubcommand(subcommand => + subcommand + .setName('guild') + .setDescription('Suggest something for this server.')), + async execute(interaction) { + if (interaction.options.getSubcommand() === 'feature') { + const modal = new ModalBuilder() + .setCustomId(`suggest-${interaction.user.id}`) + .setTitle('Suggest a feature for AleeBot'); + + const featureText = new TextInputBuilder() + .setCustomId('feature') + .setLabel('Suggest the feature you want') + .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(featureSuggestChannel).send({ embeds: [ + new EmbedBuilder() + .setTitle('AleeBot Feature Suggestion') + .setDescription(`This is an AleeBot feature suggested from ${modalInteraction.user.username}.`) + .addFields({ name: 'Suggestion Contents', value: feature }) + .setColor(abEmbedColour) + .setFooter({ text: `Sending from ${modalInteraction.guild.name}`, iconURL: modalInteraction.guild.iconURL() }) + ]}); + + return 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 b51ef0a..c079661 100644 --- a/bot/src/commands/userinfo.js +++ b/bot/src/commands/userinfo.js @@ -4,16 +4,22 @@ import { abEmbedColour } from '../storage/consts.js'; export default { data: new SlashCommandBuilder() .setName('userinfo') - .setDescription('Information about a user.'), + .setDescription('Information about a user.') + .addUserOption(option => + option + .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 userEmbed = new EmbedBuilder() - .setAuthor({ name: interaction.user.tag, iconURL: interaction.user.avatarURL() }) + .setAuthor({ name: username.tag, iconURL: username.avatarURL() }) .setDescription('User Information') - .setThumbnail(interaction.user.avatarURL()) + .setThumbnail(username.avatarURL()) .addFields( - { name: 'Names', value: `**Display Name:** ${interaction.member.displayName}\n**Username:** ${interaction.user.username}`}, - { name: 'Identity', value: `**User ID:** ${interaction.user.id}` }, - { name: 'Create and Join Times', value: `**Created At:** ${interaction.member.user.createdAt.toUTCString()}\n**Joined Guild At:** ${interaction.member.joinedAt.toUTCString()}`} + { 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()}`} ) .setColor(abEmbedColour); return await interaction.reply({ embeds: [userEmbed] }); -- cgit v1.2.3