问题
I use commando for my discord.js bot, and it's linked to the client. I want to be able to use the bot variable in a different file, mainly to help check if the bot has the correct permissions.
My Bot variable:
const bot = new commando.Client({
commandPrefix: '!',
owner: config.ownerID,
unknownCommandResponse: false
});
This is currently in my index.js file, but is there a way for me to be able to use it in a different command file?
回答1:
You could do
index.js
const bot = new commando.Client({
commandPrefix: '!',
owner: config.ownerID,
unknownCommandResponse: false
});
this.bot = bot
This would then be accessed in another file like:
this.bot.(property)
All the properties of bot will be accessible as long as you use the above mentioned method.
来源:https://stackoverflow.com/questions/50515465/getting-bot-variable-into-different-commando-files