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;
            }
        }
        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;
                            }
                        }
                    }
                }
Exemple #3
0
 /// <summary>
 /// Gets the next message sent in this channel by a specific user.
 /// </summary>
 /// <param name="c">Channel message was sent in.</param>
 /// <param name="m">Member message was sent by.</param>
 /// <param name="timeoutoverride">Timeout override.</param>
 /// <returns></returns>
 public static async Task <InteractivityResult <DiscordMessage> > GetNextMessageAsync(this DiscordChannel c, DiscordMember m, TimeSpan?timeoutoverride = null)
 => await c.GetNextMessageAsync(x => x.Author.Id == m.Id, timeoutoverride);
Exemple #4
0
 /// <summary>
 /// Gets the next message sent in this channel.
 /// </summary>
 /// <param name="c">Channel message was sent in.</param>
 /// <param name="timeoutoverride">Timeout override.</param>
 /// <returns></returns>
 public static async Task <InteractivityResult <DiscordMessage> > GetNextMessageAsync(this DiscordChannel c, TimeSpan?timeoutoverride = null)
 => await c.GetNextMessageAsync(x => true, timeoutoverride);
Exemple #5
0
 public static Task <InteractivityResult <DiscordMessage> > GetNextMessageAsync(this DiscordChannel channel, DiscordUser user,
                                                                                Func <DiscordMessage, bool> predicate)
 => channel.GetNextMessageAsync(m => m.Author == user && predicate(m));
 /// <summary>
 /// Waits for the next message sent in this channel from a specific user.
 /// </summary>
 /// <param name="channel">The channel to monitor.</param>
 /// <param name="user">The target user.</param>
 /// <param name="timeoutOverride">Overrides the timeout set in <see cref="InteractivityConfiguration.Timeout"/></param>
 /// <exception cref="InvalidOperationException">Thrown if interactivity is not enabled for the client associated with the channel.</exception>
 public static Task <InteractivityResult <DiscordMessage> > GetNextMessageAsync(this DiscordChannel channel, DiscordUser user, TimeSpan?timeoutOverride = null)
 => channel.GetNextMessageAsync(msg => msg.Author.Id == user.Id, timeoutOverride);
 /// <summary>
 /// Waits for the next message sent in this channel.
 /// </summary>
 /// <param name="channel">The channel to monitor.</param>
 /// <param name="timeoutOverride">Overrides the timeout set in <see cref="InteractivityConfiguration.Timeout"/></param>
 /// <exception cref="InvalidOperationException">Thrown if interactivity is not enabled for the client associated with the channel.</exception>
 public static Task <InteractivityResult <DiscordMessage> > GetNextMessageAsync(this DiscordChannel channel, TimeSpan?timeoutOverride = null)
 => channel.GetNextMessageAsync(msg => true, timeoutOverride);