public async Task ShowCharacterStoryAsync(IUser targetUser = null)
            {
                var userInfo  = Context.User;
                var character = targetUser == null
                    ? await _charService.GetCharacterAsync(userInfo.Id)
                    : await _charService.GetCharacterAsync(targetUser.Id);

                if (character == null)
                {
                    await ReplyAsync(string.Format(Messages.ERR_CHAR_NOT_FOUND, userInfo.Mention));

                    return;
                }

                if (character.Story == null || character.Story.Equals(""))
                {
                    await ReplyAsync(string.Format(Messages.ERR_STORY_NOT_FOUND, userInfo.Mention));

                    return;
                }

                var embed = EmbedHelper.BuildBasicEmbed("Command: $character story",
                                                        $"**Name:** {character.Name}\n" +
                                                        $"**Story:** {character.Story}");

                await ReplyAsync(userInfo.Mention, embed : embed);
            }
Beispiel #2
0
        public async Task SettingsAsync()
        {
            var guild = await Database.Guilds.AsNoTracking()
                        .Include(x => x.Tags)
                        .Include(x => x.CurrencyItems)
                        .Include(x => x.Shops)
                        .Include(x => x.Streams)
                        .Include(x => x.Leaderboards)
                        .Include(x => x.RssFeeds)
                        .Include(x => x.Cases)
                        .FirstAsync(x => x.GuildId == Context.Guild.Id);

            var embed = EmbedHelper.Embed(EmbedHelper.Info)
                        .WithTitle(Context.Guild.Name + " Settings")
                        .WithDescription("Guild settings and data for the Administrators")
                        .WithCurrentTimestamp()
                        .AddField("General Information",
                                  "```"
                                  + "Prefix                : " + (await Database.BotConfigs.AsNoTracking().FirstAsync()).Prefix + "\n"
                                  + "Bot Change channel    : " + Context.Guild.GetChannelName(guild.BotChangeChannel) + "\n"
                                  + "Case Log channel      : " + Context.Guild.GetChannelName(guild.CaseLogChannel) + "\n"
                                  + "Message Log channel   : " + Context.Guild.GetChannelName(guild.MessageLogChannel) + "\n"
                                  + "Report channel        : " + Context.Guild.GetChannelName(guild.ReportLogChannel) + "\n"
                                  + "Rules channel         : " + Context.Guild.GetChannelName(guild.RulesChannel) + "\n"
                                  + "Announcement role     : " + Context.Guild.GetRoleName(guild.AnnouncementRole) + "\n"
                                  + "Lottery role          : " + Context.Guild.GetRoleName(guild.LotteryRole) + "\n"
                                  + "Mute role             : " + Context.Guild.GetRoleName(guild.MuteRole) + "\n"
                                  + "Playstation role      : " + Context.Guild.GetRoleName(guild.PlaystationRole) + "\n"
                                  + "Xbox role             : " + Context.Guild.GetRoleName(guild.XboxRole) + "\n"
                                  + "```")
                        .AddField("Mod Information",
                                  "```"
                                  + "Log Deleted Messages    : " + (guild.EnableDeletionLog ? "Enabled" : "Disabled") + "\n"
                                  + "Profanity Check         : " + (guild.EnableAntiProfanity ? "Enabled" : "Disabled") + "\n"
                                  + "Rss Feed                : " + (guild.EnableRssFeed ? "Enabled" : "Disabled") + "\n"
                                  + "Mixer                   : " + (guild.EnableMixerFeed ? "Enabled" : "Disabled") + "\n"
                                  + "Twitch                  : " + (guild.EnableTwitchFeed ? "Enabled" : "Disabled") + "\n"
                                  + "Leaderboard             : " + (guild.EnableLeaderboardFeed ? "Enabled" : "Disabled") + "\n"
                                  + "Rss Feeds               : " + guild.RssFeeds.Count + "\n"
                                  + "Mixer Streams           : " + guild.Streams.Count(x => x.StreamType is StreamType.Mixer) + "\n"
                                  + "Twitch Stream           : " + guild.Streams.Count(x => x.StreamType is StreamType.Twitch) + "\n"
                                  + "Leaderboard Variants    : " + guild.Leaderboards.Count + "\n"
                                  + "Max Warnings            : " + guild.MaxWarnings + "\n"
                                  + "```")
                        .AddField("Guild Statistics",
                                  "```"
                                  + "Users Banned           : " + guild.Cases.Count(x => x.CaseType is CaseType.Ban) + "\n"
                                  + "Users Soft Banned      : " + guild.Cases.Count(x => x.CaseType is CaseType.Softban) + "\n"
                                  + "Users Kicked           : " + guild.Cases.Count(x => x.CaseType is CaseType.Kick) + "\n"
                                  + "Users Warned           : " + guild.Cases.Count(x => x.CaseType is CaseType.Warning) + "\n"
                                  + "Users Muted            : " + guild.Cases.Count(x => x.CaseType is CaseType.Mute) + "\n"
                                  + "Auto Mutes             : " + guild.Cases.Count(x => x.CaseType is CaseType.AutoMute) + "\n"
                                  + "Total Currency Items   : " + guild.CurrencyItems.Count + "\n"
                                  + "Total Shop Items       : " + guild.Shops.Count + "\n"
                                  + "Total Tags             : " + guild.Tags.Count + "\n"
                                  + "Total Mod Cases        : " + guild.Cases.Count + "\n"
                                  + "```");

            await ReplyAsync(embed : embed.Build());
        }
