aboutsummaryrefslogtreecommitdiff
path: root/bot/src/commands
diff options
context:
space:
mode:
authorAndrew Lee <andrew@alee14.me>2025-03-07 17:22:21 -0500
committerAndrew Lee <andrew@alee14.me>2025-03-07 17:22:21 -0500
commitc921e5cf8862def58029bd1801074c51113f86ae (patch)
tree99c8c513fd56863984ee458e747f69a87ad3c715 /bot/src/commands
parentcc06b8ed4e4e0aef02dfd8ab15df22a57a177a0a (diff)
downloadAleeBot-c921e5cf8862def58029bd1801074c51113f86ae.tar.gz
AleeBot-c921e5cf8862def58029bd1801074c51113f86ae.tar.bz2
AleeBot-c921e5cf8862def58029bd1801074c51113f86ae.zip
More settings; Better error message; Database
Diffstat (limited to 'bot/src/commands')
-rw-r--r--bot/src/commands/about.js2
-rw-r--r--bot/src/commands/quote.js2
-rw-r--r--bot/src/commands/rm.js2
-rw-r--r--bot/src/commands/settings.js79
-rw-r--r--bot/src/commands/suggest.js2
5 files changed, 75 insertions, 12 deletions
diff --git a/bot/src/commands/about.js b/bot/src/commands/about.js
index 8d3efab..311200e 100644
--- a/bot/src/commands/about.js
+++ b/bot/src/commands/about.js
@@ -23,7 +23,7 @@ export default {
{ name: 'License', value: 'GNU General Public License v3.0' },
{ name: 'Contributors', value: '- <@297201585090723841> (Uptime command from 2.x)' }
)
- .setFooter({ text: '© Copyright 2017-2025 Andrew Lee Projects' })
+ .setFooter({ text: '© Copyright 2017-2025 Andrew Lee & contributors' })
.setColor(abEmbedColour);
let Buttons = new ActionRowBuilder()
diff --git a/bot/src/commands/quote.js b/bot/src/commands/quote.js
index 60e35b9..3ae1de3 100644
--- a/bot/src/commands/quote.js
+++ b/bot/src/commands/quote.js
@@ -97,7 +97,7 @@ export default {
return modalInteraction.reply({ content: 'Something went wrong.', flags: MessageFlags.Ephemeral });
});
- return modalInteraction.reply({content: 'Sending this quote for manual approval.', flags: MessageFlags.Ephemeral});
+ return await modalInteraction.reply({content: 'Sending this quote for manual approval.', flags: MessageFlags.Ephemeral});
})
.catch((err) => {
console.error(err);
diff --git a/bot/src/commands/rm.js b/bot/src/commands/rm.js
index 7a1351c..9edfdc4 100644
--- a/bot/src/commands/rm.js
+++ b/bot/src/commands/rm.js
@@ -12,7 +12,7 @@ export default {
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
async execute(interaction) {
const amount = interaction.options.getNumber('amount');
- if (amount > 100) return interaction.reply({ content: 'Put a number less than 100.', flags: MessageFlags.Ephemeral });
+ if (amount > 100) return await 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 00f7caf..5fdf0cd 100644
--- a/bot/src/commands/settings.js
+++ b/bot/src/commands/settings.js
@@ -1,5 +1,17 @@
-import { EmbedBuilder, MessageFlags, PermissionFlagsBits, SlashCommandBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder, ComponentType } from 'discord.js';
+import {
+ EmbedBuilder,
+ MessageFlags,
+ PermissionFlagsBits,
+ SlashCommandBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ ActionRowBuilder,
+ ComponentType,
+ ChannelType,
+ ChannelSelectMenuBuilder
+} from 'discord.js';
import { abEmbedColour } from '../storage/consts.js';
+import { guildSettings } from '../models/guild-settings.js';
export default {
data: new SlashCommandBuilder()
@@ -17,6 +29,17 @@ export default {
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 });
+ const guildSetting = await guildSettings.findOne({ where: { guildID: interaction.guild.id } });
+
+ if (!guildSetting) {
+ await guildSettings.create({ guildID: interaction.guild.id });
+ }
+
+ const logMenu = new ChannelSelectMenuBuilder()
+ .setCustomId('logMenu')
+ .setPlaceholder('Select a channel')
+ .setChannelTypes(ChannelType.GuildText);
+
const logging = new ButtonBuilder()
.setCustomId('logging')
.setLabel('Logging')
@@ -27,18 +50,41 @@ export default {
.setLabel('Suggestions')
.setStyle(ButtonStyle.Primary);
+ const qotdChannel = new ButtonBuilder()
+ .setCustomId('qotdChannel')
+ .setLabel('QOTD Channel')
+ .setStyle(ButtonStyle.Primary);
+
+ const llmChatbot = new ButtonBuilder()
+ .setCustomId('llmChatbot')
+ .setLabel('LLM Chatbot')
+ .setStyle(ButtonStyle.Primary);
+
+ const qotdToggle = new ButtonBuilder()
+ .setCustomId('qotdToggle')
+ .setLabel('QOTD Toggle')
+ .setStyle(ButtonStyle.Primary);
+
+ const done = new ButtonBuilder()
+ .setCustomId('done')
+ .setLabel('Suggestions')
+ .setStyle(ButtonStyle.Success);
+
const row = new ActionRowBuilder()
- .addComponents(logging, suggestions);
+ .addComponents(logging, suggestions, qotdChannel, llmChatbot, qotdToggle);
+
+ const row2 = new ActionRowBuilder()
+ .addComponents(logMenu);
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 }
+ { name: 'Logging', value: guildSetting?.logChannelID ? `<#${guildSetting.logChannelID}>` : 'N/A', inline: true },
+ { name: 'Suggestions', value: guildSetting?.suggestionsChannelID ? `<#${guildSetting.suggestionsChannelID}>` : 'N/A', inline: true },
+ { name: 'QOTD Channel', value: guildSetting?.qotdChannelID ? `<#${guildSetting.qotdChannelID}>` : 'N/A', inline: true },
+ { name: 'LLM Chatbot', value: guildSetting?.ollamaEnabled ? 'Enabled' : 'Disabled', inline: true },
+ { name: 'Quote of the Day', value: guildSetting?.qotdToggle ? 'Enabled' : 'Disabled', inline: true }
)
.setColor(abEmbedColour);
@@ -54,7 +100,24 @@ export default {
guildCollector.on('collect', async (interaction) => {
if (interaction.customId === 'logging') {
- await interaction.reply({ content: 'Clicked on logging' });
+ await interaction.reply({ components: [row2] });
+
+ const logMenuInteraction = await interaction.channel.awaitMessageComponent({
+ componentType: ComponentType.ChannelSelectMenu,
+ filter: (i) => i.user.id === interaction.user.id,
+ time: 1000 * 120
+ });
+
+ if (logMenuInteraction.customId === 'logMenu') {
+ await logMenuInteraction.reply({ content: `Selected <#${logMenuInteraction.values}>` });
+ await guildSettings.update({ logChannelID: logMenuInteraction.values[0] }, { where: { guildID: interaction.guild.id } });
+ }
+
+ 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();
}
if (interaction.customId === 'suggestions') {
diff --git a/bot/src/commands/suggest.js b/bot/src/commands/suggest.js
index 8f75915..e4bed85 100644
--- a/bot/src/commands/suggest.js
+++ b/bot/src/commands/suggest.js
@@ -55,7 +55,7 @@ export default {
.setFooter({ text: `Sending from ${modalInteraction.guild.name}`, iconURL: modalInteraction.guild.iconURL() })
]});
- return modalInteraction.reply({content: 'Your suggestion has been sent.', flags: MessageFlags.Ephemeral});
+ return await modalInteraction.reply({content: 'Your suggestion has been sent.', flags: MessageFlags.Ephemeral});
})
.catch((err) => {
console.error(err);