/// <summary> /// Handles the Reaction Added event. /// </summary> /// <param name="cachedMessage">Message that was reaction is on.</param> /// <param name="originChannel">Channel where the message is located.</param> /// <param name="reaction">Reaction made on the message.</param> /// <returns>Task Complete.</returns> private async Task <Task> HandleReactionAdded(Cacheable <IUserMessage, ulong> cachedMessage, ISocketMessageChannel originChannel, SocketReaction reaction) { IMessage message = await originChannel.GetMessageAsync(cachedMessage.Id); SocketGuildChannel chnl = message.Channel as SocketGuildChannel; ulong guild = chnl.Guild.Id; IUser user = reaction.User.Value; if (message != null && reaction.User.IsSpecified && !user.IsBot) { if (RaidCommandParent.IsRaidMessage(message.Id)) { await RaidCommandParent.RaidMessageReactionHandle(message, reaction); } else if (RaidCommandParent.IsRaidSubMessage(message.Id)) { await RaidCommandParent.RaidSubMessageReactionHandle(message, reaction); } else if (RaidCommandParent.IsRaidGuideMessage(message.Id)) { await RaidCommandParent.RaidGuideMessageReactionHandle(message, reaction); } else if (DexCommandParent.IsDexSelectMessage(message.Id)) { await DexCommandParent.DexSelectMessageReactionHandle(message, reaction, guild); } else if (DexCommandParent.IsDexMessage(message.Id)) { await DexCommandParent.DexMessageReactionHandle(message, reaction, guild); } else if (DexCommandParent.IsCatchMessage(message.Id)) { await DexCommandParent.CatchMessageReactionHandle(message, reaction); } else if (POICommands.IsPOISubMessage(message.Id)) { await POICommands.POIMessageReactionHandle(message, reaction, guild); } else if (HelpCommands.IsHelpMessage(message.Id)) { await HelpCommands.HelpMessageReactionHandle(message, reaction, guild); } else if (Connections.IsNotifyMessage(message.Id)) { await Connections.NotifyMessageReactionHandle(message, reaction, chnl.Guild); } } return(Task.CompletedTask); }
/// <summary> /// Checks message is a reply to a raid message. /// </summary> /// <param name="context">Context that the command was sent with.</param> /// <param name="command">Command that was sent.</param> /// <param name="services">Service collection used for dependency injection</param> /// <returns>Precondition result.</returns> public override async Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services) { if (context.Message.Reference != null && RaidCommandParent.IsRaidMessage(context.Message.Reference.MessageId.Value)) { return(await Task.FromResult(PreconditionResult.FromSuccess())); } else { string message = $"{command.Name} command must be a reply to a raid message."; await ResponseMessage.SendErrorMessage(context.Channel, command.Name, message); return(await Task.FromResult(PreconditionResult.FromError(""))); } }