예제 #1
0
        public async Task RandomCatSpam(CommandContext ctx,
                                        [Description("period of cat posting. [number][d/h/m/s]")] TimeSpan period)
        {
            InteractivityExtension interactivity = ctx.Client.GetInteractivity();
            await ctx.RespondAsync(":cat: Cats will appear here every" +
                                   $"{(period.Days != 0 ? $" {period.Days} day(s)" : "")}" +
                                   $"{(period.Hours != 0 ? $" {period.Hours} hour(s)" : "")}" +
                                   $"{(period.Minutes != 0 ? $" {period.Minutes} minute(s)" : "")}" +
                                   $"{(period.Seconds != 0 ? $" {period.Seconds} second(s)" : "")}.\n" +
                                   "Enter `stop cats` to stop it.");

            while (true)
            {
                await RandomCat(ctx);

                InteractivityResult <DiscordMessage> stopmsg = await interactivity.WaitForMessageAsync(xm =>
                                                                                                       xm.ChannelId.Equals(ctx.Message.ChannelId) &&
                                                                                                       xm.Content == "stop cats", period);

                if (stopmsg.TimedOut)
                {
                    continue;
                }
                await ctx.RespondAsync("Cat spam ends here.");

                break;
            }
        }
예제 #2
0
파일: Misc.cs 프로젝트: JFronny/Disc-Hax
        public async Task QuickType(CommandContext ctx,
                                    [Description("Bytes to generate. One byte equals two characters")]
                                    int bytes, [Description("Time before exiting")] TimeSpan time)
        {
            if (ctx.Channel.Get(ConfigManager.Enabled)
                .And(ctx.Channel.GetMethodEnabled()))
            {
                await ctx.TriggerTypingAsync();

                if (time > new TimeSpan(0, 1, 0))
                {
                    throw new ArgumentOutOfRangeException("Please choose a smaller time");
                }
                InteractivityExtension interactivity = ctx.Client.GetInteractivity();
                byte[] codeBytes = new byte[bytes];
                Program.Rnd.NextBytes(codeBytes);
                string code = BitConverter.ToString(codeBytes).ToLower().Replace("-", "");
                await ctx.RespondAsync($"The first one to type the following code gets a reward: {code.Emotify()}");

                InteractivityResult <DiscordMessage> msg =
                    await interactivity.WaitForMessageAsync(xm => xm.Content.Contains(code), time);

                if (msg.TimedOut)
                {
                    await ctx.RespondAsync("Nobody? Really?");
                }
                else
                {
                    await ctx.RespondAsync($"And the winner is: {msg.Result.Author.Mention}");
                }
            }
        }
예제 #3
0
        public static async Task <Reaction> AddAndWaitForYesNoReaction(this InteractivityExtension interactivity, DiscordMessage msg, DiscordUser user)
        {
            DiscordClient client = interactivity.Client;

            await msg.CreateReactionAsync(DiscordEmoji.FromName(client, ":regional_indicator_y:"));

            await msg.CreateReactionAsync(DiscordEmoji.FromName(client, ":regional_indicator_n:"));

            InteractivityResult <MessageReactionAddEventArgs> interactivityResult = await interactivity.WaitForReactionAsync(msg, user);

            if (interactivityResult.TimedOut || interactivityResult.Result.Emoji.Equals(DiscordEmoji.FromName(client, ":regional_indicator_n:")))
            {
                DiscordMessage snark = await interactivityResult.Result.Channel.SendMessageAsync($"{user.Mention}, well then why did you get my attention! Thanks for wasting my time. Let me clean up now. :triumph:");

                await Task.Delay(5000);

                await interactivityResult.Result.Channel.DeleteMessagesAsync(new List <DiscordMessage> {
                    msg, snark
                });

                return(interactivityResult.TimedOut ? Reaction.None : Reaction.No);
            }

            await msg.DeleteAllReactionsAsync();

            return(Reaction.Yes);
        }
예제 #4
0
 public QuizGame(InteractivityExtension interactivity, DiscordChannel channel, IReadOnlyList <QuizQuestion> questions)
     : base(interactivity, channel)
 {
     this.questions         = questions;
     this.results           = new ConcurrentDictionary <DiscordUser, int>();
     this.NumberOfQuestions = this.questions.Count;
 }