Beispiel #3
0
        /// <summary>
        /// Bot exit function fired when application is closing or ctrl+c is pressed
        /// </summary>
        /// <param name="services"><see cref="IServiceProvider"> to get services from</param>
        private void BotExit(IServiceProvider services)
        {
            var node        = services.GetRequiredService <LavaNode>();
            var embedHelper = services.GetRequiredService <EmbedHelper>();

            foreach (var player in node.Players)
            {
                try
                {
                    node.LeaveAsync(player.VoiceChannel);
                    BotConfig.BotEmbedMessage.ModifyAsync(async(x) =>
                    {
                        x.Content = AudioHelper.NoSongsInQueue;
                        x.Embed   = await EmbedHelper.BuildDefaultEmbed();
                    });
                }
                catch (Exception e)
                {
                    var logging = services.GetRequiredService <LoggingService>();
                    var logger  = logging.Loggers[LoggingService.LoggerEntries.Discord];

                    logger.LogError(e, "");
                }

                BotConfig.BotEmbedMessage.ModifyAsync(async(x) =>
                {
                    x.Content = AudioHelper.NoSongsInQueue;
                    x.Embed   = await EmbedHelper.BuildDefaultEmbed();
                });

                ConfigHelper.UpdateConfigFile(BotConfig);
            }
        }
Beispiel #4
0
        private async Task MessageDeletedAsync(Cacheable <IMessage, ulong> cache, ISocketMessageChannel channel)
        {
            var guild = await _database.Guilds.AsNoTracking().FirstAsync(x => x.GuildId == (channel as SocketGuildChannel).Guild.Id);

            if (!guild.EnableDeletionLog)
            {
                return;
            }

            var message = cache.Value ?? await cache.GetOrDownloadAsync();

            if ((string.IsNullOrWhiteSpace(message.Content) && message.Attachments.Count is 0) || message.Author.IsBot)
            {
                return;
            }

            if (guild.MessageLogChannel is 0)
            {
                return;
            }

            var embed = EmbedHelper.Embed(EmbedHelper.Deleted)
                        .WithAuthor(message.Author)
                        .WithThumbnailUrl((message.Author as SocketUser)?.GetAvatar())
                        .WithTitle("Message Deleted")
                        .AddField("**Channel**:", "#" + message.Channel.Name)
                        .AddField("**Content**:", message.Attachments.FirstOrDefault()?.Url ?? message.Content)
                        .WithCurrentTimestamp()
                        .Build();

            var socketGuild = (message.Author as SocketGuildUser)?.Guild;
            var logChannel  = socketGuild.GetTextChannel(guild.MessageLogChannel);
            await logChannel.SendMessageAsync(embed : embed);
        }
Beispiel #5
0
        private async Task ReadText(string path)
        {
            Logging.Log($"Reading {path} !");
            Embed embed;

            try
            {
                string helpTextStr = File.ReadAllText(path);
                embed = EmbedHelper.BuildEmbedFromText(helpTextStr);
            }
            catch (Exception e)
            {
                Logging.Log($"Error reading {path} !");
                Logging.Log(e);
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> Error supplying help!");

                return;
            }

            try
            {
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}>", embed : embed);
            }
            catch
            {
                Logging.Log($"(!help) I'm muted ;_;");
            }
        }
        public async Task SetPrefix(string prefix)
        {
            //The loading gif :D
            RestUserMessage?loading = null;

            if (!string.IsNullOrEmpty(Client.Config.LoadingGif))
            {
                loading = await Context.Channel.SendFileAsync(Client.Config.LoadingGif);
            }
            //This code is kind of bad but i don't know how to improve it
            var guild = Client.Guilds.First(g => g.Id == Context.Guild.Id);

            guild.Prefix = prefix;
            guild        = DiswordsClient.StaticGuilds.First(g => g.Id == Context.Guild.Id);
            guild.Prefix = prefix;
            var path =
                $"{Client.Config.RootDirectory}{Path.DirectorySeparatorChar}{Client.Config.GuildsDirectoryName}{(Client.Config.GuildsDirectoryName == "" ? "" : Path.DirectorySeparatorChar.ToString())}{guild.Id}.json";

            //Write the new server to the file.
            guild.OverwriteTo(path);
            if (loading != null)
            {
                await loading.DeleteAsync();
            }
            await Context.Channel.SendMessageAsync(null, false, EmbedHelper.BuildSuccess(Locale, Locale.PrefixChanged));
        }
        public async Task Select(string shortName)
        {
            //The requested language was not found.
            if (Client.Languages.All(l => l.ShortName != shortName))
            {
                await Context.Channel.SendMessageAsync(null, false,
                                                       EmbedHelper.BuildError(Locale, string.Format(Locale.InvalidLanguage, shortName)));
            }
            else
            {
                //The loading GIF :D
                RestUserMessage?loading = null;
                if (!string.IsNullOrEmpty(Client.Config.LoadingGif))
                {
                    loading = await Context.Channel.SendFileAsync(Client.Config.LoadingGif);
                }

                var guild = Client.Guilds.First(g => g.Id == Context.Guild.Id);
                guild.Language = shortName;
                var path =
                    $"{Client.Config.RootDirectory}{Path.DirectorySeparatorChar}{Client.Config.GuildsDirectoryName}{(Client.Config.GuildsDirectoryName == "" ? "" : Path.DirectorySeparatorChar.ToString())}{guild.Id}.json";
                //Write the new guild to a file.
                guild.OverwriteTo(path);
                if (loading != null)
                {
                    await loading.DeleteAsync();
                }
                //Send an embed with the new language.
                var newLocale = ILocale.Find(shortName);
                await Context.Channel.SendMessageAsync(null, false,
                                                       EmbedHelper.BuildSuccess(newLocale, newLocale.LanguageChanged));
            }
        }
