mirror of
https://github.com/SEPPDROID/zoizbot.git
synced 2025-10-22 07:54:28 +00:00
Reload command example. - Update reload.js and zoizbot.njsproj
This commit is contained in:
20
zoizbot/commands/reload.js
Normal file
20
zoizbot/commands/reload.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* a command that reloads the command you have edited to memory
|
||||||
|
* so you dont have to reboot the bot
|
||||||
|
* good for testing, not so much for production
|
||||||
|
* ive added the permission test, to make sure not everybody spams reload
|
||||||
|
*/
|
||||||
|
exports.run = (zoizbot, message, args) => {
|
||||||
|
if (!message.member.hasPermission("ADMINISTRATOR"))
|
||||||
|
return message.reply("Sorry, you don't have permissions to use this!");
|
||||||
|
if (!args || args.length < 1) return message.reply("Please provide the command name to reload.");
|
||||||
|
const commandName = args[0];
|
||||||
|
if (!zoizbot.commands.has(commandName)) {
|
||||||
|
return message.reply("That command does not exist");
|
||||||
|
}
|
||||||
|
delete require.cache[require.resolve(`./${commandName}.js`)];
|
||||||
|
zoizbot.commands.delete(commandName);
|
||||||
|
const props = require(`./${commandName}.js`);
|
||||||
|
zoizbot.commands.set(commandName, props);
|
||||||
|
message.reply(`The command ${commandName} has been reloaded`);
|
||||||
|
};
|
@@ -48,6 +48,9 @@
|
|||||||
<Content Include="commands\ping.js">
|
<Content Include="commands\ping.js">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="commands\reload.js">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Content>
|
||||||
<Content Include="Legacy Commands\examples.js" />
|
<Content Include="Legacy Commands\examples.js" />
|
||||||
<Content Include="package.json" />
|
<Content Include="package.json" />
|
||||||
<Content Include="README.md" />
|
<Content Include="README.md" />
|
||||||
|
Reference in New Issue
Block a user