예제 #1
0
        private async Task InitiativeReactionsHandler(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user)
        {
            ChannelSettings channelSettings = await ChannelSettings.GetChannelSettingsAsync(channel.Id);

            if (!InitiativeTracker.IsInitiativeTrackerMessage(message))
            {
                return;
            }

            InitiativeTracker tracker = InitiativeTracker.FromMessage(message).WithChannelSettings(channelSettings);

            if (reaction.Emote.Name == DisadvantageEmoji)
            {
                if (!tracker.Disadvantage.Contains(user.ToString()))
                {
                    await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false);

                    tracker.Disadvantage.Add(user.ToString());
                    tracker.Advantage.RemoveAll(s => s == user.ToString());
                    await message.ModifyAsync(msg => msg.Embed = tracker.GetEmbedBuilder().Build());

                    return;
                }
            }
            if (reaction.Emote.Name == AdvantageEmoji)
            {
                if (!tracker.Advantage.Contains(user.ToString()))
                {
                    await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false);

                    tracker.Advantage.Add(user.ToString());
                    tracker.Disadvantage.RemoveAll(s => s == user.ToString());
                    await message.ModifyAsync(msg => msg.Embed = tracker.GetEmbedBuilder().Build());

                    return;
                }
            }

            return;
        }
        public async Task BuildTrackerCommand([Remainder] string Description = "")
        {
            ChannelSettings channelSettings = await ChannelSettings.GetChannelSettingsAsync(Context.Channel.Id);

            InitiativeTracker tracker = new InitiativeTracker(channelSettings);

            tracker.Description = Description;
            var msg = await ReplyAsync(embed : tracker.GetEmbedBuilder().Build());

            await msg.AddReactionAsync(AdvantageEmoji);

            await msg.AddReactionAsync(DisadvantageEmoji);

            return;
        }