Skip to content

Commit

Permalink
O4 can react to messages in #welcome now
Browse files Browse the repository at this point in the history
  • Loading branch information
chamik committed Feb 11, 2024
1 parent fce63fd commit 67ef9cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion thorn/Config/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
},
"roles": {
"classC": 537322727225163776,
"INT": 537023765163409439
"INT": 537023765163409439,
"O5": 536984757410463764,
"O4": 938104159993995265
},
"help": [
"OBECNÉ\n**`.help [1 - 3]`** - Hádej :)\n\n**`.help [pasní/překlad/korekce/členství]`** - Hádej :)\n\n**`.info`** - Info o botovi\n\n**`.ping`** - Pong!",
Expand Down
9 changes: 8 additions & 1 deletion thorn/Services/ReactionHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Discord;
Expand All @@ -18,6 +19,8 @@ public class ReactionHandler : DiscordClientService
private readonly ulong _loggingChannelId;
private readonly ulong _classCRoleId;
private readonly ulong _intRoleId;
private readonly ulong _o5RoleId;
private readonly ulong _o4RoleId;

public ReactionHandler(DiscordSocketClient client, ConstantsService constants, ILogger<ReactionHandler> logger) : base(client, logger)
{
Expand All @@ -28,6 +31,8 @@ public ReactionHandler(DiscordSocketClient client, ConstantsService constants, I
_loggingChannelId = _constants.Channels["o5"];
_classCRoleId = _constants.Roles["classC"];
_intRoleId = _constants.Roles["INT"];
_o5RoleId = _constants.Roles["O5"];
_o4RoleId = _constants.Roles["O4"];
}

protected override Task ExecuteAsync(CancellationToken cancellationToken)
Expand All @@ -47,7 +52,9 @@ private async Task ClientOnReactionAdded(Cacheable<IUserMessage, ulong> messageC

private async Task HandleWelcomeReactions(Cacheable<IUserMessage, ulong> cacheable, SocketReaction reaction)
{
if (!((IGuildUser)reaction.User.Value).GuildPermissions.Administrator) return;
var guildUser = (IGuildUser)reaction.User.Value;
if (!guildUser.RoleIds.ToList().Contains(_o5RoleId) && !guildUser.RoleIds.ToList().Contains(_o4RoleId))
return;

var emote = reaction.Emote;
var user = (IGuildUser)cacheable.Value.Author;
Expand Down

0 comments on commit 67ef9cf

Please sign in to comment.