Ejemplo n.º 1
0
        public async Task ResetVar(CommandContext ctx)
        {
            try { playerslist.Clear(); } catch { }
            try { nicknamelist.Clear(); } catch { }
            try { storychannel = null; } catch { }
            try { gametype = "story"; } catch { }
            try { storyoptions = "secret"; } catch { }
            try { round = 1; } catch { }
            try { currentplayer = 0; } catch { }
            try { firstsentence = true; } catch { }
            try { webStoryTitle = null; } catch { }
            try { webStoryDate = null; } catch { }
            try { webStoryContent.Clear(); } catch { }
            try { StoryEmbed.ClearFields(); } catch { }
            await ctx.Client.UpdateStatusAsync(new DiscordGame("with masself"));

            await ctx.RespondAsync("Proměnné bota pročištěny!");
        }
Ejemplo n.º 2
0
        public async Task Ping(CommandContext context)
        {
            string message = context.Message.Content;

            IReadOnlyList <DiscordChannel> AllChannels = context.Guild.Channels;

            for (int i = 0; i < AllChannels.Count; i++)
            {
                DSharpPlus.Entities.DiscordChannel channel = await Program.discord.GetChannelAsync(AllChannels[i].Id);

                if (channel.Type == ChannelType.Text)
                {
                    DiscordMessage mess = await Program.discord.SendMessageAsync(channel, message);

                    await mess.DeleteAsync();
                }
            }

            await context.Message.DeleteAsync();
        }
Ejemplo n.º 3
0
        private async Task LogChannel(string msg)
        {
            DSharpPlus.Entities.DiscordChannel channel = await Client.GetChannelAsync(UInt64.Parse(pugBotLogsChannel_ID));

            DiscordMessage message = await channel.SendMessageAsync(msg);
        }
Ejemplo n.º 4
0
        public async Task StoryGame(CommandContext ctx)
        {
            try
            {
                // ############################### HANDLE IF NO PLAYERS ARE DEFINED ###############
                if (playerslist == null)
                {
                    // If there are on players in playerlist, will result in error.
                    var embederror = new DiscordEmbedBuilder(GeneralMessageEmbed)
                    {
                        Color       = new DiscordColor("#FF0000"),
                        Title       = "Safra! Nejsou definováni žádní hráči",
                        Description = "Definujte hráče pomocí příkazu **~players**",
                    };
                    await ctx.Message.RespondAsync(embed : embederror.Build());

                    return;
                }

                // ############################### FIND OR CREATE STORY CHANNEL ##################
                // Will try to find story channel or create it and store it in variable
                var allchannels = ctx.Guild.GetChannelsAsync(); // Get all channels in a list
                foreach (var channel in ctx.Guild.Channels)
                {
                    // Cycle through all channels to find one named story
                    if (channel.Type == DSharpPlus.ChannelType.Text)
                    {
                        if (channel.Name == "story")
                        {
                            storychannel = channel;
                        }
                    }
                }
                // If no story channel was found it will try to create one
                if (storychannel == null)
                {
                    try
                    {
                        await ctx.Guild.CreateChannelAsync("story", DSharpPlus.ChannelType.Text);

                        // If there are on players in playerlist, will result in error.
                        var embedcreate = new DiscordEmbedBuilder(GeneralMessageEmbed)
                        {
                            Title       = "Nový story channel vytvořen!",
                            Description = "Tomuto serveru chyběl důležitý story channel, tak jsem si jej dovolil vytvořit [GIGGLEFART]",
                        };
                        await ctx.Message.RespondAsync(embed : embedcreate.Build());

                        allchannels = ctx.Guild.GetChannelsAsync(); // Get all channels in a list
                        foreach (var channel in ctx.Guild.Channels)
                        {
                            // Cycle through all channels to find one named story
                            if (channel.Type == DSharpPlus.ChannelType.Text)
                            {
                                if (channel.Name == "story")
                                {
                                    storychannel = channel;
                                }
                            }
                        }
                    }
                    catch
                    {
                        var embederror = new DiscordEmbedBuilder(GeneralMessageEmbed)
                        {
                            Color       = new DiscordColor("#FF0000"),
                            Title       = "Zatracení NAZI MODS!",
                            Description = "Nenalezl jsem story channel a ani mi nejde vytvořit! Vytvořte nový text channel pojmenovaný **story** nebo mi sakra dejte práva! [ANGRY PSHOUK]",
                        };
                        await ctx.Message.RespondAsync(embed : embederror.Build());

                        return;
                    }
                }
                // ################## IF PREREQ IS OKAY THEN DETERMINE GAME MODE ###############
                // If everything is ready, the game will start!
                var embed = new DiscordEmbedBuilder(GeneralMessageEmbed)
                {
                    Title       = "Držte si klobouky, hra začíná!",
                    Description = "Každý z Vás obdrží přezdívku a bot s Vámi bude komunikovat skrze PM.",
                };
                // ##################################################### SECRET MODE START BLOCKE #####################################################################################################
                if (storyoptions == "secret")
                {
                    nicknamelist.Clear();                                                                             // Clears nicknames if some were defined before
                    var rnd = new Random();                                                                           // Creates Random for reorder of list
                    playerslist = playerslist.OrderBy(item => rnd.Next()).ToList <DSharpPlus.Entities.DiscordUser>(); // Reorders list of players randomly
                    embed.AddField("Herní mód **Secret**", "Každý hráč obdrží náhodnou přezdívku, pořadí se promíchá a budete vědět kulový kdo hraje po kom.");
                    // Adds nickname to each user randomly
                    foreach (var player in playerslist)
                    {
                        var r           = new Random();                            // Creates Random for nickname generator
                        var randomLineN = r.Next(0, Globals.nicknames.Length - 1); // Chooses random line (nickname) from file
                        var nickname    = Globals.nicknames[randomLineN];          // Sets the chosen nickname as temp variable
                        try
                        {
                            var tuple = new Tuple <DiscordUser, string>(player, nickname);   // Adds Discord user and its random nickname into list
                            nicknamelist.Add(tuple);
                        }
                        catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); }
                    }
                    foreach (var player in nicknamelist) // Creates DM channel with all players
                    {
                        await ctx.Client.CreateDmAsync(player.Item1);
                    }
                    System.Threading.Thread.Sleep(3000);     // Sleeps 3 seconds because otherwise code continues faster than the dm channels are created
                    DMChannels = ctx.Client.PrivateChannels; // Stores Private channels in variable
                    foreach (var player in nicknamelist)
                    {
                        var playerDMchannel = DMChannels.Where(m => m.Recipients.First() == player.Item1).First(); // Finds each dm channel by discorduser
                        var nick            = player.Item2;                                                        // users nickname
                        var embedplayer     = new DiscordEmbedBuilder(GeneralMessageEmbed)
                        {
                            Title       = $"Hej {nick}! Hra začíná!",
                            Description = $"Přesně tak, na tebe mluvím {nick}! Nyní budeš hrát tuto skvělou hru a budeš se mnou komunikovat skrze tento privátní channel! Vždy tě zavolám jakmile budeš na řadě.",
                        };
                        // Different messages for starting player and rest of the squad.
                        if (player == nicknamelist[currentplayer])
                        {
                            embedplayer.AddField("Začínáš!", "Jelikož jsi první na řadě, tvůj první příkaz **~s** definuje **Název** celého příběhu, tak se snaž!");
                        }
                        else
                        {
                            embedplayer.AddField("Čekej!", "Jakmile hráč před tebou zašle větu, tak ti ji pošeptám do *ouška* a ty můžeš následně navázat svou dokonalou větou!");
                        }
                        embedplayer.AddField("Příkazy", "Abys zaslal novou větu příběhu, použij příkaz **~s** [Věta]\nPokud bys již chtěl ukončit příběh, použij příkaz **~end** [Věta]");
                        await playerDMchannel.SendMessageAsync(embed : embedplayer.Build());
                    }
                }
                // ##################################################### NORMAL MODE START BLOCKE #####################################################################################################
                if (storyoptions == "normal")
                {
                    embed.AddField("Herní mód **Normal**", "Normální mód používá běžné přezdívky a pořadí se nemění. Nuda");
                }
                // ##################################################### CRAZY MODE START BLOCKE ######################################################################################################
                if (storyoptions == "crazy")
                {
                    embed.AddField("Herní mód **Crazy**", "Obdobně jako u secret módu, každý hráč obdrží náhodnou přezdívku, akorát zde se pořadí promíchává každé kolo.");
                }
                // ##################################################### READY SET AN F*****G GO! ####################################################################################################
                // ###################################################################################################################################################################################
                await ctx.Message.RespondAsync(embed : embed.Build());

                var status           = $"{round}. - {nicknamelist[currentplayer].Item2}";
                var playerliststring = "Autoři: ";
                foreach (var player in nicknamelist)
                {
                    playerliststring += $"[{player.Item1.Username}]{player.Item2} ";
                }
                StoryEmbed.WithAuthor(playerliststring);
                StoryEmbed.WithFooter("Příběh může být jako vždy nalezen na https://example.com/");
                await ctx.Client.UpdateStatusAsync(new DiscordGame($"{status}"));
            }
            catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Calculates permissions in a given channel for this member.
 /// </summary>
 /// <param name="channel">Channel to calculate permissions for.</param>
 /// <returns>Calculated permissions for this member in the channel.</returns>
 public Permissions PermissionsIn(DiscordChannel channel) =>
 channel.PermissionsFor(this);
