mirror of
https://github.com/jcreek/denBot.git
synced 2026-07-13 19:03:45 +00:00
fix(*): Add log and try catch loop to prevent getting a user from a mention throwing uncleanly
This commit is contained in:
@@ -400,17 +400,17 @@ client.on('message', function (message) {
|
|||||||
|
|
||||||
// Remove a tagged user from the queue
|
// Remove a tagged user from the queue
|
||||||
if (command === 'ru' && args[0]) {
|
if (command === 'ru' && args[0]) {
|
||||||
const user = getUserFromMention(args[0]);
|
|
||||||
|
|
||||||
// Delete the message with the bot command
|
// Delete the message with the bot command
|
||||||
if (config.deletecommandstoggle) {
|
if (config.deletecommandstoggle) {
|
||||||
message.delete();
|
message.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`${message.author.username} used command ru in ${message.channel.name}`);
|
logger.info(`${message.author.username} used command ru ${user} in ${message.channel.name}`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const user = getUserFromMention(args[0]);
|
||||||
|
|
||||||
if ((playerQueue.includes(user))) {
|
if ((playerQueue.includes(user))) {
|
||||||
|
|
||||||
// Search for the user
|
// Search for the user
|
||||||
for(var i = 0; i < playerQueue.length; i++){
|
for(var i = 0; i < playerQueue.length; i++){
|
||||||
if ((playerQueue[i].username === user.username)){
|
if ((playerQueue[i].username === user.username)){
|
||||||
@@ -435,6 +435,10 @@ client.on('message', function (message) {
|
|||||||
message.channel.send(`${user.username} is not in the queue.`);
|
message.channel.send(`${user.username} is not in the queue.`);
|
||||||
logger.info( `${message.author.username} attempted to remove ${user.username} from queue but they weren't in it.`);
|
logger.info( `${message.author.username} attempted to remove ${user.username} from queue but they weren't in it.`);
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(`Tried to remove user ${args[0]} from queue but got an error: ${error}`);
|
||||||
|
message.channel.send(`Failed to remove ${args[0]} from the queue.`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command === 'dc') {
|
if (command === 'dc') {
|
||||||
|
|||||||
Reference in New Issue
Block a user