예제 #5
0
        public DiscordWrapper(IOptions <DiscordConfig> options, IServiceProvider services, ILoggerFactory loggerFactory)
        {
            DiscordConfig        optionsConfig = options.Value;
            DiscordConfiguration config        = new()
            {
                LoggerFactory = loggerFactory,
                Token         = optionsConfig.Token,
                TokenType     = TokenType.Bot,
                Intents       = DiscordIntents.All
            };

            Client = new DiscordClient(config);

            CommandsNextConfiguration cConfig = new()
            {
                Services = services, StringPrefixes = optionsConfig.Prefixes, EnableDms = true
            };

            Commands = Client.UseCommandsNext(cConfig);

            InteractivityConfiguration iConfig = new()
            {
                PollBehaviour = PollBehaviour.KeepEmojis, Timeout = TimeSpan.FromSeconds(30)
            };

            Interactivity = Client.UseInteractivity(iConfig);

            Client.Logger.LogInformation("Starting with secret: {Token}", options.Value.Token);
        }
    }
}
예제 #6
0
 public void Dispose()
 {
     _client.Dispose();
     _interactivity = null;
     _cnext         = null;
     _config        = null;
 }
        public async Task AddGuildEvent(CommandContext context)
        {
            DiscordMessage msg = await context.RespondAsync($":wave: Hi, {context.User.Mention}! You wanted to create a new event?");

            await msg.CreateReactionAsync(DiscordEmoji.FromName(context.Client, ":regional_indicator_y:"));

            await msg.CreateReactionAsync(DiscordEmoji.FromName(context.Client, ":regional_indicator_n:"));

            InteractivityExtension interactivity = context.Client.GetInteractivity();

            InteractivityResult <MessageReactionAddEventArgs> interactivityResult = await interactivity.WaitForReactionAsync(msg, context.User);

            if (interactivityResult.TimedOut ||
                !interactivityResult.Result.Emoji.Equals(DiscordEmoji.FromName(context.Client, ":regional_indicator_y:")))
            {
                DiscordMessage snark = await context.RespondAsync("Well, thanks for wasting my time. Have a good day.");

                await Task.Delay(5000);

                await context.Channel.DeleteMessagesAsync(new List <DiscordMessage> {
                    msg, snark, context.Message
                });

                return;
            }

            await context.Message.DeleteAsync();

            await msg.DeleteAllReactionsAsync();

            await this.AddGuildEventInteractive(context, interactivity, msg);
        }
예제 #8
0
파일: Config.cs 프로젝트: JFronny/Disc-Hax
        public async Task ConfigReset(CommandContext ctx)
        {
            InteractivityExtension interactivity = ctx.Client.GetInteractivity();
            DiscordMessage         msg           =
                await ctx.RespondAsync(
                    "Please type out \"yes\" to confirm. All configuration for your server will be reset!");

            InteractivityResult <DiscordMessage> tmp =
                await interactivity.WaitForMessageAsync(s => s.Author == ctx.Message.Author, new TimeSpan(0, 0, 30));

            if (!tmp.TimedOut || tmp.Result.Content != "yes")
            {
                string path;
                foreach ((ulong key, DiscordChannel _) in ctx.Guild.Channels)
                {
                    ConfigManager.GetXml(key.ToString(), ConfigManager.Channel, out path);
                    File.Delete(path);
                }
                ConfigManager.GetXml(ctx.Guild.Id.ToString(), ConfigManager.Guild, out path);
                File.Delete(path);
                await msg.ModifyAsync("Deleted.");
            }
            else
            {
                await msg.ModifyAsync("Cancelled.");
            }
        }
