Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fs = require('node:fs');
- const { Client, Intents, Collection } = require('discord.js');
- const { token } = require('./config.json');
- const { clientID, guildID } = require('./config2.json');
- const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
- client.commands = new Collection();
- const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
- for (const file of commandFiles) {
- const command = require(`./commands/${file}`);
- client.commands.set(command.data.name, command);
- }
- client.once('ready', () => {
- console.log("Discord bot is enabled!');
- const guild = client.guilds.cache.get(guildID);
- let commands = guild ? guild.commands : client.application?.commands;
- console.log(guild.memberCount);
- console.log(guild.members);
- addPermissions();
- // console.log(client.commands.get("debug"));
- });
- client.on('interactionCreate', async interaction => {
- if (!interaction.isCommand()) return;
- const command = client.commands.get(interaction.commandName);
- if (!command) return;
- try {
- await command.execute(interaction);
- }
- catch (error) {
- console.log(error);
- await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
- }
- });
- client.login(token);
- function addPermissions() {
- const perms = [
- {
- id: "859099861823389736",
- type: "USER",
- permission: false,
- },
- ];
- // client.commands.get("debug").permissions.set({ perms });
- }
Advertisement
Add Comment
Please, Sign In to add comment