Beispiel #8
0
        public async Task ShowCharacterAsync(IUser targetUser = null)
        {
            var userInfo  = Context.User;
            var character = targetUser == null
                ? await _charService.GetCharacterAsync(userInfo.Id)
                : await _charService.GetCharacterAsync(targetUser.Id);

            if (character == null)
            {
                await ReplyAsync(string.Format(Messages.ERR_CHAR_NOT_FOUND, userInfo.Mention));

                return;
            }

            var level          = _expService.CalculateLevelForExperience(character.Experience);
            var expToNextLevel = _expService.CalculateRemainingExperienceToNextLevel(character.Experience);

            var description = string.IsNullOrEmpty(character.Description) ? "No description." : character.Description;
            var story       = string.IsNullOrEmpty(character.Story) ? "No story." : character.Story;

            var embed = EmbedHelper.BuildBasicEmbed($"{character.Name}",
                                                    $"**Description:** {description}\n" +
                                                    $"**Story:** ($char story)\n" +
                                                    $"**Level:** {level}\n" +
                                                    $"**Experience:** {character.Experience}\n" +
                                                    $"**To Next Level:** {expToNextLevel}\n" +
                                                    $"**Caps:** {character.Money}");

            await ReplyAsync(userInfo.Mention, embed : embed);
        }
Beispiel #9
0
    public async Task FromDdstatsUrl(string url, [Remainder] string?description = null)
    {
        if (await GetDdstatsResponse(url) is not {
        } ddStatsRun)
        {
            return;
        }

        if (await IsError(!ddStatsRun.GameInfo.Spawnset.Equals("v3", StringComparison.InvariantCultureIgnoreCase), "That's not a V3 run."))
        {
            return;
        }

        Split[] splits = RunAnalyzer.GetData(ddStatsRun);
        if (await IsError(splits.Any(s => s.Value > 1000), "Invalid run: too many homings gained on some splits."))
        {
            return;
        }

        string desc = description ?? $"{ddStatsRun.GameInfo.PlayerName} {ddStatsRun.GameInfo.GameTime:0.0000}";

        (BestSplit[] OldBestSplits, BestSplit[] UpdatedBestSplits)response = await _databaseHelper.UpdateBestSplitsIfNeeded(splits, ddStatsRun, desc);

        if (response.UpdatedBestSplits.Length == 0)
        {
            await InlineReplyAsync("No updates were needed.");

            return;
        }

        Embed updatedRolesEmbed = EmbedHelper.UpdatedSplits(response.OldBestSplits, response.UpdatedBestSplits);

        await ReplyAsync(embed : updatedRolesEmbed, allowedMentions : AllowedMentions.None, messageReference : Context.Message.Reference);
    }
        public async Task BanAsync(
            [Name("User")]
            [Description("The user to ban, can either be @user, user id, or user/nick name (wrapped in quotes if it contains a space)")]
            SocketGuildUser user,
            [Name("Reason")]
            [Description("Reason for the ban")]
            [Remainder] string reason = null)
        {
            if (Context.Guild.HierarchyCheck(user))
            {
                await ReplyAsync(EmoteHelper.Cross + " Oops, clumsy me! *`" + user + "` is higher than I.*");

                return;
            }

            var embed = EmbedHelper.Embed(EmbedHelper.Info)
                        .WithAuthor(Context.User)
                        .WithTitle("Mod Action")
                        .WithDescription("You were banned in the " + Context.Guild.Name + " guild.")
                        .WithThumbnailUrl(Context.User.GetAvatar())
                        .AddField("Reason", reason)
                        .Build();

            await user.TrySendDirectMessageAsync(embed : embed);

            await Context.Guild.AddBanAsync(user, 7, reason);

            await LogCaseAsync(user, CaseType.Ban, reason);

            await ReplyAsync("You are remembered only for the mess you leave behind. *`" + user + "` was banned.* " + EmoteHelper.Hammer);
        }
Beispiel #11
0
        public async void Stop()
        {
            Guild.GamesPlayed++;
            Guild.OverwriteTo(
                $"{_client.Config.RootDirectory}{Path.DirectorySeparatorChar}{_client.Config.GuildsDirectoryName}{(_client.Config.GuildsDirectoryName == "" ? "" : Path.DirectorySeparatorChar.ToString())}{Guild.Id}.json");
            switch (_newChannelCreated)
            {
            case true:
            {
                await Channel.SendMessageAsync(null, false, EmbedHelper.BuildSuccess(Locale, Locale.GameDeleted));

                await Task.Delay(10000);

                await Channel.DeleteAsync();

                _client.Games.Remove(this);
                break;
            }

            case false:
            {
                await Channel.SendMessageAsync(null, false, EmbedHelper.BuildSuccess(Locale, Locale.GameDeleted));

                await Task.Delay(10000);

                await Channel.ModifyAsync(c => c.SlowModeInterval = _previousSlowModeInterval);

                _client.Games.Remove(this);
                break;
            }
            }
        }
        public async Task KickAsync(
            [Name("User")]
            [Description("The user to kick, can either be @user, user id, or user/nick name (wrapped in quotes if it contains a space)")]
            SocketGuildUser user,
            [Name("Reason")]
            [Description("Reason for the kick")]
            [Remainder] string reason = null)
        {
            if (Context.Guild.HierarchyCheck(user))
            {
                await ReplyAsync(EmoteHelper.Cross + " Oops, clumsy me! `" + user + "` is higher than I.");

                return;
            }

            var embed = EmbedHelper.Embed(EmbedHelper.Info)
                        .WithAuthor(Context.User)
                        .WithTitle("Mod Action")
                        .WithDescription("You were kicked in the " + Context.Guild.Name + " guild.")
                        .WithThumbnailUrl(Context.User.GetAvatar())
                        .AddField("Reason", reason)
                        .Build();

            await user.TrySendDirectMessageAsync(embed : embed);

            await user.KickAsync(reason);

            await LogCaseAsync(user, CaseType.Kick, reason);

            await ReplyWithEmoteAsync(EmoteHelper.OkHand);
        }
