-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
15 lines (14 loc) · 1.17 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const fs = require('fs')
const{Client, Intents, Collection}=require('discord.js')
const{token}=require('./config.json')
const client = new Client({intents:[Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MEMBERS]})
client.once('ready',()=>{console.log('Logged in successfully');client.user.setActivity('/help | build 0.1a',{type:"COMPETING"})})
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.on('interactionCreate',async interaction=>{
if(!interaction.isCommand()) return
const command=client.commands.get(interaction.commandName)
if(!command)return
try{await command.execute(interaction);console.log(`${interaction.user.tag} (ID: ${interaction.user.id}) ran the ${interaction.commandName} command`)}catch(error){console.error(error);await interaction.reply({content:'Whoops! Something went wrong when executing that... Try again. Or maybe [report a bug](https://github.com/joebobbio/phene-bot/issues/new/choose)?', ephemeral:true})}})
client.login(token)