コード例 #1
0
        private async Task SetupMemberUpdateMessagesAsync(GuildConfig gcfg, CommandContext ctx, DiscordChannel channel)
        {
            await GetChannelIdAndMessageAsync(welcome : true);
            await GetChannelIdAndMessageAsync(welcome : false);


            async Task GetChannelIdAndMessageAsync(bool welcome)
            {
                InteractivityExtension interactivity = ctx.Client.GetInteractivity();

                if (await ctx.WaitForBoolReplyAsync(welcome ? "q-setup-memupd-wm" : "q-setup-memupd-lm", channel: channel, reply: false))
                {
                    await channel.LocalizedEmbedAsync(this.Localization, "q-setup-memupd-chn");

                    DiscordChannel?chn = await interactivity.WaitForChannelMentionAsync(channel, ctx.User);

                    if (chn is { } && chn.Type == ChannelType.Text)
                    {
                        if (welcome)
                        {
                            gcfg.WelcomeChannelId = chn?.Id ?? default;
                        }
                        else
                        {
                            gcfg.LeaveChannelId = chn?.Id ?? default;
                        }
                    }

                    if (await ctx.WaitForBoolReplyAsync("q-setup-memupd-msg", channel: channel, reply: false))
                    {
                        await channel.LocalizedEmbedAsync(this.Localization, "q-setup-memupd-msg-new");

                        InteractivityResult <DiscordMessage> mctx = await channel.GetNextMessageAsync(ctx.User, m => m.Content.Length <= 128);

                        if (mctx.TimedOut)
                        {
                            throw new CommandFailedException(ctx, "str-timeout");
                        }
                        else
                        {
                            if (welcome)
                            {
                                gcfg.WelcomeMessage = mctx.Result.Content;
                            }
                            else
                            {
                                gcfg.LeaveMessage = mctx.Result.Content;
                            }
                        }
                    }
                }
コード例 #2
0
        private async Task SetupLoggingAsync(GuildConfig gcfg, CommandContext ctx, DiscordChannel channel)
        {
            if (await ctx.WaitForBoolReplyAsync("q-setup-log", channel: channel, reply: false))
            {
                await channel.LocalizedEmbedAsync(this.Localization, "q-setup-log-chn");

                DiscordChannel?logchn = await ctx.Client.GetInteractivity().WaitForChannelMentionAsync(channel, ctx.User);

                gcfg.LogChannelId = logchn?.Id ?? default;
            }
        }
コード例 #3
0
        private async Task SetupPrefixAsync(GuildConfig gcfg, CommandContext ctx, DiscordChannel channel)
        {
            if (await ctx.WaitForBoolReplyAsync("q-setup-prefix", channel: channel, reply: false))
            {
                await channel.LocalizedEmbedAsync(this.Localization, "q-setup-prefix-new", GuildConfig.PrefixLimit);

                InteractivityResult <DiscordMessage> mctx = await channel.GetNextMessageAsync(ctx.User, m => m.Content.Length <= GuildConfig.PrefixLimit);

                gcfg.Prefix = mctx.TimedOut ? throw new CommandFailedException(ctx, "str-timeout") : mctx.Result.Content;
            }
        }
コード例 #4
0
        private async Task SetupBackupAsync(GuildConfig gcfg, CommandContext ctx, DiscordChannel channel)
        {
            if (await ctx.WaitForBoolReplyAsync("q-setup-bak", channel: channel, reply: false))
            {
                gcfg.BackupEnabled = true;
                if (await ctx.WaitForBoolReplyAsync("q-setup-bak-ex", channel: channel, reply: false))
                {
                    await channel.LocalizedEmbedAsync(this.Localization, "q-setup-bak-ex-list");

                    InteractivityResult <DiscordMessage> res = await ctx.Client.GetInteractivity().WaitForMessageAsync(
                        msg => msg.Author == ctx.User && msg.Channel == channel && msg.MentionedChannels.Any()
                        );

                    if (!res.TimedOut)
                    {
                        BackupService bs = ctx.Services.GetRequiredService <BackupService>();
                        await bs.ExemptAsync(ctx.Guild.Id, res.Result.MentionedChannels.SelectIds());
                    }
                }
            }
        }