diff options
| -rw-r--r-- | .gitignore | 19 | ||||
| -rw-r--r-- | bot/.gitignore | 137 | ||||
| -rw-r--r-- | bot/bun.lockb | bin | 0 -> 42007 bytes | |||
| -rw-r--r-- | bot/deploy-command.js | 31 | ||||
| -rw-r--r-- | bot/eslint.config.js | 15 | ||||
| -rw-r--r-- | bot/package.json | 21 | ||||
| -rw-r--r-- | bot/src/bot.js | 21 | ||||
| -rw-r--r-- | bot/src/commands/about.js | 45 | ||||
| -rw-r--r-- | bot/src/commands/ping.js | 9 | ||||
| -rw-r--r-- | bot/src/events/ClientReady.js | 36 | ||||
| -rw-r--r-- | bot/src/events/InteractionCreate.js | 19 | ||||
| -rw-r--r-- | bot/src/handler/commands.js | 20 | ||||
| -rw-r--r-- | bot/src/handler/event.js | 23 | ||||
| -rw-r--r-- | bot/src/storage/activities.js | 101 |
14 files changed, 479 insertions, 18 deletions
@@ -1,19 +1,2 @@ +.idea/
-node_modules/
-
-tokens\.json
-
-ffmpeg.exe
-
-ffplay.exe
-
-ffprobe.exe
-
-.directory
-
-.vs/slnx.sqlite
-.vs/slnx.sqlite-journal
-json.sqlite
-package-lock.json
-database.sqlite
-.env
diff --git a/bot/.gitignore b/bot/.gitignore new file mode 100644 index 0000000..37d13a0 --- /dev/null +++ b/bot/.gitignore @@ -0,0 +1,137 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# vitepress build output +**/.vitepress/dist + +# vitepress cache directory +**/.vitepress/cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + diff --git a/bot/bun.lockb b/bot/bun.lockb Binary files differnew file mode 100644 index 0000000..c0c384f --- /dev/null +++ b/bot/bun.lockb diff --git a/bot/deploy-command.js b/bot/deploy-command.js new file mode 100644 index 0000000..aed5890 --- /dev/null +++ b/bot/deploy-command.js @@ -0,0 +1,31 @@ +import fs from 'node:fs'; +import { REST, Routes } from 'discord.js'; +import 'dotenv/config' + +const commands = []; +const commandFiles = fs.readdirSync('./src/commands').filter(file => file.endsWith('.js')); + +for (const file of commandFiles) { + const { default: command } = await import(`./src/commands/${file}`); + commands.push(command.data.toJSON()); +} + +const rest = new REST().setToken(process.env.abbtoken); + +// and deploy your commands! +(async() => { + try { + console.log(`Started refreshing ${commands.length} application (/) commands.`); + + // The put method is used to fully refresh all commands in the guild with the current set + const data = await rest.put( + Routes.applicationCommands(process.env.clientID), + { body: commands } + ); + + console.log(`Successfully reloaded ${data.length} application (/) commands.`); + } catch (error) { + // And of course, make sure you catch and log any errors! + console.error(error); + } +})(); diff --git a/bot/eslint.config.js b/bot/eslint.config.js new file mode 100644 index 0000000..e67ce26 --- /dev/null +++ b/bot/eslint.config.js @@ -0,0 +1,15 @@ +import globals from "globals"; +import pluginJs from "@eslint/js"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + { + languageOptions: { + ecmaVersion: "latest", + sourceType: "module", + globals: globals.node + } + }, + pluginJs.configs.recommended, +]; diff --git a/bot/package.json b/bot/package.json new file mode 100644 index 0000000..c09e16b --- /dev/null +++ b/bot/package.json @@ -0,0 +1,21 @@ +{ + "name": "aleebot", + "version": "4.0.0", + "main": "src/bot.js", + "type": "module", + "author": "Andrew Lee", + "license": "GPL-3.0", + "scripts": { + "start": "node src/bot.js --beta", + "lint": "eslint ." + }, + "dependencies": { + "discord.js": "^14.18.0" + }, + "devDependencies": { + "@eslint/js": "^9.21.0", + "dotenv": "^16.4.7", + "eslint": "^9.21.0", + "globals": "^16.0.0" + } +} diff --git a/bot/src/bot.js b/bot/src/bot.js new file mode 100644 index 0000000..af2aec2 --- /dev/null +++ b/bot/src/bot.js @@ -0,0 +1,21 @@ +import { Client, GatewayIntentBits } from 'discord.js' +import 'dotenv/config' +import { event } from './handler/event.js' +import { commands } from "./handler/commands.js"; + +const client = new Client({ intents: [GatewayIntentBits.Guilds] }); + +commands(client); +event(client); + +if (process.argv.indexOf('--beta') === -1) { + client.login(process.env.abtoken).catch(function() { + console.log('[X] Login failed. The token that you have put in is invalid.'); + process.exit(0); + }); +} else { + client.login(process.env.abbtoken).catch(function() { + console.log('[X] Login failed. The token that you have put in is invalid.'); + process.exit(0); + }); +} diff --git a/bot/src/commands/about.js b/bot/src/commands/about.js new file mode 100644 index 0000000..9983857 --- /dev/null +++ b/bot/src/commands/about.js @@ -0,0 +1,45 @@ +import { + ActionRowBuilder, + ButtonBuilder, + EmbedBuilder, + SlashCommandBuilder, + ButtonStyle +} from 'discord.js'; +import { readFileSync } from "node:fs"; + +const { version } = JSON.parse(readFileSync('./package.json', 'utf-8')); + +export default { + data: new SlashCommandBuilder() + .setName('about') + .setDescription('Information about this bot'), + async execute(interaction) { + const aboutEmbed = new EmbedBuilder() + .setAuthor({ name: `AleeBot ${version}`, iconURL: interaction.client.user.avatarURL() }) + .addFields( + { name: 'About AleeBot', value: 'AleeBot is an all-in-one bot that\'s made from the Discord.JS API!' }, + { name: 'License', value: 'GNU General Public License v3.0' } + //{ name: 'Contributors', value: '' } + ) + .setFooter({ text: '© Copyright 2017-2025 Andrew Lee Projects' }) + .setColor('#1fd619'); + + let Buttons = new ActionRowBuilder() + .addComponents( + new ButtonBuilder() + .setStyle(ButtonStyle.Link) + .setLabel('Source Code') + .setURL('https://github.com/alee14-projects/AleeBot'), + new ButtonBuilder() + .setStyle(ButtonStyle.Link) + .setLabel('Invite AleeBot') + .setURL('https://discord.com/oauth2/authorize?client_id=282547024547545109&permissions=68185158&scope=bot'), + new ButtonBuilder() + .setStyle(ButtonStyle.Link) + .setLabel('Join Andrew Lee Projects') + .setURL('https://discord.gg/EFhRDqG') + ); + + return await interaction.reply({embeds: [aboutEmbed], components: [Buttons]}); + } +}; diff --git a/bot/src/commands/ping.js b/bot/src/commands/ping.js new file mode 100644 index 0000000..996c705 --- /dev/null +++ b/bot/src/commands/ping.js @@ -0,0 +1,9 @@ +import { SlashCommandBuilder } from 'discord.js'; +export default { + data: new SlashCommandBuilder() + .setName('ping') + .setDescription('Pong!'), + async execute(interaction) { + return await interaction.reply(`**PONG!** :ping_pong: ${Math.round(interaction.client.ws.ping)} ms`); + } +}; diff --git a/bot/src/events/ClientReady.js b/bot/src/events/ClientReady.js new file mode 100644 index 0000000..06b5cce --- /dev/null +++ b/bot/src/events/ClientReady.js @@ -0,0 +1,36 @@ +import { Events } from "discord.js"; +import { readFileSync } from 'node:fs'; + +import { activities as activity } from '../storage/activities.js'; + +function botActivity(client) { + client.user.setPresence({ + activities: [{ + name: activity[Math.floor(Math.random() * activity.length)] + }], + status: 'online', + afk: false, + }); + console.log(`[>] Updated bot presence to "${client.user.presence.activities[0].name}"`); +} + +const { version } = JSON.parse(readFileSync('./package.json', 'utf-8')); + +export default { + name: Events.ClientReady, + once: true, + execute(client) { + console.log('[>] AleeBot is now ready!'); + console.log(`[i] Logged in as ${client.user.tag}`); + console.log(`[i] Bot ID: ${client.user.id}`); + console.log(`[i] Running version ${version} | Serving in ${client.guilds.cache.size} guilds`); + + botActivity(client); + + setInterval(function() { + botActivity(); + }, 200000); + + + } +} diff --git a/bot/src/events/InteractionCreate.js b/bot/src/events/InteractionCreate.js new file mode 100644 index 0000000..b1e7593 --- /dev/null +++ b/bot/src/events/InteractionCreate.js @@ -0,0 +1,19 @@ +import { Events, MessageFlags } from "discord.js"; + +export default { + name: Events.InteractionCreate, + async execute(interaction, client) { + if (!interaction.isChatInputCommand()) return; + + const command = interaction.client.commands.get(interaction.commandName); + + if (!command) return; + + try { + await command.execute(interaction, client); + } catch (e) { + console.error(e); + await interaction.reply({ content: 'Something went wrong.', flags: MessageFlags.Ephemeral }); + } + } +} diff --git a/bot/src/handler/commands.js b/bot/src/handler/commands.js new file mode 100644 index 0000000..d4b7bdc --- /dev/null +++ b/bot/src/handler/commands.js @@ -0,0 +1,20 @@ +import { Collection } from 'discord.js' +import { readdirSync } from 'node:fs'; +import path from "node:path"; +import { fileURLToPath } from "url"; +import { dirname } from "path"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const commandPath = path.join(__dirname, '../commands'); + +export async function commands(client) { + client.commands = new Collection(); + const commandFiles = readdirSync(commandPath).filter(file => file.endsWith('.js')); + + for (const file of commandFiles) { + const { default: command } = await import(`../commands/${file}`); + client.commands.set(command.data.name, command); + } +} diff --git a/bot/src/handler/event.js b/bot/src/handler/event.js new file mode 100644 index 0000000..0783741 --- /dev/null +++ b/bot/src/handler/event.js @@ -0,0 +1,23 @@ +import { fileURLToPath } from "url"; +import { dirname } from "path"; +import path from "node:path"; +import fs from "node:fs"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const eventsPath = path.join(__dirname, '../events'); +const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js')); + +export async function event(client) { + for (const file of eventFiles) { + const filePath = path.join(eventsPath, file); + const event = (await import(filePath)).default; + if (event.once) { + client.once(event.name, (...args) => event.execute(...args)); + } else { + client.on(event.name, (...args) => event.execute(...args)); + } + } + +} diff --git a/bot/src/storage/activities.js b/bot/src/storage/activities.js new file mode 100644 index 0000000..f4bd4ff --- /dev/null +++ b/bot/src/storage/activities.js @@ -0,0 +1,101 @@ +import { version as discordVersion } from "discord.js"; +import { readFileSync } from "node:fs"; +const { version: abVersion } = JSON.parse(readFileSync('./package.json', 'utf-8')); + + +const activities = [ + `AleeBot ${abVersion}`, + 'Coding bytes', + 'Drawing shapes', + 'Fighting Quad', + 'Installing Windows 11', + 'Breaking Windows 10', + 'Beating up big tech', + 'Deleting Google', + 'Deleting Apple', + 'Deleting System32', + 'Deleting /usr/bin/', + 'Watering down the Apple walled garden', + 'Reticulating splines', + 'Generating world', + 'Never punch a tree...', + 'Collecting data', + 'Dag dag!', + 'Developed by Andrew Lee', + 'When will 2.13 release?', + 'Alert Irruption !!!', + 'when', + 'Frying Shrimpbot', + 'RADIATION BABY', + 'Frivolously Spending', + 'Thanks! @Victor', + 'MCA DiscoVision', + 'Werq', + 'Pombo', + 'Ian Clary\'s First Day At FrivoloCo!', + 'Squid Airlines', + 'AirCS Race', + 'FrivoloCo', + 'I WANT 2 ORDER', + 'I REALLY WANT 2 ORDER', + 'Monica Is Going To Cosume You', + 'BLÅHAJ', + 'ShiftOS', + 'Histacom', + 'Wall Street', + 'Mac OS X Jaguar', + 'Abunchoo 12.10', + 'MikeOS', + 'theBeat', + 'FRESHMusicPlayer', + 'theShell', + 'theBeat', + 'theSlate', + 'theDesk', + 'Ultra Jump Mania!', + 'Battle Blaze', + 'Tempest', + 'Turbo Crash 9', + 'Pocket Gakusei', + 'Hidden Heroes', + 'Skybreakers', + 'Always Running', + 'Only Up', + 'Trade', + 'Breeze', + 'Steady', + 'Bluejay', + 'Exposing TAS-Corp', + 'Fighting Evelyn Claythorne', + 'Frying Dr. Sheridan', + 'Hacking SherCorp', + 'Games with Tari', + 'Decommissioning Meta Runners', + 'Installing Meta Runners', + '90% bug free!', + 'Google Wallet', + 'Apple Pay', + 'Splatoon 3', + 'Super Mario 64', + 'Minceraft', + 'Mario Kart 8', + 'bnbmc', + 'Evaluating JavaScript code', + 'Evaluating C# code', + 'Forkbombing FMP', + 'Merging with DLAP', + 'Now asbestos-free!', + 'May contain nuts!', + 'MythOS', + 'Also try Scratch!', + 'Funky!', + 'Apple Vision Pro', + 'What is Web3?', + 'GNU\'s NOT UNIX!', + 'Linux, but actually GNU/Linux', + 'Debloating my ThinkPad', + 'Turbotastic!', + `Now running on Discord.JS ${discordVersion}!` +]; + +export { activities }; |
