예제 #1
0
        public async Task RequestPoints()
        {
            DiscordMessageBuilder discordMessage = new DiscordMessageBuilder
            {
                Content = $"For this rule you can reduce the users chances by {Rule.MinPoints} - {Rule.MaxPoints}"
            };

            for (int i = 0; i < 3; i++)
            {
                List <DiscordButtonComponent> buttons = new List <DiscordButtonComponent>();
                for (int index = i * 5; index < (i * 5) + 5; index++)
                {
                    buttons.Add(new DiscordButtonComponent
                                (
                                    ButtonStyle.Primary,
                                    (index + 1).ToString(),
                                    (index + 1).ToString(),
                                    (index + 1) < Rule.MinPoints || (index + 1) > Rule.MaxPoints)
                                );
                }
                discordMessage.AddComponents(buttons);
            }
            DiscordMessage pointsMessage = await WarnChannel.SendMessageAsync(discordMessage);

            var interactpointsMessage = await Interactivity.WaitForButtonAsync(pointsMessage, Mod, TimeSpan.FromMinutes(2));

            PointsDeducted = int.Parse(interactpointsMessage.Result.Id);
            await pointsMessage.DeleteAsync();
        }
예제 #2
0
        public async Task <DiscordInteraction> RequestPointsEphemeral(ContextMenuContext ctx, ulong messageID)
        {
            DiscordWebhookBuilder webhook = new DiscordWebhookBuilder
            {
                Content = $"For this rule you can reduce the users chances by {Rule.MinPoints} - {Rule.MaxPoints}"
            };

            for (int i = 0; i < 3; i++)
            {
                List <DiscordButtonComponent> buttons = new List <DiscordButtonComponent>();
                for (int index = i * 5; index < (i * 5) + 5; index++)
                {
                    buttons.Add(new DiscordButtonComponent
                                (
                                    ButtonStyle.Primary,
                                    (index + 1).ToString(),
                                    (index + 1).ToString(),
                                    (index + 1) < Rule.MinPoints || (index + 1) > Rule.MaxPoints)
                                );
                }
                webhook.AddComponents(buttons);
            }
            DiscordMessage pointsMessage = await ctx.EditFollowupAsync(messageID, webhook);

            var interactpointsMessage = await Interactivity.WaitForButtonAsync(pointsMessage, Mod, TimeSpan.FromMinutes(2));

            PointsDeducted = int.Parse(interactpointsMessage.Result.Id);

            foreach (var item in webhook.Components)
            {
                foreach (DiscordButtonComponent button in item.Components)
                {
                    button.Disable();
                }
            }

            await ctx.EditFollowupAsync(messageID, webhook);

            return(interactpointsMessage.Result.Interaction);
        }