Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { Client, GatewayIntentBits, PermissionsBitField, EmbedBuilder, Collection, ActivityType } = require('discord.js');
- const { token } = require('./config.json');
- const fs = require('fs');
- const { setInterval } = require('timers/promises');
- const prefix = '>';
- const client = new Client({
- intents: [
- GatewayIntentBits.Guilds,
- GatewayIntentBits.GuildMessages,
- GatewayIntentBits.MessageContent,
- ],
- });
- client.commands = new Collection();
- // Get the Commands folder for access to individual commands
- const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
- for (const file of commandFiles) {
- const command = require(`./commands/${file}`);
- client.commands.set(command.name, command);
- }
- //Bot connecting to service and Status
- client.on('ready', () => {
- console.log('Bot is online!');
- const activities = [
- 'Make sure to vote for your servers! :white_check_mark:',
- 'Taking a cat nap :zzz:',
- 'Getting zombified! :zombie:',
- 'Eating your brains!',
- '#support for support'
- ];
- setInterval(() => {
- const status = activities[Math.floor(Math.random() * activities.length)];
- client.user.setPresence({
- activities: [{
- name: `${status}`,
- type: ActivityType.Custom
- }]
- });
- console.log(status); // Log the current status
- }, 5000);
- });
- // Logic for the Commands
- client.on('messageCreate', (message) => {
- if (!message.content.startsWith(prefix) || message.author.bot) return;
- const args = message.content.slice(prefix.length).split(/ +/);
- const commandName = args.shift().toLowerCase();
- const command = client.commands.get(commandName);
- if (!command) return;
- try {
- command.execute(message, args);
- } catch (error) {
- console.error(error);
- message.channel.send('There was an error while executing this command.');
- }
- });
- // Login bot with token from config.json
- client.login(token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement