mirror of
https://github.com/yuzu-emu/Command-fix.git
synced 2024-11-22 15:35:45 +01:00
Access check to see if the user has privilages to warn after command runs.
This commit is contained in:
parent
6f48e1c379
commit
2509bd2179
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', () => {
|
client.on('ready', () => {
|
||||||
// Initalize app channels.
|
// Initalize app channels.
|
||||||
app.logChannel = client.channels.get(config.logChannel);
|
app.logChannel = client.channels.get(config.logChannel);
|
||||||
@ -66,12 +70,19 @@ client.on('message', message => {
|
|||||||
}
|
}
|
||||||
} catch (err) { logger.error(err); }
|
} catch (err) { logger.error(err); }
|
||||||
|
|
||||||
|
// Warn after running command?
|
||||||
try {
|
try {
|
||||||
// Check if the command requires a warning.
|
// Check if the command requires a warning.
|
||||||
if (cmd != 'warn' && cachedModule.warn == true) {
|
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); }
|
} catch (err) { logger.error(err); }
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Not a valid command.
|
// Not a valid command.
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user