Skip to content

Commit 0c9ef0a

Browse files
Check whether user already has insider roles when giving insiderChat
1 parent 4d34994 commit 0c9ef0a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Events/InteractionEvents.cs

+30
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,37 @@ await LogChannelHelper.LogDeletedMessagesAsync(
297297
// Get member
298298
var member = await e.Guild.GetMemberAsync(e.User.Id);
299299

300+
// Get insider chat role
300301
var insiderChatRole = await e.Guild.GetRoleAsync(cfgjson.UserRoles.InsiderChat);
302+
303+
// Check whether member already has any insider roles
304+
var insiderRoles = new List<ulong>()
305+
{
306+
cfgjson.UserRoles.InsiderCanary,
307+
cfgjson.UserRoles.InsiderDev,
308+
cfgjson.UserRoles.InsiderBeta,
309+
cfgjson.UserRoles.InsiderRP,
310+
cfgjson.UserRoles.Insider10RP,
311+
cfgjson.UserRoles.PatchTuesday
312+
};
313+
if (member.Roles.Any(x => insiderRoles.Contains(x.Id)))
314+
{
315+
// Member already has an insider role, thus already has access to #insiders
316+
// No need for the chat role too
317+
318+
string insidersMention;
319+
if (cfgjson.InsidersChannel == 0)
320+
insidersMention = "#insiders";
321+
else
322+
insidersMention = $"<#{cfgjson.InsidersChannel}>";
323+
324+
await e.Interaction.CreateFollowupMessageAsync(new DiscordFollowupMessageBuilder()
325+
.WithContent($"You already have Insider roles, so you already have access to chat in {insidersMention}!")
326+
.AsEphemeral(true));
327+
328+
return;
329+
}
330+
301331
if (member.Roles.Contains(insiderChatRole))
302332
{
303333
// Member already has the role

0 commit comments

Comments
 (0)