aboutsummaryrefslogtreecommitdiff
path: root/bot
diff options
context:
space:
mode:
Diffstat (limited to 'bot')
-rw-r--r--bot/src/commands/fetch.js34
-rw-r--r--bot/src/commands/rm.js1
-rw-r--r--bot/src/commands/serverinfo.js3
-rw-r--r--bot/src/commands/settings.js35
-rw-r--r--bot/src/commands/suggest.js1
-rw-r--r--bot/src/commands/userinfo.js1
-rw-r--r--bot/src/events/GuildMemberAdd.js10
-rw-r--r--bot/src/events/GuildMemberRemove.js2
-rw-r--r--bot/src/events/InteractionCreate.js2
-rw-r--r--bot/src/events/MessageBulkDelete.js9
-rw-r--r--bot/src/events/MessageCreate.js15
-rw-r--r--bot/src/events/MessageDelete.js2
-rw-r--r--bot/src/events/MessageUpdate.js2
-rw-r--r--bot/src/storage/consts.js8
14 files changed, 88 insertions, 37 deletions
diff --git a/bot/src/commands/fetch.js b/bot/src/commands/fetch.js
new file mode 100644
index 0000000..651fb06
--- /dev/null
+++ b/bot/src/commands/fetch.js
@@ -0,0 +1,34 @@
+import { AttachmentBuilder, SlashCommandBuilder } from 'discord.js';
+
+export default {
+ data: new SlashCommandBuilder()
+ .setName('fetch')
+ .setDescription('Fetches JSON data.')
+ .addStringOption(option =>
+ option
+ .setName('url')
+ .setDescription('Enter the URL you want to fetch.')
+ .setRequired(true)),
+ execute(interaction) {
+ const url = interaction.options.getString('url');
+ fetch(url)
+ .then(response => response.json())
+ .then(async data => {
+ const dataString = JSON.stringify(data, null, 2);
+ if (dataString.length === 0) {
+ return await interaction.reply('Received an empty response.');
+ }
+
+ if (dataString.length > 2000) {
+ const attachment = new AttachmentBuilder(Buffer.from(dataString, 'utf-8'), { name: 'messages.json' });
+ return await interaction.reply({ files: [attachment] });
+ }
+
+ return await interaction.reply(`\`\`\`json\n${dataString}\n\`\`\``);
+ })
+ .catch(async error => {
+ console.error(error);
+ return await interaction.reply(`An error occurred while fetching the URL data.\n\`\`\`js\n${error.stack}\`\`\``);
+ });
+ }
+};
diff --git a/bot/src/commands/rm.js b/bot/src/commands/rm.js
index 9edfdc4..64543ac 100644
--- a/bot/src/commands/rm.js
+++ b/bot/src/commands/rm.js
@@ -4,6 +4,7 @@ export default {
data: new SlashCommandBuilder()
.setName('rm')
.setDescription('Purges messages.')
+ .setContexts(0)
.addNumberOption(option =>
option
.setName('amount')
diff --git a/bot/src/commands/serverinfo.js b/bot/src/commands/serverinfo.js
index 480087d..3f7bd72 100644
--- a/bot/src/commands/serverinfo.js
+++ b/bot/src/commands/serverinfo.js
@@ -4,7 +4,8 @@ import { abEmbedColour } from '../storage/consts.js';
export default {
data: new SlashCommandBuilder()
.setName('serverinfo')
- .setDescription('Information about this server.'),
+ .setDescription('Information about this server.')
+ .setContexts(0),
async execute(interaction) {
// let listedChannels = [];
let guildOwner = await interaction.guild.fetchOwner();
diff --git a/bot/src/commands/settings.js b/bot/src/commands/settings.js
index 88e108d..e5f4ee3 100644
--- a/bot/src/commands/settings.js
+++ b/bot/src/commands/settings.js
@@ -20,13 +20,14 @@ export default {
.addSubcommand(subcommand =>
subcommand
.setName('guild')
- .setDescription('Change settings for the guild.'))
- .addSubcommand(subcommand =>
- subcommand
- .setName('user')
- .setDescription('Change settings for the user.')),
+ .setDescription('Change settings for the guild.')),
+ // .addSubcommand(subcommand =>
+ // subcommand
+ // .setName('user')
+ // .setDescription('Change settings for the user.')),
async execute(interaction) {
if (interaction.options.getSubcommand() === 'guild') {
+ if (!interaction.guild) return await interaction.reply({ content: 'This command can only be run in a 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 } });
@@ -126,17 +127,17 @@ export default {
});
}
- if (interaction.options.getSubcommand() === 'user') {
- 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] });
- }
+ // if (interaction.options.getSubcommand() === 'user') {
+ // 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
index 7bb91e2..b8fe68a 100644
--- a/bot/src/commands/suggest.js
+++ b/bot/src/commands/suggest.js
@@ -65,6 +65,7 @@ export default {
}
if (interaction.options.getSubcommand() === 'guild') {
+ if (!interaction.guild) return await interaction.reply({ content: 'This command can only be run in a 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.' });
diff --git a/bot/src/commands/userinfo.js b/bot/src/commands/userinfo.js
index 0cf7332..8119a16 100644
--- a/bot/src/commands/userinfo.js
+++ b/bot/src/commands/userinfo.js
@@ -5,6 +5,7 @@ export default {
data: new SlashCommandBuilder()
.setName('userinfo')
.setDescription('Information about a user.')
+ .setContexts(0)
.addUserOption(option =>
option
.setName('username')
diff --git a/bot/src/events/GuildMemberAdd.js b/bot/src/events/GuildMemberAdd.js
index 783b29e..1e3cd54 100644
--- a/bot/src/events/GuildMemberAdd.js
+++ b/bot/src/events/GuildMemberAdd.js
@@ -1,5 +1,6 @@
import { EmbedBuilder, Events } from 'discord.js';
import { guildSettings } from '../models/guild-settings.js';
+import { autoRole, serverWhitelist, roleWhitelist } from '../storage/consts.js';
export default {
name: Events.GuildMemberAdd,
@@ -9,7 +10,7 @@ export default {
const logEmbed = new EmbedBuilder()
.setAuthor({ name: 'AleeBot Logging', iconURL: member.client.user.avatarURL() })
- .setDescription('A user has joined this server!')
+ .setDescription('A user has joined this server.')
.addFields(
{ name: 'Username: ', value: `${member.user}`, inline: true },
{ name: 'User ID: ', value: `${member.id}`, inline: true },
@@ -22,5 +23,12 @@ export default {
if (!guildMember) return;
await guildMember.send({ embeds: [logEmbed] });
+
+ if (autoRole) {
+ if (member.guild.id !== serverWhitelist) return;
+ const role = member.guild.roles.cache.get(roleWhitelist);
+ member.roles.add(role);
+ console.log(`[i] ${member.user.username} joined Andrew Lee Projects, automatically giving them role.`.green);
+ }
}
};
diff --git a/bot/src/events/GuildMemberRemove.js b/bot/src/events/GuildMemberRemove.js
index c031211..aa44366 100644
--- a/bot/src/events/GuildMemberRemove.js
+++ b/bot/src/events/GuildMemberRemove.js
@@ -9,7 +9,7 @@ export default {
const logEmbed = new EmbedBuilder()
.setAuthor({ name: 'AleeBot Logging', iconURL: member.client.user.avatarURL() })
- .setDescription('A user has left this server!')
+ .setDescription('A user has left this server.')
.addFields(
{ name: 'Username: ', value: `${member.user.username}`, inline: true },
{ name: 'User ID: ', value: `${member.id}`, inline: true },
diff --git a/bot/src/events/InteractionCreate.js b/bot/src/events/InteractionCreate.js
index 8f1e998..ac979d2 100644
--- a/bot/src/events/InteractionCreate.js
+++ b/bot/src/events/InteractionCreate.js
@@ -1,7 +1,7 @@
import { Events, MessageFlags } from 'discord.js';
function error(e) {
- return `Something went wrong. [Submit an issue at the AleeBot repository.](<https://github.com/Alee14/AleeBot/issues>)\nMessage:\n\`\`\`${e.stack}\`\`\``;
+ return `Something went wrong. [Submit an issue at the AleeBot repository.](<https://github.com/Alee14/AleeBot/issues>)\nMessage:\n\`\`\`js\n${e.stack}\`\`\``;
}
export default {
diff --git a/bot/src/events/MessageBulkDelete.js b/bot/src/events/MessageBulkDelete.js
index 1595012..92db987 100644
--- a/bot/src/events/MessageBulkDelete.js
+++ b/bot/src/events/MessageBulkDelete.js
@@ -9,16 +9,17 @@ export default {
const logEmbed = new EmbedBuilder()
.setAuthor({ name: 'AleeBot Logging', iconURL: channel.client.user.avatarURL() })
- .setDescription(`A bulk of ${msg.size} messages was deleted in ${channel}`)
+ .setDescription(`A bulk of ${msg.size} messages were deleted in ${channel}`)
.setColor('#ff021b')
.setTimestamp();
let messages = [];
msg.forEach(message => {
- messages.push(message.createdAt.toUTCString());
- messages.push(`${message.author.username} - ${message.author.id}`);
- messages.push(message.content);
+ messages.push(`[${message.createdAt.toUTCString()}]`);
+ messages.push(`${message.author.username} (${message.author.id})`);
+ messages.push(`Message (${message.id}): ${message.content}`);
+ messages.push('-----------------------------------');
});
const messageContent = messages.join('\n');
diff --git a/bot/src/events/MessageCreate.js b/bot/src/events/MessageCreate.js
index e7af3a8..8753587 100644
--- a/bot/src/events/MessageCreate.js
+++ b/bot/src/events/MessageCreate.js
@@ -1,4 +1,4 @@
-import { Events } from 'discord.js';
+import {AttachmentBuilder, Events} from 'discord.js';
import { ollama } from '../utils/ollama.js';
import { ollamaGlobal, ollamaModel } from '../storage/consts.js';
import { guildSettings } from '../models/guild-settings.js';
@@ -12,11 +12,11 @@ export default {
const guildSetting = await guildSettings.findOne({ where: { guildID: msg.guild.id } });
- const args = msg.content.slice(`<@${msg.client.user.id}>`.length).trim();
+ const args = msg.content.slice(`${msg.client.user}`.length).trim();
if (msg.mentions.has(msg.client.user)) {
if (!guildSetting.ollamaEnabled) return;
- if (!ollamaGlobal) return msg.reply('Sorry, this feature has been turned off.');
+ if (!ollamaGlobal) return msg.reply('Sorry, the LLM chatbot feature has been turned off.');
if (!args) return msg.reply('Sorry? What was that?');
try {
@@ -26,15 +26,12 @@ export default {
});
let content = response.message.content;
- content = content.replace(/<think>.*?<\/think>/g, '');
if (content.length > 2000) {
- const chunks = content.match(/[\s\S]{1,2000}/g) || [];
- for (const chunk of chunks) {
- await msg.reply({ content: chunk });
- }
+ const attachment = new AttachmentBuilder(Buffer.from(content, 'utf-8'), { name: 'output.txt' });
+ return await msg.reply({ files: [attachment] });
} else {
- await msg.reply({ content });
+ return await msg.reply({ content });
}
} catch (err) {
diff --git a/bot/src/events/MessageDelete.js b/bot/src/events/MessageDelete.js
index 62f8536..154940b 100644
--- a/bot/src/events/MessageDelete.js
+++ b/bot/src/events/MessageDelete.js
@@ -15,7 +15,7 @@ export default {
.addFields({ name: 'Deleted Message: ', value: `\`\`\`${msg.content}\`\`\`` })
.setColor('#ff021b')
.setTimestamp()
- .setFooter(`Author ID: ${msg.author.id}`);
+ .setFooter({ text: `Author ID: ${msg.author.id}` });
let deleteMessage = msg.client.channels.cache.get(guildSetting.logChannelID);
if (!deleteMessage) return;
diff --git a/bot/src/events/MessageUpdate.js b/bot/src/events/MessageUpdate.js
index f4cb769..7fc5e1b 100644
--- a/bot/src/events/MessageUpdate.js
+++ b/bot/src/events/MessageUpdate.js
@@ -1,6 +1,8 @@
import { EmbedBuilder, Events } from 'discord.js';
import { guildSettings } from '../models/guild-settings.js';
+// bug: whenever a long message is edited, the bot crashes; also make sure that the log has newline
+
export default {
name: Events.MessageUpdate,
async execute(msg, newmsg) {
diff --git a/bot/src/storage/consts.js b/bot/src/storage/consts.js
index 0787528..80a65aa 100644
--- a/bot/src/storage/consts.js
+++ b/bot/src/storage/consts.js
@@ -1,5 +1,9 @@
export const abEmbedColour = '#0066a6';
export const readyMsg = false;
-export const ollamaGlobal = false;
-export const ollamaModel = 'deepseek-r1:14b';
+export const ollamaGlobal = true;
+export const ollamaModel = 'aleebot-deepseek';
export const featureSuggestChannel = '427495678390960148';
+
+export const autoRole = true;
+export const serverWhitelist = '243022206437687296';
+export const roleWhitelist = '657426918416580614';