Beispiel #13
0
        public async Task <RuntimeResult> ChangeGuildIconAsync(Uri url = null)
        {
            if (url == null)
            {
                await ReplyAsync("", embed : EmbedHelper.FromInfo("New icon", "Please upload your new server icon.").Build()).ConfigureAwait(false);

                var response = await InteractiveService.NextMessageAsync(Context, timeout : TimeSpan.FromMinutes(5)).ConfigureAwait(false);

                if (response == null)
                {
                    return(CommandRuntimeResult.FromError("You did not upload your picture in time."));
                }
                if (!Uri.TryCreate(response.Content, UriKind.RelativeOrAbsolute, out url))
                {
                    var attachment = response.Attachments.FirstOrDefault();
                    if (attachment?.Height != null)
                    {
                        url = new Uri(response.Attachments.FirstOrDefault().Url);
                    }
                    else
                    {
                        return(CommandRuntimeResult.FromError("You did not upload any valid pictures."));
                    }
                }
            }
            using (var image = await WebHelper.GetFileStreamAsync(HttpClient, url).ConfigureAwait(false))
            {
                // ReSharper disable once AccessToDisposedClosure
                await Context.Guild.ModifyAsync(x => x.Icon = new Image(image)).ConfigureAwait(false);
            }
            return(CommandRuntimeResult.FromSuccess("The server icon has been changed!"));
        }
Beispiel #14
0
        // This is not the recommended way to write a bot - consider
        // reading over the Commands Framework sample.
        private async Task MessageReceivedAsync(SocketMessage message)
        {
            if (message.Content.ToLower().StartsWith("!ping"))
            {
                await message.Channel.SendMessageAsync("pong!");
            }
            var messageHelper = new MessageHelper(_client, message);

            // The bot should never respond to itself.
            if (message.Author.Id == _client.CurrentUser.Id)
            {
                return;
            }
            Console.WriteLine($"{message.Author.Username} Requested!");

            if (await messageHelper.IsAuthorized())
            {
                if (message.Content.EqualsAnyOf("!help", "!Help", "!HELP"))
                {
                    await message.Channel.SendMessageAsync(embed : EmbedHelper.GetHelp());
                }


                if (message.Content.ToLower().StartsWith("!stats"))
                {
                    await messageHelper.GetStats(message);
                }

                if (message.Content.ToLower().StartsWith("!compare"))
                {
                    await messageHelper.GetStatsCompare(message);
                }
            }
        }
Beispiel #15
0
 public async Task ShowNpcPresetHelpAsync(SocketCommandContext context)
 {
     var userInfo = context.User;
     var embed    = EmbedHelper.BuildBasicEmbedWithFields("Command: $help npc preset", string.Empty,
                                                          Pages.HELP_NPC_PRESETS_PAGE1_TITLES, Pages.HELP_NPC_PRESETS_PAGE1_CONTENTS);
     await context.User.SendMessageAsync(userInfo.Mention, embed : embed);
 }
Beispiel #16
0
        public async Task Create()
        {
            await Context.Channel.SendMessageAsync(Locale.PleaseWait);

            //I consider this a warning because I wouldn't recommend creating a game in general, for example.
            await Context.Channel.SendMessageAsync(null, false,
                                                   EmbedHelper.BuildWarning(Locale,
                                                                            string.Format(Locale.NewChannelWarning, Client.Guilds.First(g => g.Id == Context.Guild.Id).Prefix,
                                                                                          Locale.CreateNew)));

            if (Client.Languages.All(x => x.ShortName != Locale.Name))
            {
                throw new Exception($"Diswords: Language {Locale.Name} was not found.");
            }
            //Change the slow mode interval (delay between sending messages).
            var smi = ((SocketTextChannel)Context.Channel).SlowModeInterval;

            await((SocketTextChannel)Context.Channel).ModifyAsync(c =>
            {
                c.SlowModeInterval = 10;
            });
            //Create the game.
            var game = new Game.Diswords(Client, Context.Message.Author as IGuildUser,
                                         Client.Guilds.First(g => g.Id == Context.Guild.Id), Context.Channel as SocketTextChannel, false, smi,
                                         Client.Languages.First(x => x.ShortName == Locale.Name));
            var word = game.Language.Words[new Random((int)DateTime.Now.Ticks).Next(game.Language.Words.Count)];

            //The bot starts the game, so it sets the word first.
            game.SetWord(word, Client.Client.CurrentUser);
            Client.Games.Add(game);
            await Context.Channel.SendMessageAsync(null, false,
                                                   EmbedHelper.BuildSuccess(Locale, string.Format(Locale.GameCreated, word)));
        }
