Skip to content

Commit

Permalink
Check whether user already has insider roles when giving insiderChat
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Jan 2, 2025
1 parent 4d34994 commit 0c9ef0a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Events/InteractionEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,37 @@ await LogChannelHelper.LogDeletedMessagesAsync(
// Get member
var member = await e.Guild.GetMemberAsync(e.User.Id);

// Get insider chat role
var insiderChatRole = await e.Guild.GetRoleAsync(cfgjson.UserRoles.InsiderChat);

// Check whether member already has any insider roles
var insiderRoles = new List<ulong>()
{
cfgjson.UserRoles.InsiderCanary,
cfgjson.UserRoles.InsiderDev,
cfgjson.UserRoles.InsiderBeta,
cfgjson.UserRoles.InsiderRP,
cfgjson.UserRoles.Insider10RP,
cfgjson.UserRoles.PatchTuesday
};
if (member.Roles.Any(x => insiderRoles.Contains(x.Id)))
{
// Member already has an insider role, thus already has access to #insiders
// No need for the chat role too

string insidersMention;
if (cfgjson.InsidersChannel == 0)
insidersMention = "#insiders";
else
insidersMention = $"<#{cfgjson.InsidersChannel}>";

await e.Interaction.CreateFollowupMessageAsync(new DiscordFollowupMessageBuilder()
.WithContent($"You already have Insider roles, so you already have access to chat in {insidersMention}!")
.AsEphemeral(true));

return;
}

if (member.Roles.Contains(insiderChatRole))
{
// Member already has the role
Expand Down

0 comments on commit 0c9ef0a

Please sign in to comment.