예제 #9
0
        private async Task VerifyTransactionAsync(
            CommandContext ctx, GlobalUserModel sender, GlobalUserModel receiver,
            uint amount)
        {
            // 'Complicated async logic here' //
            InteractivityExtension interactivity = ctx.Client.GetInteractivity();
            int authKey = new Random().Next(1000, 10000);
            await ctx.RespondAsync("Just verifying you want to send money to this person. " +
                                   $"Could you type `{authKey}` to confirm? (Ignoring this will cancel, " +
                                   "since Velvet can't be bothered to write that logic right now.)");

            InteractivityResult <DiscordMessage> message =
                await interactivity.WaitForMessageAsync(m => m.Author == ctx.User && m.Content == authKey.ToString(),
                                                        TimeSpan.FromMinutes(3));

            if (message.TimedOut)
            {
                await ctx.RespondAsync("Timed out :(");
            }
            else
            {
                DiscordMember member = await ctx.Guild.GetMemberAsync(receiver.Id);

                DiscordEmbedBuilder embed = new DiscordEmbedBuilder()
                                            .WithThumbnail(ctx.User.AvatarUrl)
                                            .WithDescription($"Successfully donated {amount} dollars to {member.Mention}! " +
                                                             $"Feel free to do `{ctx.Prefix}cash` to ensure you've received the funds.")
                                            .WithColor(DiscordColor.PhthaloGreen);

                sender.Cash   -= (int)amount;
                receiver.Cash += (int)amount;

                await ctx.RespondAsync(embed : embed);
            }
        }
예제 #10
0
        public static async Task <bool?> WaitForConfirmation(this InteractivityExtension interactivity, TimeSpan?timeoutoverride = null)
        {
            string[] positive = new string[]
            {
                "yes",
                "y",
                "yeah",
                "✅",
                "✔",
            };
            string[] negative = new string[]
            {
                "no",
                "n",
                "nope",
                "❌",
                "✖",
                "❎"
            };
            InteractivityResult <DiscordMessage> interactivityResult = await interactivity.WaitForMessageAsync(msg => positive.Any(w => msg.Content.ToLower().Contains(w)) ||
                                                                                                               negative.Any(w => msg.Content.ToLower().Contains(w)),
                                                                                                               timeoutoverride);

            return(positive.Any(w => interactivityResult.Result.Content.ToLower().Contains(w))
                ? true
                : negative.Any(w => interactivityResult.Result.Content.ToLower().Contains(w)) ? false : (bool?)null);
        }
예제 #11
0
        public Bot()
        {
            Instance = this;
            //DownloadAudioClips();

            DiscordConfiguration discordConfiguration = new DiscordConfiguration()
            {
                AutoReconnect         = true,
                Token                 = Config.Instance.Token,
                TokenType             = TokenType.Bot,
                UseInternalLogHandler = true,
                LogLevel              = LogLevel.Info,
                DateTimeFormat        = "MM/dd/yyyy hh:mm:ss tt"
            };

            discord = new DiscordClient(discordConfiguration);
            discord.DebugLogger.LogMessageReceived += LogMessageReceived;

            interactivity = discord.UseInteractivity(new InteractivityConfiguration());
            voice         = discord.UseVoiceNext();
            commands      = discord.UseCommandsNext(new CommandsNextConfiguration()
            {
                StringPrefixes = new[] { Config.Instance.Prefix },
                CaseSensitive  = false
            });

            commands.RegisterCommands <GeneralCommands>();
            commands.RegisterCommands <AudioModule>();
            commands.RegisterCommands <MinecraftCommands>();
            commands.CommandErrored  += CommandErrored;
            commands.CommandExecuted += CommandExecuted;
            //discord.MessageCreated += MessageCreated;
            discord.Ready += Ready;
        }
예제 #12
0
파일: Bot.cs 프로젝트: joaodev123/CSUB
        private Bot(Config config)
        {
            this.config = new DiscordConfiguration
            {
                Token = config.Token
            };
            this.client  = new DiscordClient(this.config);
            this.cfg     = config;
            this.systems = GetExecutingAssembly().GetTypes().Where(x => x.GetInterfaces().Contains(typeof(IApplicableSystem))).ToList();
            this.systems = GetExecutingAssembly().GetTypes().Where(x => x.GetInterfaces().Contains(typeof(IApplicableSystem))).ToList();
            foreach (var system in systems)
            {
                if (system.GetInterfaces().Contains(typeof(IApplyToClient)))
                {
                    var instance = (IApplyToClient)Activator.CreateInstance(system);
                    instance.Activate();
                    instance.ApplyToClient(this.client);
                    Console.WriteLine($"[System] {instance.Name} Loaded\n\t{instance.Description}");
                }
            }

            this.cnext = this.client.UseCommandsNext(new CommandsNextConfiguration
            {
                PrefixResolver    = PrefixResolver,
                EnableDefaultHelp = false,
                EnableDms         = true
            });
            this.interactivity = this.client.UseInteractivity(new InteractivityConfiguration {
                Timeout = TimeSpan.FromMinutes(30)
            });
        }