Beispiel #17
0
        public async Task GetRequiredPermissions(CommandContext ctx)
        {
            string prefix = ctx.Prefix;

            DiscordEmbedBuilder embed = EmbedHelper.CreateEmbed(ctx, "Permissions:", DiscordColor.CornflowerBlue);
            DiscordMember       bot   = await ctx.Guild.GetMemberAsync(ctx.Client.CurrentUser.Id);

            bool manageMessage = bot.HasPermission(Permissions.ManageMessages);
            bool kick          = bot.HasPermission(Permissions.KickMembers);
            bool ban           = bot.HasPermission(Permissions.BanMembers);
            bool manageRoles   = bot.HasPermission(Permissions.ManageRoles);

            var sb = new StringBuilder();

            sb.AppendLine($"`Manage Messages`: {GetStatusEmoji(manageMessage)}\nAffected commands: `{prefix}clear`, " +
                          $"`{prefix}clean`; __error messages will persist if false.__\n");
            sb.AppendLine($"`Manage Roles`: {GetStatusEmoji(manageRoles)}\nAffected commands: `{prefix}role`\n");
            sb.AppendLine($"`Kick Members` {GetStatusEmoji(kick)}\nAffected commands: `{prefix}kick`\n");
            sb.AppendLine($"`Ban Members` {GetStatusEmoji(ban)}\nAffected commands: `{prefix}ban`\n");

            embed.WithTitle("Permissions:");
            embed.WithDescription(sb.ToString());

            await ctx.RespondAsync(embed : embed);
        }
Beispiel #18
0
        public async Task CreateNew()
        {
            await Context.Channel.SendMessageAsync(Locale.PleaseWait);

            if (Client.Languages.All(x => x.ShortName != Locale.Name))
            {
                throw new Exception($"Diswords: Language {Locale.Name} was not found.");
            }
            var channel = await Context.Guild.CreateTextChannelAsync("diswords-" +
                                                                     (Context.Guild.TextChannels.Count(c =>
                                                                                                       c.Name.Contains("diswords")) + 1));

            //Change the slow mode interval (delay between sending messages).
            await channel.ModifyAsync(c => c.SlowModeInterval = 10);

            //Create the game.
            var game = new Game.Diswords(Client, Context.Message.Author as IGuildUser,
                                         Client.Guilds.First(g => g.Id == Context.Guild.Id), channel, true, 0,
                                         Client.Languages.First(x => x.ShortName == Locale.Name));
            var word = game.Language.Words[new Random((int)DateTime.Now.Ticks).Next(game.Language.Words.Count)];

            //The bot starts the game, so it sets the word first.
            game.SetWord(word, Client.Client.CurrentUser);
            Client.Games.Add(game);
            await channel.SendMessageAsync(null, false,
                                           EmbedHelper.BuildSuccess(Locale, string.Format(Locale.GameCreated, word)));

            await Context.Channel.SendMessageAsync(null, false,
                                                   EmbedHelper.BuildSuccess(Locale, $"\n{channel.Mention}"));
        }
Beispiel #19
0
        public async Task GetRequiredPermissions(CommandContext ctx)
        {
            var prefix = SilkBot.Bot.GuildPrefixes[ctx.Guild.Id];
            var embed  = EmbedHelper.CreateEmbed(ctx, "Permissions:", DiscordColor.CornflowerBlue);
            var bot    = await ctx.Guild.GetMemberAsync(ctx.Client.CurrentUser.Id);

            var manageMessage = bot.HasPermission(Permissions.ManageMessages);
            var kick          = bot.HasPermission(Permissions.KickMembers);
            var ban           = bot.HasPermission(Permissions.BanMembers);
            var manageRoles   = bot.HasPermission(Permissions.ManageRoles);

            var sb = new StringBuilder();

            sb.AppendLine($"`Manage Messages`: {(manageMessage ? ":white_check_mark:" : ":x:")}\nAffected commands: `{prefix}clear`, `{prefix}clean`; __error messages will persist if false.__");
            sb.AppendLine($"`Manage Roles`: {(manageRoles ? ":white_check_mark:" : ":x:")}\nAffected commands: {prefix}role");
            sb.AppendLine($"`Kick Members` {(kick ? ":white_check_mark:" : ":x:")}\nAffected commands: {prefix}kick");
            sb.AppendLine($"`Ban Members` {(ban ? ":white_check_mark:" : ":x:")}\nAffected commands: {prefix}ban");

            embed.WithTitle("Permissions:");
            embed.WithDescription(sb.ToString());



            await ctx.RespondAsync(embed : embed);
        }
Beispiel #20
0
        public async Task ShowHighScoresAsync()
        {
            var userInfo = Context.User;
            var charList = await _charService.GetHighScoresAsync();

            var strBuilder = new StringBuilder();

            /*for (var i = 0; i < charList.Count; i++)
             * {
             *  var level = _expService.CalculateLevelForExperience(charList[i].Experience);
             *
             *  strBuilder.Append(
             *      $"**{i + 1}:** {charList[i].FirstName} {charList[i].LastName}" +
             *      $" | Level: {level}" +
             *      $" | Experience: {charList[i].Experience}\n");
             * }
             *
             * var embed = EmbedHelper.BuildBasicEmbed("Command: $highscores", strBuilder.ToString());*/

            var fieldTitlesList   = new List <string>();
            var fieldContentsList = new List <string>();

            for (var i = 0; i < charList.Count; i++)
            {
                var level = _expService.CalculateLevelForExperience(charList[i].Experience);
                fieldTitlesList.Add($"{i + 1}: {charList[i].Name}");
                fieldContentsList.Add($"Level {level} / {charList[i].Experience} XP");
            }

            var embed = EmbedHelper.BuildBasicEmbedWithFields("Command: $hiscores", string.Empty, fieldTitlesList.ToArray(), fieldContentsList.ToArray());

            await ReplyAsync(userInfo.Mention, embed : embed);
        }
