Exemplo n.º 1
0
        private async Task LogChannel(string msg)
        {
            DSharpPlus.Entities.DiscordChannel channel = await Client.GetChannelAsync(UInt64.Parse(pugBotLogsChannel_ID));

            DiscordMessage message = await channel.SendMessageAsync(msg);
        }
Exemplo n.º 2
0
        public async Task EndGame(CommandContext ctx)
        {
            string endingplayer = nicknamelist.Where(m => m.Item1 == ctx.User).First().ToString(); // Finds each dm channel by discorduser

            if (ctx.User != nicknamelist[currentplayer].Item1)
            {
                var embedwarn = new DiscordEmbedBuilder(GeneralMessageEmbed)
                {
                    Color       = new DiscordColor("#FFFF00"),
                    Title       = "Právě nejsi na řadě!",
                    Description = "Jak můžeš vědět, že se má příběh ukončit?! Pokud se jedná o krizovku, kdy drzý drzoun utekl od svého zažízení, napiš pro potvrzení zprávu **reallyend**.",
                };
                await ctx.Message.RespondAsync(embed : embedwarn.Build());

                var interactivity = ctx.Client.GetInteractivityModule();
                var msg           = await interactivity.WaitForMessageAsync(xm => xm.Author.Id == ctx.User.Id && xm.Content.ToLower() == "reallyend", TimeSpan.FromMinutes(1));

                if (msg != null)
                {
                    await storychannel.SendMessageAsync(embed : StoryEmbed.Build());

                    // Send shit to website etc
                    await PostStory(ctx);

                    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 skončila!",
                            Description = $"Věř tomu nebo ne, hráč {endingplayer} vše skončil. Příběh nalezneš na https://nase.example.com/stories/cs/blog/{webStoryPageName}",
                        };
                        // Different messages for starting player and rest of the squad.
                        await playerDMchannel.SendMessageAsync(embed : embedplayer.Build());
                    }
                    ctx.Client.DebugLogger.LogMessage(level: LogLevel.Info, application: "prdelbot-story", message: $"[{ctx.Message.Author.Username}] forced end of story.", timestamp: DateTime.Now);
                }
            }
            else
            {
                var webStorySentence      = ctx.Message.Content.Substring(5); // Gets current sentence
                var currentPlayerNickname = nicknamelist[currentplayer].Item2;
                webStoryContent.Add(new Tuple <string, string>($"[{nicknamelist[currentplayer].Item1.Username}]{currentPlayerNickname}", webStorySentence));
                StoryEmbed.AddField($"{$"{currentPlayerNickname} "}", ctx.Message.Content.Substring(5));
                await storychannel.SendMessageAsync(embed : StoryEmbed.Build());

                // Send shit to website etc
                await PostStory(ctx);

                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 skončila!",
                        Description = $"Věř tomu nebo ne, hráč {endingplayer} vše skončil. Příběh nalezneš na https://nase.example.com/stories/cs/blog/{webStoryPageName}",
                    };
                    // Different messages for starting player and rest of the squad.
                    await playerDMchannel.SendMessageAsync(embed : embedplayer.Build());
                }
                ctx.Client.DebugLogger.LogMessage(level: LogLevel.Info, application: "prdelbot-story", message: $"[{nicknamelist[currentplayer].Item1.Username}]{currentPlayerNickname} - {webStorySentence}", timestamp: DateTime.Now);
            }


            // Dispose all variables
            round         = 1;
            currentplayer = 0;
            firstsentence = true;
            webStoryTitle = null;
            webStoryDate  = null;
            webStoryContent.Clear();
            StoryEmbed.ClearFields();
            await ctx.Client.UpdateStatusAsync(new DiscordGame("with masself"));
        }