Skip to content

Commit

Permalink
give meaningful response for role cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxiao921 committed Sep 1, 2021
1 parent 1e87bee commit 8e9aa22
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions CHEF/Components/Commands/GiveRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,27 @@ public override async Task Handle(SocketSlashCommand interaction)
var guildRole = guild.Roles.FirstOrDefault(x => x.Name == role);
var guildRoleId = guildRole?.Id;

var responseMessage = "Something went wrong.";

if (guildRoleId != null)
{
if (user.RoleIds.Any(id => id == guildRoleId))
{
await user.RemoveRoleAsync(guildRole);
responseMessage = $"{role} role removed.";
}
else
{
await user.AddRoleAsync(guildRole);
responseMessage = $"{role} role added.";
}

await interaction.RespondAsync("ROLE : " + role);
}
else
{
responseMessage = $"the role {role} was not found.";
}

await interaction.RespondAsync(responseMessage, ephemeral: true);
}
}
}

0 comments on commit 8e9aa22

Please sign in to comment.