Beispiel #21
0
        private async Task MessageReceivedAsync(SocketMessage messageParam)
        {
            // Don't process the command if it was a System Message
            if (!(messageParam is SocketUserMessage message))
            {
                return;
            }
            // Ignore TF2RJweekly messages for now
            if (messageParam.Channel is SocketGuildChannel socketGuildChannel &&
                socketGuildChannel.Guild.Id == 310494288570089472)
            {
                return;
            }
            // Create a number to track where the prefix ends and the command begins
            var commandPosition = 0;

            // Determine if the message is a command, based on if it starts with '!' or a mention prefix
            if (!(message.HasCharPrefix(DiscordConstants.CommandPrefix, ref commandPosition) ||
                  message.HasMentionPrefix(_client.CurrentUser, ref commandPosition)))
            {
                return;
            }

            // Create a Command Context
            var context = new CommandContext(_client, message);
            // Execute the command. (result does not indicate a return value,
            // rather an object stating if the command executed successfully)
            var result = await _commands.ExecuteAsync(context, commandPosition, _services);

            if (result.Error != null && !result.IsSuccess && result.Error.Value != CommandError.UnknownCommand)
            {
                await context.Channel.SendMessageAsync("", embed : EmbedHelper.CreateEmbed(result.ErrorReason, false));
            }
        }
        public async Task StartScriptAsync()
        {
            IUserMessage response;
            EmbedBuilder initialBuilder;


            initialBuilder = EmbedHelper.GetDefaultEmbed(Context);
            initialBuilder.AddField(":robot: Starting idle script", "Please wait...");

            response = await ReplyAsync("", embed : initialBuilder.Build());

            try {
                EmbedBuilder embed;
                Stopwatch    watch;


                watch = new Stopwatch();
                watch.Start();

                embed = EmbedHelper.GetDefaultEmbed(Context);

                _screenshotProvider.Start();

                watch.Stop();

                embed.AddField(":white_check_mark: Success", "The idle script has been started.");
                embed.AddField(":alarm_clock: Time taken to complete action", watch.Elapsed.ToString("mm'm 'ss's 'fff'ms'"));

                await response.ModifyAsync(msg => { msg.Embed = embed.Build(); msg.Content = ""; });
            } catch (Exception e) {
                await response.ModifyAsync(msg => msg = ErrorHandler.GetDefaultErrorMessageEmbed(e, msg, Context.Message));
            }
        }
        public async Task TestLogChannelWorks(CommandContext ctx)
        {
            await ctx.TriggerTypingAsync();

            await Task.Delay(1500);

            await ctx.RespondAsync("Verifying config is set...");

            var embed = EmbedHelper.CreateEmbed(ctx, "", "");

            await Task.Delay(3000);

            ServerConfigurationManager.LocalConfiguration.TryGetValue(ctx.Guild.Id, out var serverConfigurationObject);
            if (serverConfigurationObject is null)
            {
                var newEmbed = new DiscordEmbedBuilder(embed)
                               .WithAuthor(ctx.Member.Nickname ?? ctx.Member.DisplayName, iconUrl: ctx.Member.AvatarUrl)
                               .WithDescription("Server configuration integrety check failed!")
                               .WithColor(DiscordColor.IndianRed);
                await ctx.RespondAsync(embed : newEmbed);
            }
            else
            {
                //var testMessage = await ctx.Client.SendMessageAsync(
                //    await ServerConfig.ReturnChannelFromID(ctx, serverConfigurationObject.LoggingChannel),
                //    "This message is to ensure the integrity of the logging channel set via the `SetLoggingChannelCommand`. `!help SetLoggingChannel` for more information.");
                var newEmbed = new DiscordEmbedBuilder(embed)
                               .WithAuthor(ctx.Member.Nickname ?? ctx.Member.DisplayName, iconUrl: ctx.Member.AvatarUrl)
                               .WithDescription("Server configuration integrety check passed!")
                               .WithColor(DiscordColor.PhthaloGreen);
                await ctx.RespondAsync(embed : newEmbed);
            }
        }
        public async Task GetVersionAsync()
        {
            IUserMessage response;
            EmbedBuilder initialBuilder;


            initialBuilder = EmbedHelper.GetDefaultEmbed(Context);
            initialBuilder.AddField(":robot: Starting bot script", "Please wait...");

            response = await ReplyAsync("", embed : initialBuilder.Build());

            try {
                EmbedBuilder    embed;
                Assembly        assembly;
                FileVersionInfo fileVersionInfo;
                string          version;


                embed           = EmbedHelper.GetDefaultEmbed(Context);
                assembly        = Assembly.GetExecutingAssembly();
                fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
                version         = fileVersionInfo.FileVersion;

                embed.AddField(":cheese: Session Bot Version", version);

                await response.ModifyAsync(msg => { msg.Embed = embed.Build(); msg.Content = ""; });
            } catch (Exception e) {
                await response.ModifyAsync(msg => msg = ErrorHandler.GetDefaultErrorMessageEmbed(e, msg, Context.Message));
            }
        }
