From e8a29a2461751a6978c771fc52c16a4e53e5a849 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Mon, 25 Apr 2022 12:02:01 -0700 Subject: [PATCH] Fix setSuggestionChannel panicking when key not in guilds.json --- src/commands/owner.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/commands/owner.rs b/src/commands/owner.rs index 2565237..8a68e27 100644 --- a/src/commands/owner.rs +++ b/src/commands/owner.rs @@ -63,7 +63,11 @@ async fn setSubmissionChannel(ctx: &Context, msg: &Message) -> CommandResult { async fn setSuggestionChannel(ctx: &Context, msg: &Message) -> CommandResult { let channel = msg.channel_id.as_u64().to_string(); let mut guild_data = get_guild_data(); - guild_data["suggestionChannel"] = channel.into(); + if guild_data.contains_key("submissionChannel") { + guild_data["suggestionChannel"] = channel.into(); + } else { + guild_data.insert(String::from("suggestionChannel"), channel.into()); + } set_guild_data(guild_data); msg.reply( &ctx.http,