Fix setSuggestionChannel panicking when key not in guilds.json

This commit is contained in:
Elnu 2022-04-25 12:02:01 -07:00
parent 830ac6cb61
commit e8a29a2461

View file

@ -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,