Beispiel #25
0
            public async Task <RuntimeResult> ShowCharacterStoryAsync(IUser targetUser = null)
            {
                var userInfo  = Context.User;
                var character = targetUser == null
                    ? await _charService.GetCharacterAsync(userInfo.Id)
                    : await _charService.GetCharacterAsync(targetUser.Id);

                if (character == null)
                {
                    return(CharacterResult.CharacterNotFound());
                }

                if (character.Story == null || character.Story.Equals(""))
                {
                    return(GenericResult.FromError(Messages.ERR_STORY_NOT_FOUND));
                }

                var embed = EmbedHelper.BuildBasicEmbed("Command: $character story",
                                                        $"**Name:** {character.Name}\n" +
                                                        $"**Story:** {character.Story}");

                await ReplyAsync(userInfo.Mention, embed : embed);

                return(GenericResult.FromSilentSuccess());
            }
        public async Task SwitchToDesktopAsync()
        {
            IUserMessage response;
            EmbedBuilder initialBuilder;


            initialBuilder = EmbedHelper.GetDefaultEmbed(Context);
            initialBuilder.AddField(":desktop: Switching to desktop", "Please wait...");

            response = await ReplyAsync("", embed : initialBuilder.Build());

            try {
                ScreenCaptureProvider provider;
                IntPtr       windowHandle;
                EmbedBuilder embed;
                const int    WM_COMMAND = 0x111;
                const int    MIN_ALL    = 419;


                embed        = EmbedHelper.GetDefaultEmbed(Context);
                provider     = new ScreenCaptureProvider(_config);
                windowHandle = User32.GetDesktopWindow();

                IntPtr lHwnd = User32.FindWindow("Shell_TrayWnd", null);
                User32.SendMessage(lHwnd, WM_COMMAND, (IntPtr)MIN_ALL, IntPtr.Zero);

                User32.SetForegroundWindow(windowHandle);

                embed.AddField(":white_check_mark: Success", "The desktop should now be in focus.");

                await response.ModifyAsync(msg => { msg.Embed = embed.Build(); msg.Content = ""; });
            } catch (Exception e) {
                await response.ModifyAsync(msg => msg = ErrorHandler.GetDefaultErrorMessageEmbed(e, msg, Context.Message));
            }
        }
