Guest User

Untitled

a guest
Feb 27th, 2022
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const fs = require('node:fs');
  2. const { Client, Intents, Collection } = require('discord.js');
  3. const { token } = require('./config.json');
  4. const { clientID, guildID } = require('./config2.json');
  5.  
  6. const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
  7.  
  8. client.commands = new Collection();
  9. const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
  10.  
  11. for (const file of commandFiles) {
  12.     const command = require(`./commands/${file}`);
  13.  
  14.     client.commands.set(command.data.name, command);
  15. }
  16.  
  17. client.once('ready', () => {
  18.     console.log("Discord bot is enabled!');
  19.  
  20.    const guild = client.guilds.cache.get(guildID);
  21.  
  22.    let commands = guild ? guild.commands : client.application?.commands;
  23.  
  24.    console.log(guild.memberCount);
  25.    console.log(guild.members);
  26.  
  27.    addPermissions();
  28.  
  29.    // console.log(client.commands.get("debug"));
  30. });
  31.  
  32. client.on('interactionCreate', async interaction => {
  33.    if (!interaction.isCommand()) return;
  34.  
  35.    const command = client.commands.get(interaction.commandName);
  36.  
  37.    if (!command) return;
  38.  
  39.    try {
  40.        await command.execute(interaction);
  41.    }
  42.    catch (error) {
  43.        console.log(error);
  44.        await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
  45.    }
  46. });
  47.  
  48. client.login(token);
  49.  
  50. function addPermissions() {
  51.    const perms = [
  52.        {
  53.            id: "859099861823389736",
  54.            type: "USER",
  55.            permission: false,
  56.        },
  57.    ];
  58.  
  59.    // client.commands.get("debug").permissions.set({ perms });
  60. }
Advertisement
Add Comment
Please, Sign In to add comment