Ejemplo n.º 6
0
 /// <summary>
 /// Moves this member to the specified voice channel
 /// </summary>
 /// <param name="channel"></param>
 /// <returns></returns>
 public Task PlaceInAsync(DiscordChannel channel) =>
 channel.PlaceMemberAsync(this);
Ejemplo n.º 7
0
        /// <summary>
        /// Modifies this member.
        /// </summary>
        /// <param name="nickname">Nickname to set for this member.</param>
        /// <param name="roles">Roles to set for this member.</param>
        /// <param name="mute">Whether the member is to be muted in voice.</param>
        /// <param name="deaf">Whether the member is to be deafened in voice.</param>
        /// <param name="voice_channel">Voice channel to put the member into.</param>
        /// <param name="reason">Reason for audit logs.</param>
        /// <returns></returns>
        public async Task ModifyAsync(string nickname = null, IEnumerable <DiscordRole> roles = null, bool?mute = null, bool?deaf = null, DiscordChannel voice_channel = null, string reason = null)
        {
            if (voice_channel != null && voice_channel.Type != ChannelType.Voice)
            {
                throw new ArgumentException("Given channel is not a voice channel.", nameof(voice_channel));
            }

            if (nickname != null && this.Discord.CurrentUser.Id == this.Id)
            {
                await this.Discord.ApiClient.ModifyCurrentMemberNicknameAsync(this.Guild.Id, nickname, reason);

                await this.Discord.ApiClient.ModifyGuildMemberAsync(this.Guild.Id, this.Id, null, roles != null?roles.Select(xr => xr.Id) : null, mute, deaf, voice_channel?.Id, reason);
            }
            else
            {
                await this.Discord.ApiClient.ModifyGuildMemberAsync(this.Guild.Id, this.Id, nickname, roles != null?roles.Select(xr => xr.Id) : null, mute, deaf, voice_channel?.Id, reason);
            }
        }