Beispiel #27
0
            public async Task ShowSpecialAsync(IUser targetUser = null)
            {
                var userInfo  = Context.User;
                var character = targetUser == null
                    ? await _charService.GetCharacterAsync(userInfo.Id)
                    : await _charService.GetCharacterAsync(targetUser.Id);

                if (character == null)
                {
                    await ReplyAsync(
                        string.Format(Messages.ERR_CHAR_NOT_FOUND, userInfo.Mention));

                    return;
                }

                if (!_specService.IsSpecialSet(character))
                {
                    await ReplyAsync(
                        string.Format(Messages.ERR_SPECIAL_NOT_FOUND, userInfo.Mention));

                    return;
                }

                var embed = EmbedHelper.BuildBasicEmbed("Command: $character special",
                                                        $"**Name:** {character.Name}\n" +
                                                        $"**STR:** {character.Special.Strength}\n" +
                                                        $"**PER:** {character.Special.Perception}\n" +
                                                        $"**END:** {character.Special.Endurance}\n" +
                                                        $"**CHA:** {character.Special.Charisma}\n" +
                                                        $"**INT:** {character.Special.Intelligence}\n" +
                                                        $"**AGI:** {character.Special.Agility}\n" +
                                                        $"**LUC:** {character.Special.Luck}");

                await ReplyAsync(userInfo.Mention, embed : embed);
            }
        public async Task FindNewSessionAsync()
        {
            IUserMessage response;
            EmbedBuilder initialBuilder;


            initialBuilder = EmbedHelper.GetDefaultEmbed(Context);
            initialBuilder.AddField(":mag: Finding new session", "Please wait...");

            response = await ReplyAsync("", embed : initialBuilder.Build());

            try {
                EmbedBuilder    embed;
                IntPtr          windowHandle;
                ProcessProvider provider;


                embed    = EmbedHelper.GetDefaultEmbed(Context);
                provider = new ProcessProvider();

                embed.AddField(":robot: Stopping bot process", "Please wait...");

                _screenshotProvider.Stop();

                embed.AddField(":white_check_mark: Success", "The bot process has been stopped.");
                embed.AddField(":mag: Finding new session", "Please wait...");

                await response.ModifyAsync(msg => { msg.Embed = embed.Build(); msg.Content = ""; });

                windowHandle = provider.GetGrandTheftAutoProcessPointer();

                User32.GetWindowThreadProcessId(windowHandle, out uint processID);

                if (processID != 0)
                {
                    Process process;


                    process = Process.GetProcessById((int)processID);

                    process.Suspend();
                    Thread.Sleep(8000);
                    process.Resume();
                }


                embed.AddField(":white_check_mark: Success", "A new session has been found.");
                embed.AddField(":robot: Starting bot script", "Please wait");

                await response.ModifyAsync(msg => { msg.Embed = embed.Build(); msg.Content = ""; });

                _screenshotProvider.Start();

                embed.AddField(":white_check_mark: Success", "Bot script started ");

                await response.ModifyAsync(msg => { msg.Embed = embed.Build(); msg.Content = ""; });
            } catch (Exception e) {
                await response.ModifyAsync(msg => msg = ErrorHandler.GetDefaultErrorMessageEmbed(e, msg, Context.Message));
            }
        }
 public Task Lab() => ReplyAsync(embed: EmbedHelper.Embed(EmbedHelper.Info)
                                 .WithTitle("Please turn off any Ad Blockers you have to help the team keep doing Izaros work.")
                                 .WithDescription("[Homepage](https://www.poelab.com/) - [Support](https://www.poelab.com/support/)")
                                 .AddField("Labrynth Info", "[Guide](https://www.poelab.com/new-to-labyrinth/) - [Enchantments](https://www.poelab.com/all-enchantments/)"
                                           + " - [Darkshrines](https://www.poelab.com/hidden-darkshrines/) - [Izaro's Phases](https://www.poelab.com/izaro-phases/) - [Izaro's Attacks](https://www.poelab.com/izaro-weapon-and-attacks/)"
                                           + " - [Traps](https://www.poelab.com/traps_and_trials/) - [Doors & Keys](https://www.poelab.com/doors-and-keys/) - [Puzzles](https://www.poelab.com/gauntlets-puzzles/)"
                                           + " - [Lore](https://www.poelab.com/lore/) - [Tips](https://www.poelab.com/labyrinth-tips/) - [Puzzle Solutions](https://www.poelab.com/puzzle-solutions/)"
                                           + " - [Trial Locations](https://www.poelab.com/trial-locations/) - [Trial Tracker](https://www.poelab.com/trial-tracker/) - [What makes a Good Labyrinth?](https://www.poelab.com/what-makes-a-good-labyrinth/)")
                                 .AddField("Leveling Guides", "[Act 1](https://www.poelab.com/act-1-leveling-guide/) - [Act 2](https://www.poelab.com/act-2-leveling-guide/)"
                                           + " - [Act 3](https://www.poelab.com/act-3-leveling-guide/) - [Act 4](https://www.poelab.com/act-4-leveling-guide/) - [Act 5](https://www.poelab.com/act-5-leveling-guide/)"
                                           + " - [Act 6](https://www.poelab.com/act-6-leveling-guide/) - [Act 7](https://www.poelab.com/act7-leveling-guide/) - [Act 8](https://www.poelab.com/act-8-leveling-guide/)"
                                           + " - [Act 9](https://www.poelab.com/act-9-leveling-guide/) - [Act 10](https://www.poelab.com/act-10-leveling-guide/)")
                                 .AddField("League Cheat sheets", "[Azurite Mine Rooms](https://www.poelab.com/azurite-mine-legend-rooms/) - [Incursion Rooms](https://www.poelab.com/incursion-rooms/)")
                                 .AddField("League Mechanics", "[Incursion](https://www.poelab.com/incursion/)")
                                 .AddField("Endgame Goals", "[Crafting an Item](https://www.poelab.com/crafting-an-item/) - [Road to Uber Elder](https://www.poelab.com/road-to-uber-elder/)"
                                           + " - [Zana and the Map Device](https://www.poelab.com/zana-and-the-map-device/)")
                                 .AddField("Endgame Boss Guides", "[Ahuatotli](https://www.poelab.com/ahuatotli-the-blind/) - [Atziri](https://www.poelab.com/atziri-queen-of-the-vaal/)"
                                           + " - [Aul](https://www.poelab.com/aul-the-crystal-king/) - [Chimera](https://www.poelab.com/guardian-of-the-chimera/) - [Constrictor](https://www.poelab.com/the-constrictor/)"
                                           + " - [Elder](https://www.poelab.com/the-elder/) - [Enslaver](https://www.poelab.com/the-enslaver/) - [Eradicator](https://www.poelab.com/the-eradicator/)"
                                           + " - [Hydra](https://www.poelab.com/guardian-of-the-hydra/) - [Minotaur](https://www.poelab.com/guardian-of-the-minotaur/) - [Phoenix](https://www.poelab.com/guardian-of-the-phoenix/)"
                                           + " - [Purifier](https://www.poelab.com/the-purifier/) - [Shaper](https://www.poelab.com/the-shaper-master-of-the-void/) - [Uber Elder](https://www.poelab.com/the-uber-elder/)"
                                           + " - [Vessel of the Vaal](https://www.poelab.com/the-vessel-of-the-vaals/)")
                                 .AddField("Breach Boss Guides", "[Chayula](https://www.poelab.com/chayula-who-dreamt/) - [Esh](https://www.poelab.com/esh-forked-thought/)"
                                           + " - [Tul](https://www.poelab.com/tul-creeping-avalanche/) - [Uul-Netol](https://www.poelab.com/uul-netol-unburdened-flesh/) - [Xoph](https://www.poelab.com/xoph-dark-embers/)")
                                 .AddField("Misc", "[Defensive Layers](https://www.poelab.com/defensive-layers/) - [Mapping Etique](https://www.poelab.com/mapping-etiquette/)")
                                 .Build());
Beispiel #30
0
        public async Task SoloStats([Remainder] string playersName = null)
        {
            try
            {
                if (playersName == null)
                {
                    await ReplyAsync(Strings.PlayerNameRequired);

                    return;
                }
                var playerRep = new PlayerRepository();
                await playerRep.GetPlayerByName(playersName);

                if (playerRep.Player == null)
                {
                    await ReplyAsync(Strings.PlayerNotFound);

                    return;
                }
                await playerRep.GetPlayerStats();
                await ReplyAsync(embed : EmbedHelper.GetStats($"{playerRep.Player.Name}'s Solo FPP", playerRep.Player.SoloStats, Color.Red));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
        }