Guest User

Untitled

a guest
Jul 28th, 2022
546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. const Discord = require("discord.js")
  2. require("dotenv").config()
  3.  
  4. const generateImage = require("./generateImage")
  5.  
  6. const TOKEN = "mytoken :)"
  7.  
  8. const client = new Discord.Client({
  9. intents: [
  10. "Guilds",
  11. "GuildMessages",
  12. "GuildMembers"
  13. ]
  14. })
  15.  
  16. let bot = {
  17. client
  18. }
  19.  
  20. client.on("ready", () => {
  21. console.log(`Logged In As ${client.user.tag}`)
  22. })
  23.  
  24. client.commands = new Discord.Collection()
  25. client.events = new Discord.Collection()
  26.  
  27. module.exports = bot
  28.  
  29. client.slashcmds = new Discord.Collection()
  30.  
  31. client.loadSlashcommands = (bot, reload) => require("./handlers/slashcommands")(bot, reload)
  32. client.loadSlashcommands(bot, false)
  33.  
  34. client.on("interactionCreate", (interaction) => {
  35. if (!interaction.isCommand()) return
  36. if (!interaction.inGuild()) return interaction.reply("This command can only be used in a server!")
  37.  
  38. const slashcmd = client.slashcommands.get(interaction.commandName)
  39.  
  40. if(!slashcmd) return interaction.reply("Invalid Slash Command")
  41.  
  42. if (slashcmd.perms && !interaction.member.permissions.has(slashcmd.perm))
  43. return interaction.reply("You do not have permission for this command!")
  44.  
  45. slashcmd.run(client, interaction)
  46. })
  47.  
  48.  
  49. client.login(process.env.TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment