mirror of
https://github.com/yuzu-emu/Command-fix
synced 2024-11-24 23:48:13 +00:00
Access check to see if the user has privilages to warn after command runs.
This commit is contained in:
parent
6f48e1c379
commit
2509bd2179
1 changed files with 12 additions and 1 deletions
13
server.js
13
server.js
|
@ -17,6 +17,10 @@ function findArray(haystack, arr) {
|
|||
});
|
||||
};
|
||||
|
||||
process.on('unhandledRejection', function onError(err) {
|
||||
throw err;
|
||||
});
|
||||
|
||||
client.on('ready', () => {
|
||||
// Initalize app channels.
|
||||
app.logChannel = client.channels.get(config.logChannel);
|
||||
|
@ -66,12 +70,19 @@ client.on('message', message => {
|
|||
}
|
||||
} catch (err) { logger.error(err); }
|
||||
|
||||
// Warn after running command?
|
||||
try {
|
||||
// Check if the command requires a warning.
|
||||
if (cmd != 'warn' && cachedModule.warn == true) {
|
||||
cachedModules['warn.js'].command(message);
|
||||
// Access check to see if the user has privilages to warn.
|
||||
let warnCommand = cachedModules['warn.js'];
|
||||
if (findArray(message.member.roles.map(function(x) { return x.name; }), warnCommand.roles)) {
|
||||
// They are allowed to warn because they are in warn's roles.
|
||||
warnCommand.command(message);
|
||||
}
|
||||
}
|
||||
} catch (err) { logger.error(err); }
|
||||
|
||||
} else {
|
||||
// Not a valid command.
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue