diff options
Diffstat (limited to 'bot/src')
| -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 |
8 files changed, 274 insertions, 0 deletions
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 }; |