예제 #13
0
파일: Program.cs 프로젝트: Damitrix/Sabrina
        private void SetConfig(string[] args)
        {
            if (args.Length > 0)
            {
                Config.ConfigPath = args[0];
            }

            var config = new DiscordConfiguration
            {
                AutoReconnect         = true,
                MessageCacheSize      = 2048,
                LogLevel              = LogLevel.Debug,
                Token                 = Config.Token,
                TokenType             = TokenType.Bot,
                UseInternalLogHandler = true
            };

            this._client = new DiscordClient(config);

            this.Interactivity = this._client.UseInteractivity(
                new InteractivityConfiguration()
            {
                PaginationBehaviour = DSharpPlus.Interactivity.Enums.PaginationBehaviour.Default,
                Timeout             = TimeSpan.FromSeconds(30)
            });
        }
예제 #14
0
        public async Task RunAsync()
        {
            if (File.Exists("config.json"))
            {
                _config = JObject.Parse(File.ReadAllText("config.json")).ToObject <Config>();
            }
            else
            {
                File.Create("config.json").Close();
                File.WriteAllText("config.json", JObject.FromObject(new Config()).ToString());
                Console.WriteLine("Created a new config file. Please write out all values");
                Console.ReadKey();
                Environment.Exit(0);
            }

            this._client = new DiscordClient(new DiscordConfiguration()
            {
                AutoReconnect         = true,
                LogLevel              = LogLevel.Debug,
                Token                 = _config.Token,
                TokenType             = TokenType.Bot,
                UseInternalLogHandler = true
            });

            this._interactivity = this._client.UseInteractivity(new InteractivityConfiguration()
            {
                PaginationBehaviour = PaginationBehaviour.WrapAround,
                PaginationDeletion  = PaginationDeletion.DeleteEmojis,
                PaginationEmojis    = new PaginationEmojis(),
                PollBehaviour       = PollBehaviour.DeleteEmojis,
                Timeout             = TimeSpan.FromSeconds(45) // timeout op interactivity
            });

            var services = new ServiceCollection()
                           .AddSingleton <DiscordClient>(_client)
                           .AddSingleton <InteractivityExtension>(_interactivity)
                           .AddSingleton <Config>(_config)
                           .AddSingleton <Bot>(this)
                           .BuildServiceProvider();

            this._commands = this._client.UseCommandsNext(new CommandsNextConfiguration()
            {
                StringPrefixes = new List <string> {
                    _config.CommandPrefix
                },
                EnableDms           = false, // geen commands via DM, kan je aanpassen als je wil
                EnableDefaultHelp   = true,  // zelf geen help maken, vet handig
                EnableMentionPrefix = true,  // @bot doe dingen, vet leuk
                CaseSensitive       = false, // @bOt dOe dINgEn lekker sarcastisch
                Services            = services
            });

            _commands.RegisterCommands <MainCommands>();
            _commands.RegisterCommands <OwnerCommands>();
            status = "hentai";
            //client connect event:
            _client.Ready += Client_Ready;

            await _client.ConnectAsync();
        }
예제 #15
0
        private static async Task MainAsync()
        {
            discord = new DiscordClient(new DiscordConfiguration {
                Token           = "",
                TokenType       = TokenType.Bot,
                MinimumLogLevel = LogLevel.Information,
                Intents         = DiscordIntents.GuildMembers | DiscordIntents.AllUnprivileged
            });

            CommandsNextExtension commands = discord.UseCommandsNext(new CommandsNextConfiguration()
            {
                StringPrefixes = new[] { "." }
            });

            InteractivityExtension interactivity = discord.UseInteractivity(new InteractivityConfiguration {
                Timeout = TimeSpan.FromMinutes(10)
            });

            discord.Ready            += EventHandlers.Discord_Ready;
            discord.GuildMemberAdded += EventHandlers.Discord_GuildMemberAdded;
            discord.MessageCreated   += EventHandlers.Discord_MessageCreated;
            commands.CommandErrored  += EventHandlers.Commands_CommandErrored;

            commands.SetHelpFormatter <CustomHelpFormatter>();
            commands.RegisterCommands(Assembly.GetExecutingAssembly());

            await discord.ConnectAsync();

            await Task.Delay(-1);
        }
