aboutsummaryrefslogtreecommitdiff
path: root/bot
diff options
context:
space:
mode:
authorAndrew Lee <andrew@alee14.me>2025-03-26 16:02:25 -0400
committerAndrew Lee <andrew@alee14.me>2025-03-26 16:04:06 -0400
commitbc64422fdf34e512509cfc931569715828047c24 (patch)
tree11cc24121519b5d2fd4c65907e1979d6f426981b /bot
parentf374c5bda7a9453266e46e77da3631d655998c68 (diff)
downloadAleeBot-bc64422fdf34e512509cfc931569715828047c24.tar.gz
AleeBot-bc64422fdf34e512509cfc931569715828047c24.tar.bz2
AleeBot-bc64422fdf34e512509cfc931569715828047c24.zip
QOTD implemented; Removed readyMsg (replaced with NODE_ENV); More activities
Diffstat (limited to 'bot')
-rw-r--r--bot/Dockerfile6
-rw-r--r--bot/bun.lockbbin134376 -> 134763 bytes
-rw-r--r--bot/package.json1
-rw-r--r--bot/src/api/routes/settings.js5
-rw-r--r--bot/src/events/ClientReady.js8
-rw-r--r--bot/src/plugins/qotd.js44
-rw-r--r--bot/src/storage/activities.js36
-rw-r--r--bot/src/storage/consts.js1
8 files changed, 71 insertions, 30 deletions
diff --git a/bot/Dockerfile b/bot/Dockerfile
index c21fd47..ae74f3a 100644
--- a/bot/Dockerfile
+++ b/bot/Dockerfile
@@ -2,12 +2,8 @@ FROM oven/bun:latest
WORKDIR /bot
-COPY package.json ./
-
-COPY bun.lockb ./
+COPY . .
RUN bun install
-COPY . .
-
ENTRYPOINT ["bun", "start"]
diff --git a/bot/bun.lockb b/bot/bun.lockb
index 86b95df..070f3d3 100644
--- a/bot/bun.lockb
+++ b/bot/bun.lockb
Binary files differ
diff --git a/bot/package.json b/bot/package.json
index 4c937be..cdfb6a3 100644
--- a/bot/package.json
+++ b/bot/package.json
@@ -17,6 +17,7 @@
"discord.js": "^14.18.0",
"express": "^4.21.2",
"jsonwebtoken": "^9.0.2",
+ "node-cron": "^3.0.3",
"ollama": "^0.5.14",
"sequelize": "^6.37.6",
"sqlite3": "^5.1.7"
diff --git a/bot/src/api/routes/settings.js b/bot/src/api/routes/settings.js
index 794d302..3722fd2 100644
--- a/bot/src/api/routes/settings.js
+++ b/bot/src/api/routes/settings.js
@@ -10,7 +10,10 @@ export function settingsRouter(client) {
try {
const settings = await guildSettings.findOne({ where: { guildID: req.params.id } });
- if (!settings) return res.sendStatus(404);
+ if (!settings) {
+ await guildSettings.create({ guildID: req.params.id });
+ return res.status(200).send({ message: 'Added new guild' });
+ }
let channels = [];
diff --git a/bot/src/events/ClientReady.js b/bot/src/events/ClientReady.js
index 6a6b097..7f998ad 100644
--- a/bot/src/events/ClientReady.js
+++ b/bot/src/events/ClientReady.js
@@ -2,8 +2,8 @@ import { EmbedBuilder, Events, version } from 'discord.js';
import { readFileSync } from 'node:fs';
import { activities } from '../storage/activities.js';
-import { readyMsg, abEmbedColour } from '../storage/consts.js';
-// import { QuoteOfTheDay } from '../plugins/qotd.js';
+import { abEmbedColour } from '../storage/consts.js';
+import { QuoteOfTheDay } from '../plugins/qotd.js';
const { version: abVersion } = JSON.parse(readFileSync('./package.json', 'utf-8'));
function botActivity(client) {
@@ -29,9 +29,9 @@ export default {
console.log(`[i] Running version ${abVersion} | Serving in ${client.guilds.cache.size} guilds`);
await botActivity(client);
- //await QuoteOfTheDay(client);
+ await QuoteOfTheDay(client);
- if (readyMsg) {
+ if (process.env.NODE_ENV !== 'development') {
const readyEmbed = new EmbedBuilder()
.setAuthor({ name: 'AleeBot Status', iconURL: client.user.avatarURL() })
.setDescription('AleeBot has started')
diff --git a/bot/src/plugins/qotd.js b/bot/src/plugins/qotd.js
index a6ea73e..16ae507 100644
--- a/bot/src/plugins/qotd.js
+++ b/bot/src/plugins/qotd.js
@@ -1,28 +1,38 @@
import { EmbedBuilder } from 'discord.js';
import { abEmbedColour } from '../storage/consts.js';
import { quote as quoteDB } from '../models/quote.js';
+import { guildSettings } from '../models/guild-settings.js';
+import { schedule } from 'node-cron';
-export async function QuoteOfTheDay(client) {
- const channels = ['606602551634296968', '341669022179262464'];
- const quoteList = await quoteDB.findAll({ attributes: ['id'] });
- const random = crypto.getRandomValues(new Uint32Array(1));
+export function QuoteOfTheDay(client) {
+ schedule('0 0 * * *', async () => {
+ const enabledGuilds = await guildSettings.findAll({
+ where: { qotdToggle: true },
+ attributes: ['guildID', 'qotdChannelID']
+ });
- if (quoteList.length === 0) return console.log('[i] No quotes are currently in the database.');
+ const channels = enabledGuilds
+ .filter(guild => guild.qotdChannelID)
+ .map(guild => guild.qotdChannelID);
- let quoteID = quoteList[random[0] % quoteList.length].id;
+ const quoteList = await quoteDB.findAll({attributes: ['id']});
+ const random = crypto.getRandomValues(new Uint32Array(1));
- const quote = await quoteDB.findOne({ where: { id: quoteID } });
+ let quoteID = quoteList[random[0] % quoteList.length].id;
- let userSubmitter = await client.users.fetch(quote.submitter);
+ const quote = await quoteDB.findOne({where: {id: quoteID}});
- const quoteEmbed = new EmbedBuilder()
- .setAuthor({ name: quote.author, iconURL: quote.authorImage })
- .setDescription(quote.quote)
- .setColor(abEmbedColour)
- .setFooter({ text: `- ${quote.year}\nSubmitted by ${userSubmitter.username}` });
+ let userSubmitter = await client.users.fetch(quote.submitter);
- for (const channel of channels) {
- let qotdChannel = client.channels.cache.get(channel);
- await qotdChannel.send({ embeds: [quoteEmbed] });
- }
+ const quoteEmbed = new EmbedBuilder()
+ .setAuthor({name: quote.author, iconURL: quote.authorImage})
+ .setDescription(quote.quote)
+ .setColor(abEmbedColour)
+ .setFooter({text: `- ${quote.year}\nSubmitted by ${userSubmitter.username}`});
+
+ for (const channel of channels) {
+ let qotdChannel = client.channels.cache.get(channel);
+ await qotdChannel.send({ content: 'New Quote of the Day!', embeds: [quoteEmbed ]});
+ }
+ });
}
diff --git a/bot/src/storage/activities.js b/bot/src/storage/activities.js
index 155eeaa..73051de 100644
--- a/bot/src/storage/activities.js
+++ b/bot/src/storage/activities.js
@@ -4,6 +4,7 @@ const { version: abVersion } = JSON.parse(readFileSync('./package.json', 'utf-8'
export const activities = [
{ name: `AleeBot ${abVersion}`, type: 4 },
+ { name: `Now running on Discord.JS ${discordVersion}!`, type: 4 },
{ name: 'Coding bytes', type: 4 },
{ name: 'Drawing shapes', type: 4 },
{ name: 'Fighting Quad', type: 4 },
@@ -40,7 +41,7 @@ export const activities = [
{ name: 'Monica Is Going To Cosume You', type: 4 },
{ name: 'BLĂ…HAJ', type: 4 },
{ name: 'ShiftOS', type: 0 },
- { name: 'Histacom', type: 2 },
+ { name: 'Histacom', type: 0 },
{ name: 'Wall Street', type: 4 },
{ name: 'Mac OS X Jaguar', type: 0 },
{ name: 'Abunchoo 12.10', type: 0 },
@@ -77,10 +78,12 @@ export const activities = [
{ name: 'Splatoon 3', type: 0 },
{ name: 'Super Mario 64', type: 0 },
{ name: 'Minceraft', type: 0 },
+ { name: 'Minecraft', type: 0 },
{ name: 'Mario Kart 8', type: 0 },
{ name: 'bnbmc', type: 0 },
{ name: 'Evaluating JavaScript code', type: 4 },
{ name: 'Evaluating C# code', type: 4 },
+ { name: 'Evaluating Rust code', type: 4 },
{ name: 'Forkbombing FMP', type: 4 },
{ name: 'Merging with DLAP', type: 4 },
{ name: 'Now asbestos-free!', type: 4 },
@@ -96,6 +99,35 @@ export const activities = [
{ name: 'Turbotastic!', type: 4 },
{ name: 'Artemis', type: 0 },
{ name: 'Helping Kapuletti Industries', type: 4 },
+ { name: 'Frank (The Game)', type: 0 },
+ { name: 'Blasting earbuds with the Maraca Cracker 9000', type: 4 },
+ { name: 'Scarlet Fire', type: 2 },
{ name: 'The Beat 92.5 - MTL\'s Perfect Mix', type: 2 },
- { name: `Now running on Discord.JS ${discordVersion}!`, type: 4 }
+ { name: 'Removing unsafe code', type: 4 },
+ { name: 'Google Pixel 7', type: 0 },
+ { name: 'FreeSO', type: 0 },
+ { name: 'The Sims 1', type: 0 },
+ { name: 'The Sims 2', type: 0 },
+ { name: 'The Sims 3', type: 0 },
+ { name: 'The Sims 4', type: 0 },
+ { name: 'inZOI', type: 0 },
+ { name: 'Paralives', type: 0 },
+ { name: 'CollabVM', type: 0 },
+ { name: '86Box', type: 0 },
+ { name: 'AIM', type: 0 },
+ { name: 'Software Inc.', type: 0 },
+ { name: 'Nintendo GameBoy', type: 0 },
+ { name: 'Nintendo GameBoy Advanced', type: 0 },
+ { name: 'Nintendo DS', type: 0 },
+ { name: 'Nintendo DSi', type: 0 },
+ { name: 'Nintendo 3DS', type: 0 },
+ { name: 'Nintendo Entertainment System', type: 0 },
+ { name: 'Super Nintendo Entertainment System', type: 0 },
+ { name: 'Nintendo 64', type: 0 },
+ { name: 'Nintendo Gamecube', type: 0 },
+ { name: 'Nintendo Wii', type: 0 },
+ { name: 'Nintendo Wii U', type: 0 },
+ { name: 'Nintendo Switch', type: 0 },
+ { name: 'Nintendo Switch 2', type: 0 },
+ { name: 'Sony Playstation 2', type: 0 }
];
diff --git a/bot/src/storage/consts.js b/bot/src/storage/consts.js
index 9a408f4..231f5ca 100644
--- a/bot/src/storage/consts.js
+++ b/bot/src/storage/consts.js
@@ -1,5 +1,4 @@
export const abEmbedColour = '#0066a6';
-export const readyMsg = false;
export const ollamaGlobal = true;
export const ollamaModel = 'aleebot-deepseek';
export const featureSuggestChannel = '427495678390960148';