From d4ff58d4090331c9aab78bd9ca652e298e78a653 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Tue, 10 May 2022 18:27:51 +0100 Subject: [PATCH] Update lobby command to give proper errors if role or channel id cannot be found --- src/commands/501231711271780357/lobby.ts | 31 +++++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/commands/501231711271780357/lobby.ts b/src/commands/501231711271780357/lobby.ts index 58793bf..4d0bcfc 100644 --- a/src/commands/501231711271780357/lobby.ts +++ b/src/commands/501231711271780357/lobby.ts @@ -111,8 +111,17 @@ export default class Lobby extends Command { const cooldown = Number(context.args[4]) || 30; const gameName = context.args.splice(5).join(" "); - if (!channel || !role) { - this.SendConfigHelp(context); + if (!channel) { + const errorEmbed = new ErrorEmbed(context, "The channel id you provided is invalid or channel does not exist."); + errorEmbed.SendToCurrentChannel(); + + return; + } + + if (!role) { + const errorEmbed = new ErrorEmbed(context, "The role id you provided is invalid or role does not exist."); + errorEmbed.SendToCurrentChannel(); + return; } @@ -133,20 +142,18 @@ export default class Lobby extends Command { } private async RemoveLobbyConfig(context: ICommandContext) { - const channel = context.message.guild!.channels.cache.find(x => x.id == context.args[2]); + const entity = await eLobby.FetchOneByChannelId(context.args[2]); + + if (!entity) { + const errorEmbed = new ErrorEmbed(context, "The channel id you provided has not been setup as a lobby, unable to remove."); + errorEmbed.SendToCurrentChannel(); - if (!channel) { - this.SendConfigHelp(context); return; } + + await BaseEntity.Remove(eLobby, entity); - const entity = await eLobby.FetchOneByChannelId(channel.id); - - if (entity) { - await BaseEntity.Remove(eLobby, entity); - } - - const embed = new PublicEmbed(context, "", `Removed \`${channel.name}\` from the list of lobby channels`); + const embed = new PublicEmbed(context, "", `Removed <#${context.args[2]}> from the list of lobby channels`); embed.SendToCurrentChannel(); } } \ No newline at end of file -- 2.45.2