예제 #16
0
        static async Task MainAsync(string[] args)
        {
            string token = Environment.GetEnvironmentVariable("BOTTOKEN");

            discord = new DiscordClient(new DiscordConfiguration {
                Token     = token,
                TokenType = TokenType.Bot
            });

            interactivity = discord.UseInteractivity(new InteractivityConfiguration());

            commands = discord.UseCommandsNext(new CommandsNextConfiguration()
            {
                StringPrefixes = new string[] { "!" },
                CaseSensitive  = false
            });

            commands.RegisterCommands <Commands>();

            var command = new Commands();

            //await Task.Run(() => discord.MessageCreated += Discord_MessageCreated);

            await discord.ConnectAsync();

            await Task.Delay(-1);
        }
예제 #17
0
        }                                                                  // not yet set for now

        public async Task RunAsync(string token)
        {
            var config = new DiscordConfiguration
            {
                Token           = token,
                TokenType       = TokenType.Bot,
                AutoReconnect   = true,
                MinimumLogLevel = LogLevel.Debug
            };

            _Client = new DiscordClient(config);
            // every client ready, guild available and client error
            _Client.Ready          += Client_OnReady;
            _Client.GuildAvailable += Client_GuildConnected;
            _Client.ClientErrored  += Client_ClientError;


            SharedData.prefixes.Add("i!"); //default prefix
            //might wanna add a interactivity here along with its config
            var commandsConfig = new CommandsNextConfiguration
            {
                StringPrefixes      = SharedData.prefixes, // for now it is default prefix can turn this to a list
                EnableDms           = true,                // so botDev can set himself as dev lmao
                EnableMentionPrefix = false,
                EnableDefaultHelp   = true,
                DmHelp = false
            };

            _Commands = _Client.UseCommandsNext(commandsConfig);
            _Commands.CommandExecuted += Command_CommandExecuted;
            _Commands.CommandErrored  += Command_CommandError;


            _Commands.RegisterCommands <IamagesCmds>();
            _Commands.RegisterCommands <UtilCmds>();
            _Commands.SetHelpFormatter <HelpFormatter>();

            var emojis = new PaginationEmojis() //emojis to be used in the pagination
            {
                Left      = DiscordEmoji.FromName(_Client, ":arrow_backward:"),
                Right     = DiscordEmoji.FromName(_Client, ":arrow_forward:"),
                SkipLeft  = null,
                SkipRight = null
            };

            _Interactivity = _Client.UseInteractivity(new InteractivityConfiguration
            {
                PaginationBehaviour = DSharpPlus.Interactivity.Enums.PaginationBehaviour.WrapAround,
                PaginationEmojis    = emojis,
                Timeout             = TimeSpan.FromSeconds(60) //increase timeout
            });

            SharedData.reportChannel = await _Client.GetChannelAsync(SharedData.reportChannelid);

            SharedData.startTime = DateTime.Now;
            //client connection to bot application on the discord api
            await _Client.ConnectAsync();

            await Task.Delay(-1); // <------ needs to re looked upon
        }
예제 #18
0
        public static async Task <bool> WaitForBoolReplyAsync(this InteractivityExtension interactivity, ulong cid, ulong uid, SharedData shared = null)
        {
            if (!(shared is null))
            {
                shared.AddPendingResponse(cid, uid);
            }

            bool           response = false;
            MessageContext mctx     = await interactivity.WaitForMessageAsync(
                m => {
                if (m.ChannelId != cid || m.Author.Id != uid)
                {
                    return(false);
                }
                bool?b   = CustomBoolConverter.TryConvert(m.Content);
                response = b ?? false;
                return(b.HasValue);
            }
                );

            if (!(shared is null) && !shared.TryRemovePendingResponse(cid, uid))
            {
                throw new ConcurrentOperationException("Failed to remove user from waiting list. This is bad!");
            }

            return(response);
        }
