commit db54eab0aec7c84c0d42dcef4964614a65e86c3b Author: WubzyGD Date: Tue Jul 15 05:01:01 2025 -0500 dear lord diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bdc872c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +json/auth.json \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/Senko.iml b/.idea/Senko.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/.idea/Senko.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 0000000..30bab2a --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml new file mode 100644 index 0000000..1c380a6 --- /dev/null +++ b/.idea/material_theme_project_new.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..3ce3588 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..2ab89a5 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/bot.js b/bot.js new file mode 100644 index 0000000..bdbb049 --- /dev/null +++ b/bot.js @@ -0,0 +1,45 @@ +const Discord = require('discord.js'); + +const errorhandler = require('./util/log/errorhandler'); +const log = require('./util/log/log'); +const wait = require('./util/misc/wait'); + +const flags = Discord.GatewayIntentBits; +const partials = Discord.Partials; +let fl = []; Object.keys(flags).forEach(flag => fl.push(flags[flag])); // fuck new standards i'm in't'zing with all the flags. +const client = new Discord.Client({intents: fl, partials: [partials.Channel, partials.Message, partials.Reaction]}); + +let waitAmount = 1000 * 10; +function testConnection() { + return new Promise(async r => { + require('dns').lookup('www.google.com', async e => { + if (e) {await wait(waitAmount); waitAmount *= 2; await testConnection(); r();} + else {r();} + }) + }); +} + + +const startBot = async () => { + + client.config = require('./json/config.json'); + client.auth = require('./json/auth.json'); + client.config.randResp = require('./json/randresp.json'); + + require('./util/misc/setutils')(client); + require('./util/misc/embed')(client); + + const loggers = log(client); + Object.keys(loggers).forEach(logger => client[logger] = loggers[logger]); + + client.log(client.utils.gr(client.config.randResp.clistart), {color: "#78d9f8", source: client.config.bot.consoleName}, true, true); //senko's wakeup log + + require('./bot/startup/run/getflags')(client); + + await require('./db/connect')(client); //connect to database + await require('./bot/startup/run/collect')(client); //load in commands and events + await require('./bot/startup/run/login')(client); //log in to discord + +} + +testConnection().then(() => startBot().catch(e => errorhandler(client, e))); \ No newline at end of file diff --git a/bot/runtime/commands/dev/reload.js b/bot/runtime/commands/dev/reload.js new file mode 100644 index 0000000..9c4952f --- /dev/null +++ b/bot/runtime/commands/dev/reload.js @@ -0,0 +1,33 @@ +const Discord = require('discord.js'); +const fs = require('fs'); +const chalk = require('chalk'); +const ora = require('ora'); + +const {EmbedBuilder} = require("discord.js"); + +module.exports = { + name: "reload", + aliases: ['relog', 'rel', 'refresh'], + help: new EmbedBuilder() + .setTitle("Help -> System Reloading") + .setDescription("Reloads the system extensions by refreshing all command and event files into client without terminating the node process.") + .addFields( + [{name: "Syntax", value: "`reload [log]`. Adding 'log' will log to the console as though the bot were in startup."}, + {name: "Notice", value: "This command is only available to developers."}] + ), + category: 'Developer', + info: "Refresh all client commands and events and clear most of the require cache.", + syntax: '`reload`', + async execute(client, message, args, cmd) { + if (!client.config.developers.has(message.author.id)) {return message.channel.send(`You must be a ${client.config.bot.name} developer in order to do this!`);} + + if (!args.length) { + let timer = new Date().getTime(); + let commands = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); + let dirSet = new Map(); + fs.readdirSync('./commands').filter(file => !file.includes('.')).forEach(dir => fs.readdirSync(`./commands/${dir}`).filter(file => file.endsWith('.js')).forEach(x => {commands.push(x); dirSet.set(x, dir)})); + client.warn(`${chalk.gray('Reload:')} ${chalk.white('All commands and events are being reloaded!')}\``); + client.log(`Developer ${message.author.username} initiated the system refresh`, {color: 'ff4fd0', source: "info"}, 0, 1); + } + } +}; \ No newline at end of file diff --git a/bot/runtime/commands/misc/info.js b/bot/runtime/commands/misc/info.js new file mode 100644 index 0000000..3b83ed6 --- /dev/null +++ b/bot/runtime/commands/misc/info.js @@ -0,0 +1,17 @@ +module.exports = { + name: "info", + aliases: ["i"], + syntax: '`info`', + category: 'Misc', + info: "Provides information about Senko.", + help: null, + guildOnly: false, + async run(client, message, args, cmd) { + message.channel.send({embeds: [client.embeds.base() + .setTitle("Senko the Helpful Sserver Mascot!") + .setThumbnail(message.guild ? message.guild.iconURL({dynamic: true, size: 2048}) : client.user.avatarURL()) + .setDescription("My name is Senko! I was developed by Kitsuu to help the LHTranslation team do their work more efficiently. " + + "I notify TLs when new chapters of their current series have been released, and may eventually track chapter status more precisely for users to see.") + ]}); + } +}; \ No newline at end of file diff --git a/json/config.json b/json/config.json new file mode 100644 index 0000000..c9caa4a --- /dev/null +++ b/json/config.json @@ -0,0 +1,30 @@ +{ + "bot": { + "name": "Senko", + "consoleName": "SNKO", + "prefix": "+", + "devPrefix": "s!" + }, + "embed": { + "colors": { + "base": "faba28", + "success": "23d534", + "fail": "d52334" + } + }, + "log": { + "suffix": ">>", + "defaultLevel": 1, + "colors": { + "error": "redBright", + "warn": "yellowBright", + "success": "greenBright", + "notice": "#8521a0", + "primary": "blue", + "secondary": "green", + "altprimary": "blueBright", + "altsecondary": "greenBright" + } + }, + "developers": ["330547934951112705"] +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..7a16fe1 --- /dev/null +++ b/package.json @@ -0,0 +1,48 @@ +{ + "name": "Senko", + "version": "1.0.0", + "description": "", + "author": "WubzyGD", + "main": "index.js", + "engines": { + "node": ">=16.0.0" + }, + "scripts": { + "start": "node bot.js", + "start:pretty": "node bot.js -g -s", + "swin": "run", + "dev": "node bot.js -dev", + "dev:pretty": "node bot.js -dev -g -s", + "presync": "git pull origin", + "sync": "git push origin", + "postsync": "git push wubzy" + }, + "dependencies": { + "@discordjs/rest": "^2.4.3", + "axios": "^1.10.0", + "canvas": "^3.1.0", + "chalk": "^4.1.0", + "cheerio": "^1.1.0", + "discord-api-types": "^0.37.119", + "discord.js": "^14.18.0", + "dreidels": "^0.6.1", + "express": "^4.21.2", + "fuzzysort": "^3.1.0", + "google-auth-library": "^10.1.0", + "google-spreadsheet": "^4.1.5", + "googleapis": "^152.0.0", + "gradient-string": "^2.0.2", + "lastfm": "^0.9.4", + "moment": "^2.30.1", + "moment-precise-range-plugin": "^1.3.0", + "mongoose": "^8.10.0", + "node-fetch": "^3.3.2", + "ora": "^5.3.0", + "tinygradient": "^2.0.0", + "ws": "^8.18.0" + }, + "devDependencies": { + "typescript": "^5.7.3" + }, + "private": true +} diff --git a/util/misc/embed.js b/util/misc/embed.js new file mode 100644 index 0000000..fca5576 --- /dev/null +++ b/util/misc/embed.js @@ -0,0 +1,32 @@ +const {EmbedBuilder} = require("discord.js"); + +const getFooterIcon = (client, message, options) => options + ? options.footerIcon === "bot" + ? client.user.avatarURL() + : options.footerIcon === "user" + ? message.member + ? message.member.displayAvatarURL({dynamic: true}) + : message.author.displayAvatarURL({dynamic: true}) + : options.footerIcon === "server" + ? message.guild + ? message.guild.iconURL({dynamic: true}) + : client.user.avatarURL() + : client.user.avatarURL() + : client.user.avatarURL(); + +module.exports = client => { + client.embeds = { + base: (message, options) => new EmbedBuilder() + .setColor(client.config.embed.colors.base) + .setFooter({text: client.config.bot.name, iconURL: getFooterIcon(client, message, options)}) + .setTimestamp(), + success: (message, options) => new EmbedBuilder() + .setColor(client.config.embed.colors.success) + .setFooter({text: client.config.bot.name, iconURL: getFooterIcon(client, message, options)}) + .setTimestamp(), + fail: (message, options) => new EmbedBuilder() + .setColor(client.config.embed.colors.fail) + .setFooter({text: client.config.bot.name, iconURL: getFooterIcon(client, message, options)}) + .setTimestamp() + } +}; \ No newline at end of file