public async Task StopMonitoringMessageAsync([Summary("Optional message ID to stop monitoring")] int id = 0) { if (MonitorList.GetMonitoredMessage() == null) { await ReplyAsync("There is no message currently being monitored."); return; } string emoji = ReactionUtilities.emojiToCheck; var msg = await Context.Channel.GetMessageAsync(MonitorList.GetMonitoredMessage().Id) as RestUserMessage; //If the monitored message got deleted before !unmonitor was used, clear the message and reset. if (msg == null) { MonitorList.DeleteMonitoredMessage(); //Grab the member list from the server and unassign the role from anyone who has it. return; } var users = await msg.GetReactionUsersAsync(emoji); if (!users.Any()) { return; } foreach (RestUser user in users) { await ReactionUtilities.RemoveRoleFromUserAsync(user, Context.Guild); } MonitorList.DeleteMonitoredMessage(); await ReplyAsync("Message is no longer monitored and all reacted users have had their role unassigned."); }
private async Task ReactionRemoved(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction) { RestUserMessage msg = MonitorList.GetMonitoredMessage(); if (msg != null) { try { await ReactionUtilities.RemoveRoleFromUserAsync(channel, reaction); } catch (Exception e) { Console.WriteLine(e.Message); } } }
private async Task ReactionAdded(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction) { RestUserMessage msg = MonitorList.GetMonitoredMessage(); if (msg != null) { try { await ReactionUtilities.AddRoleToUserAsync(channel, reaction); } catch (Exception e) { Console.WriteLine(e.Message); await channel.SendMessageAsync("Something bad happened. Consult this bot's administrator."); } } }