예제 #19
0
        public async Task Poll(CommandContext ctx, TimeSpan duration, params DiscordEmoji[] emojiOptions)
        {
            InteractivityExtension interactivity = ctx.Client.GetInteractivity();
            IEnumerable <string>   options       = emojiOptions.Select(x => x.ToString());

            DiscordEmbedBuilder pollEmbed = new DiscordEmbedBuilder
            {
                Title       = "Poll",
                Description = string.Join(" ", options)
            };

            DiscordMessage pollMessage = await ctx.Channel.SendMessageAsync(embed : pollEmbed).ConfigureAwait(false);

            foreach (DiscordEmoji option in emojiOptions)
            {
                await pollMessage.CreateReactionAsync(option).ConfigureAwait(false);
            }

            var result = await interactivity.CollectReactionsAsync(pollMessage, duration).ConfigureAwait(false);

            var distinctResult = result.Distinct();

            var results = distinctResult.Select(x => $"{x.Emoji}: {x.Total}");

            await ctx.Channel.SendMessageAsync(string.Join("\n", results)).ConfigureAwait(false);
        }
예제 #20
0
파일: Bot.cs 프로젝트: 001101/Discord-Bot
        public Bot(string Token, string mysqlCon)
        {
            connection      = new MySqlConnection(mysqlCon);
            ShutdownRequest = new CancellationTokenSource();
            var cfg = new DiscordConfiguration
            {
                Token                 = Token,
                TokenType             = TokenType.Bot,
                AutoReconnect         = true,
                LogLevel              = LogLevel.Debug,
                UseInternalLogHandler = true
            };

            Client = new DiscordClient(cfg);
            Client.GuildDownloadCompleted += BotGuildsDownloaded;
            Client.GuildMemberAdded       += MemberAdd;
            Client.GuildMemberUpdated     += MemberUpdate;
            Client.GuildMemberRemoved     += MemberLeave;
            Client.GuildCreated           += BotGuildAdded;
            //Client.MessageReactionAdded += ReactAdd;
            //Client.MessageReactionRemoved += ReactRemove;
            CNext = Client.UseCommandsNext(new CommandsNextConfiguration {
                StringPrefixes    = new string[] { "$", "!", "%" },
                EnableDefaultHelp = false
            });
            CNext.RegisterCommands <Commands.UserCommands>();
            CNext.RegisterCommands <Commands.AdminCommands>();
            CNext.RegisterCommands <Commands.OwnerCommands>();
            CNext.RegisterCommands <Config.UserConfig>();
            INext = Client.UseInteractivity(new InteractivityConfiguration {
            });
        }
예제 #21
0
        private static async Task MainAsync(string[] arguments)
        {
            _discordClient = new DiscordClient(new DiscordConfiguration
            {
                Token           = _config.Token,
                TokenType       = TokenType.Bot,
                MinimumLogLevel = LogLevel.Information
            });

            _discordClient.MessageCreated += CheckForCannedResponses;

            _commandsNext = _discordClient.UseCommandsNext(new CommandsNextConfiguration
            {
                EnableMentionPrefix = true,
                StringPrefixes      = new List <string> {
                    _config.CommandPrefix
                },
                CaseSensitive = false
            });
            _commandsNext.RegisterCommands <ShittyVerseModule>();
            _commandsNext.RegisterCommands <CopyPastaModule>();

            InteractivityExtension = _discordClient.UseInteractivity(new InteractivityConfiguration());
            await _discordClient.ConnectAsync();

            await Task.Delay(-1);
        }
예제 #22
0
 public AnimalRace(InteractivityExtension interactivity, DiscordChannel channel)
     : base(interactivity, channel)
 {
     this.Started      = false;
     this.participants = new ConcurrentQueue <AnimalRaceParticipant>();
     this.animals      = new ConcurrentBag <DiscordEmoji>(Emojis.Animals.All);
 }
예제 #23
0
    private async Task WaitForNextMessage(CommandContext ctx, DiscordMessage oldmessage,
                                          InteractivityExtension interactivity, Language lang, int page, string formated, GiphySearchResult gifResult,
                                          DiscordEmbedBuilder b = null)
    {
        b ??= new DiscordEmbedBuilder();
        var msg = await oldmessage.WaitForButtonAsync(ctx.User, TimeSpan.FromSeconds(300));

        if (msg.Result != null)
        {
            page++;
            if (page >= gifResult.Data.Length)
            {
                page = 0;
            }

            b.WithDescription(
                $"{formated} : {gifResult.Data[page].Url} {string.Format(lang.PageGif, page + 1, gifResult.Data.Length)}")
            .WithImageUrl(gifResult.Data[page].Images.Original.Url).WithColor(await ColorUtils.GetSingleAsync());
            await msg.Result.Interaction.CreateResponseAsync(InteractionResponseType.UpdateMessage,
                                                             new DiscordInteractionResponseBuilder(new DiscordMessageBuilder().WithEmbed(b)
                                                                                                   .AddComponents(new DiscordButtonComponent(ButtonStyle.Primary, "nextgif",
                                                                                                                                             lang.PageGifButtonText))));
            await WaitForNextMessage(ctx, oldmessage, interactivity, lang, page, formated, gifResult, b);
        }
        else
        {
            await oldmessage.ModifyAsync(new DiscordMessageBuilder().WithEmbed(b).WithContent(lang.PeriodExpired)
                                         .AddComponents(new DiscordButtonComponent(ButtonStyle.Primary, "nextgif", lang.PageGifButtonText,
                                                                                   true)));
        }
    }
예제 #24
0
 public Toxicity(SharedData shared, DatabaseContextBuilder db, InteractivityExtension interactive, StartTimes starttimes)
 {
     this.Database      = db;
     this.Shared        = shared;
     this.Interactivity = interactive;
     this.StartTimes    = starttimes;
 }
예제 #25
0
 public Fields(InteractivityExtension interactivity, Dictionary <string, string> tokens, DiscordClient client, Random random)
 {
     this.Interactivity = interactivity;
     this.Tokens        = tokens;
     this.DiscordClient = client;
     this.Random        = random;
 }
 public RussianRouletteGame(InteractivityExtension interactivity, DiscordChannel channel)
     : base(interactivity, channel)
 {
     this.Started      = false;
     this.Survivors    = new List <DiscordUser>();
     this.participants = new ConcurrentHashSet <DiscordUser>();
 }
예제 #27
0
        static async Task MainAsync(string[] arguments)
        {
            discord = new DiscordClient(new DiscordConfiguration
            {
                Token         = "YOUR-BOT-TOKEN-FROM-DISCORDAPP-WEBSITE-GOES-HERE",
                TokenType     = TokenType.Bot,
                AutoReconnect = true
            });

            discord.GuildMemberAdded += async data => {
                var member = data.Member;
                var role   = data.Guild.Roles.FirstOrDefault(roles => roles.Name == "Tsukonin");
                await member.GrantRoleAsync(role);
            };

            commands = discord.UseCommandsNext(new CommandsNextConfiguration
            {
                StringPrefixes = new [] { "hola, ", "oi, ", "yo, ", "hey, ", "sup, ", "aloha, ",
                                          "hola ", "oi ", "yo ", "hey ", "sup ", "aloha ", "alert " },
                EnableDms = true
            });

            commands.RegisterCommands <Commander>();

            interactivity = discord.UseInteractivity(new InteractivityConfiguration {
            });

            Schedule.ReadZoneInfo();

            Magician.DisappearConsole();

            await discord.ConnectAsync();

            await Task.Delay(-1);
        }
예제 #28
0
        public static async Task <DiscordChannel?> WaitForChannelMentionAsync(this InteractivityExtension interactivity, DiscordChannel channel, DiscordUser user)
        {
            InteractivityResult <DiscordMessage> mctx = await interactivity.WaitForMessageAsync(
                m => m.Channel == channel && m.Author == user && m.MentionedChannels.Count == 1
                );

            return(mctx.TimedOut ? null : mctx.Result.MentionedChannels.FirstOrDefault() ?? null);
        }
예제 #29
0
 public DiscordService(AatroxConfigurationProvider ac, DiscordBotSharderConfiguration dbc,
                       InteractivityExtension interactivity, AatroxPrefixProvider aapp) : base(TokenType.Bot,
                                                                                               ac.GetConfiguration().DiscordToken, aapp, dbc)
 {
     _logger        = LogService.GetLogger("Discord");
     _configuration = ac.GetConfiguration();
     _interactivity = interactivity;
 }
예제 #30
0
 public DuelGame(InteractivityExtension interactivity, DiscordChannel channel, DiscordUser p1, DiscordUser p2)
     : base(interactivity, channel)
 {
     this.player1 = p1;
     this.player2 = p2;
     this.hp1     = this.hp2 = StartingHp;
     this.eb      = new StringBuilder();
 }