Ejemplo n.º 1
0
        public async Task SetTotalShardCount(int shards)
        {
            if (shards <= 0)
            {
                throw new CommandUnsuccessfulException(StringResourceHandler.GetTextStatic("err", "invalidShardCount", shards));
            }
            _config.TotalShards = shards;
            _config.SaveConfig(true);
            _config.ReloadConfig(false);
            await Context.Message.AddReactionAsync(new Emoji("👌"));

            await ReplyAsync($":ok_hand: `{StringResourceHandler.GetTextStatic("Admin", "setShardCount", shards)}`").ConfigureAwait(false);

            LogManager.GetCurrentClassLogger().Info($"Total shard count set to {shards}. Now restarting bot...");
            LogManager.GetCurrentClassLogger().Info(">>RESTARTING");
            _config.SaveConfig(true);
            LogManager.GetCurrentClassLogger().Info("Logging out...");
            await Context.Client.LogoutAsync().ConfigureAwait(false);

            LogManager.GetCurrentClassLogger().Info("Relaunching in 2 seconds...");
            await Task.Delay(2000).ConfigureAwait(false);

            Process.Start(Assembly.GetExecutingAssembly().Location);
            Environment.Exit(0);
        }
Ejemplo n.º 2
0
        public async Task Ban([Summary("User to ban")] IGuildUser target, [Remainder] string reason = null)
        {
            if (target.Id == Context.Message.Author.Id)
            {
                await Context.Message.AddReactionAsync(new Emoji("⛔"));
                await ReplyAsync($":no_entry_sign: `{StringResourceHandler.GetTextStatic("Moderation", "cannotBanSelf")}`").ConfigureAwait(false);

                return;
            }
            try
            {
                var userdm = await target.CreateDMChannelAsync();

                var dmembed = new EmbedBuilder()
                              .WithColor(Color.Red)
                              .WithTitle(StringResourceHandler.GetTextStatic("Moderation", "dm_reason"))
                              .WithDescription(reason ?? StringResourceHandler.GetTextStatic("Moderation", "dm_NoReasonSpecified"))
                              .WithFooter($"{StringResourceHandler.GetTextStatic("Moderation", "dm_by", StringResourceHandler.GetTextStatic("Moderation", "dm_banned"))} @{Context.User.Username}#{Context.User.Discriminator}")
                              .Build();
                await userdm.SendMessageAsync($":anger: {StringResourceHandler.GetTextStatic("Moderation", "dm_ban_header", Context.Guild.Name)}", false, dmembed);
            }
            catch (Exception e)
            {
                await ReplyAsync(":no_entry_sign: " + StringResourceHandler.GetTextStatic("Moderation", "DMFailed", e.Message));
            }
            await Context.Message.AddReactionAsync(new Emoji("🔨"));

            await Context.Guild.AddBanAsync(target, 0, reason).ConfigureAwait(false);

            await ReplyAsync($":hammer: `{StringResourceHandler.GetTextStatic("Moderation", "ban", $"@{target.Username}#{target.Discriminator}")}`").ConfigureAwait(false);
        }
Ejemplo n.º 3
0
        public async Task Fire([Remainder] string target)
        {
            if (target == Context.User.Mention)
            {
                await ReplyAsync(StringResourceHandler.GetTextStatic("DaveFun", "fire_cannotFireYourself"));

                return;
            }
            if (target.ToUpperInvariant() == StringResourceHandler.GetTextStatic("DaveFun", "fire_egg1trigger"))
            {
                await ReplyAsync(StringResourceHandler.GetTextStatic("DaveFun", "fire_easteregg1"));

                return;
            }
            if (target.ToUpperInvariant() == StringResourceHandler.GetTextStatic("DaveFun", "fire_egg2trigger"))
            {
                await ReplyAsync(StringResourceHandler.GetTextStatic("DaveFun", "fire_easteregg2"));

                return;
            }
            if (target.ToUpperInvariant().Contains(Context.Client.CurrentUser.Mention))
            {
                await ReplyAsync(StringResourceHandler.GetTextStatic("DaveFun", "fire_easteregg3"));

                target = Context.User.Mention;
            }
            await ReplyAsync(StringResourceHandler.GetTextStatic("DaveFun", "fire", target.ToUpperInvariant()));
        }
Ejemplo n.º 4
0
        public async Task ReloadConfig()
        {
            await Context.Message.AddReactionAsync(new Emoji("👌"));

            _config.ReloadConfig(true);
            await ReplyAsync($":ok_hand: `{StringResourceHandler.GetTextStatic("Admin", "reloadconfig")}`");
        }
Ejemplo n.º 5
0
        public async Task Ping()
        {
            string pingwaitmsg = StringResourceHandler.GetTextStatic("Utils", "ping_wait");
            var    msg         = await Context.Channel.SendMessageAsync("🏓 " + pingwaitmsg).ConfigureAwait(false);

            var sw = Stopwatch.StartNew();
            await msg.DeleteAsync();

            sw.Stop();
            Random random       = new Random();
            string subtitleText = StringResourceHandler.GetTextStatic("Utils", "ping_subtitle" + random.Next(1, 5));
            string footerText   = StringResourceHandler.GetTextStatic("Utils", "ping_footer1");

            if (sw.ElapsedMilliseconds > 200)
            {
                footerText = StringResourceHandler.GetTextStatic("Utils", "ping_footer2");
            }
            if (sw.ElapsedMilliseconds > 500)
            {
                footerText = StringResourceHandler.GetTextStatic("Utils", "ping_footer3");
            }
            if (sw.ElapsedMilliseconds > 1200)
            {
                footerText = StringResourceHandler.GetTextStatic("Utils", "ping_footer4");
            }
            if (sw.ElapsedMilliseconds > 5000)
            {
                footerText = StringResourceHandler.GetTextStatic("Utils", "ping_footer5");
            }
            await ReplyAsync(Context.User.Mention, false, new EmbedBuilder()
                             .WithTitle("🏓 " + StringResourceHandler.GetTextStatic("Utils", "ping_title"))
                             .WithDescription(subtitleText + '\n' + StringResourceHandler.GetTextStatic("Utils", "ping_pingtime", sw.ElapsedMilliseconds))
                             .WithFooter(footerText)
                             .Build());
        }
Ejemplo n.º 6
0
        public async Task SetStatus([Summary("Status (Online/Idle/DnD/Invisible)")] string status)
        {
            switch (status.ToLowerInvariant())
            {
            case "online":
                await Context.Client.SetStatusAsync(UserStatus.Online);

                break;

            case "idle":
                await Context.Client.SetStatusAsync(UserStatus.Idle);

                break;

            case "dnd":
                await Context.Client.SetStatusAsync(UserStatus.DoNotDisturb);

                break;

            case "invisible":
                await Context.Client.SetStatusAsync(UserStatus.Invisible);

                break;

            default:
                throw new CommandUnsuccessfulException(StringResourceHandler.GetTextStatic("err", "invalidStatus"));
            }
            await Context.Message.AddReactionAsync(new Emoji("👌"));

            await ReplyAsync($":ok_hand: `{StringResourceHandler.GetTextStatic("Admin", "setStatus")}`");
        }
Ejemplo n.º 7
0
        public async Task SetGame(string atype, [Remainder][Summary("Game to show on status")] string game)
        {
            ActivityType acttype;
            string       acttypestring;

            switch (atype.ToLowerInvariant())
            {
            case "playing":
                acttype       = ActivityType.Playing;
                acttypestring = StringResourceHandler.GetTextStatic("Admin", "setGame_playing");
                break;

            case "watching":
                acttype       = ActivityType.Watching;
                acttypestring = StringResourceHandler.GetTextStatic("Admin", "setGame_watching");
                break;

            case "listeningto":
                acttype       = ActivityType.Listening;
                acttypestring = StringResourceHandler.GetTextStatic("Admin", "setGame_listeningTo");
                break;

            default:
                throw new CommandUnsuccessfulException(StringResourceHandler.GetTextStatic("err", "invalidActivityType"));
            }
            await Context.Client.SetGameAsync(game, null, acttype).ConfigureAwait(false);

            await Context.Message.AddReactionAsync(new Emoji("👌"));

            await ReplyAsync($":ok: `{StringResourceHandler.GetTextStatic("Admin", "setGame", game, acttypestring)}`").ConfigureAwait(false);
        }
Ejemplo n.º 8
0
        public async Task ListCustomReactions()
        {
            string desc = "";

            foreach (var cr in Program.CustomReactions)
            {
                desc += "• " + cr.Key + '\n';
            }
            if (Program.CustomReactions.Count == 0)
            {
                desc += StringResourceHandler.GetTextStatic("CustomReactions", "lcr_noCustomReactions");
            }
            else if (Program.CustomReactions.Count == 1)
            {
                desc += StringResourceHandler.GetTextStatic("CustomReactions", "lcr_TotalCountOne");
            }
            else
            {
                desc += StringResourceHandler.GetTextStatic("CustomReactions", "lcr_TotalCountMultiple", Program.CustomReactions.Count);
            }
            EmbedBuilder eb = new EmbedBuilder()
                              .WithTitle(StringResourceHandler.GetTextStatic("CustomReactions", "ListCustomReactions"))
                              .WithDescription(desc)
                              .WithColor(Color.Green);

            await ReplyAsync(Context.Message.Author.Mention, false, eb.Build());
        }
Ejemplo n.º 9
0
        public async Task Commands(string modulename)
        {
            ModuleInfo targetmodule = null;

            foreach (var module in Program._commands.Modules)
            {
                if (module.Name.ToLower() == modulename.ToLower())
                {
                    targetmodule = module;
                }
            }
            if (targetmodule == null)
            {
                await ReplyAsync($":no_entry: `{StringResourceHandler.GetTextStatic("err", "nonexistentModule")}`");
            }
            else
            {
                var commandseb = new EmbedBuilder().WithTitle(StringResourceHandler.GetTextStatic("Help", "commands_header", targetmodule.Name)).WithColor(Color.Orange);
                if (targetmodule.Commands.Count > 0)
                {
                    foreach (var command in targetmodule.Commands)
                    {
                        commandseb.AddField("» " + Program.prefix + command.Name, command.Summary);
                    }
                }
                else
                {
                    commandseb.WithDescription(StringResourceHandler.GetTextStatic("Help", "commandListEmpty"));
                }
                await ReplyAsync(Context.User.Mention, false, commandseb.Build());
            }
        }
Ejemplo n.º 10
0
        public async Task HelpCmd()
        {
            var dmchannel = await Context.User.GetOrCreateDMChannelAsync();

            string dmcontent = StringResourceHandler.GetTextStatic("Help", "DMContent", Program.prefix,
                                                                   (Program.botName == "PaletteBot")? //I did have some compiler flags to switch out the two strings when it was a PublicRelease build, but they didn't work, so I removed them before I committed this change
                                                                   StringResourceHandler.GetTextStatic("Help", "introPublic")
                :
                                                                   StringResourceHandler.GetTextStatic("Help", "intro", Program.botName)

                                                                   );

            if (Program.OwnerID == 0)
            {
                dmcontent += StringResourceHandler.GetTextStatic("Help", "DMContentNoBotOwner");
            }
            else
            {
                dmcontent += StringResourceHandler.GetTextStatic("Help", "DMContentContactBotOwner", Context.Client.GetUser(Program.OwnerID).Mention, Context.Client.GetUser(Program.OwnerID).Username, Context.Client.GetUser(Program.OwnerID).Discriminator);
            }
            await dmchannel.SendMessageAsync(dmcontent);

            if (!Context.IsPrivate)
            {
                await ReplyAsync(StringResourceHandler.GetTextStatic("Help", "DMedHelp"));
            }
        }
Ejemplo n.º 11
0
 public async Task <bool> TryExecuteEarly(DiscordSocketClient client, IGuild guild, IUserMessage msg)
 {
     if (msg.Content.StartsWith(client.CurrentUser.Mention) && IsCleverbotChannel(msg.Channel))
     {
         await msg.Channel.SendMessageAsync($":speech_balloon: `{StringResourceHandler.GetTextStatic("Fun", "cleverbot_comingSoon")}`");
     }
     return(false);
 }
Ejemplo n.º 12
0
 public async Task Invite()
 {
     /*await ReplyAsync($"{Context.User.Mention} - {StringResourceHandler.GetTextStatic("Utils", "invite")}", false, new EmbedBuilder()
      *  .WithTitle("Invite PaletteBot onto your own server!")
      *  .WithUrl($"https://discordapp.com/oauth2/authorize?client_id={Context.Client.CurrentUser.Id}&permissions=8&scope=bot")
      *  .Build());*/
     await ReplyAsync($"{Context.User.Mention} - {StringResourceHandler.GetTextStatic("Utils", "invite")} https://discordapp.com/oauth2/authorize?client_id={Context.Client.CurrentUser.Id}&permissions=8&scope=bot");
 }
Ejemplo n.º 13
0
 public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
 {
     if (context.Channel == null)
     {
         return(Task.FromResult(PreconditionResult.FromError(StringResourceHandler.GetTextStatic("err", "unavailableInDMs"))));
     }
     return(Task.FromResult(PreconditionResult.FromSuccess()));
 }
Ejemplo n.º 14
0
        public async Task GodClean([Remainder] string target)
        {
            await ReplyAsync(StringResourceHandler.GetTextStatic("DaveFun", "clean", target));

            if (target.Contains(Context.Client.CurrentUser.Mention))
            {
                await ReplyAsync(StringResourceHandler.GetTextStatic("DaveFun", "clean_easterEgg1"));
            }
        }
Ejemplo n.º 15
0
        public async Task CrotchKick([Remainder] string target)
        {
            await ReplyAsync(StringResourceHandler.GetTextStatic("DaveFun", "crotchkick", target));

            if (target.Contains(Context.Client.CurrentUser.Mention))
            {
                await ReplyAsync(StringResourceHandler.GetTextStatic("DaveFun", "crotchkick_kickedSelf"));
            }
        }
Ejemplo n.º 16
0
        public async Task GuildInfo()
        {
            var featureList = StringResourceHandler.GetTextStatic("Utils", "sinfo_noFeatures");

            // old code which doesn't work with D.NET 3

            /*if(Context.Guild.Features.Count > 0)
             * {
             *  featureList = Context.Guild.Features.Aggregate("", (current, feature) => current + ("• " + feature + '\n'));
             * }*/
            featureList = "NOT YET IMPLEMENTED";
            var inviteLinks = await Context.Guild.GetInvitesAsync().ConfigureAwait(false);

            var userCount = 0;
            var botCount  = 0;

            foreach (var user in Context.Guild.Users)
            {
                if (user.IsBot)
                {
                    botCount++;
                }
                else
                {
                    userCount++;
                }
            }
            var vl  = Context.Guild.VerificationLevel;
            var vli = vl switch
            {
                VerificationLevel.Low => 1,
                VerificationLevel.Medium => 2,
                VerificationLevel.High => 3,
                VerificationLevel.Extreme => 4,
                _ => 0
            };

            await ReplyAsync(Context.User.Mention, false, new EmbedBuilder()
                             .WithTitle(Context.Guild.Name)
                             .AddField(StringResourceHandler.GetTextStatic("Utils", "sinfo_id"), Context.Guild.Id, true)
                             .AddField(StringResourceHandler.GetTextStatic("Utils", "sinfo_created"), Context.Guild.CreatedAt, true)
                             .AddField(StringResourceHandler.GetTextStatic("Utils", "sinfo_owner"), $"@{Context.Guild.Owner.Username}#{Context.Guild.Owner.Discriminator} ({Context.Guild.Owner.Id})", true)
                             .AddField(StringResourceHandler.GetTextStatic("Utils", "sinfo_users"), $"{Context.Guild.MemberCount} {StringResourceHandler.GetTextStatic("Utils", "sinfo_userbotratio",userCount,botCount)}", true)
                             .AddField(StringResourceHandler.GetTextStatic("Utils", "sinfo_categories"), Context.Guild.CategoryChannels.Count, true)
                             .AddField(StringResourceHandler.GetTextStatic("Utils", "sinfo_textchannels"), Context.Guild.TextChannels.Count, true)
                             .AddField(StringResourceHandler.GetTextStatic("Utils", "sinfo_voicechannels"), Context.Guild.VoiceChannels.Count, true)
                             .AddField(StringResourceHandler.GetTextStatic("Utils", "sinfo_roles"), Context.Guild.Roles.Count, true)
                             .AddField(StringResourceHandler.GetTextStatic("Utils", "sinfo_verificationlevel"), StringResourceHandler.GetTextStatic("Utils", $"sinfo_verificationlevel_{vli}"), true)
                             .AddField(StringResourceHandler.GetTextStatic("Utils", "sinfo_features"), featureList, true)
                             .AddField(StringResourceHandler.GetTextStatic("Utils", "sinfo_invites"), inviteLinks.Count, true)
                             .AddField(StringResourceHandler.GetTextStatic("Utils", "sinfo_customemotes"), Context.Guild.Emotes.Count, true)
                             .WithThumbnailUrl(Context.Guild.IconUrl)
                             .WithColor(Color.Blue)
                             .Build());
        }
    }
Ejemplo n.º 17
0
        public async Task EightBall([Remainder][Summary("The question")] string question)
        {
            Random random = new Random();
            string answer = EightBallResponses[random.Next(EightBallResponses.Length)];

            await ReplyAsync("", false, new EmbedBuilder()
                             .AddField($":question: {StringResourceHandler.GetTextStatic("Fun", "8ball_question")}", question)
                             .AddField($":8ball: {StringResourceHandler.GetTextStatic("Fun", "8ball_answer")}", answer)
                             .Build());
        }
Ejemplo n.º 18
0
        public async Task Modules()
        {
            var moduleseb = new EmbedBuilder().WithTitle(StringResourceHandler.GetTextStatic("Help", "modules_header")).WithColor(Color.Orange);

            foreach (var module in Program._commands.Modules)
            {
                moduleseb.AddField("» " + module.Name, StringResourceHandler.GetTextStatic("Help", "modules_commandcount", module.Commands.Count));
            }
            await ReplyAsync(Context.User.Mention, false, moduleseb.Build());
            await ReplyAsync("", false, new EmbedBuilder().WithDescription(StringResourceHandler.GetTextStatic("Help", "modules_moreInfo", Program.prefix)).WithColor(Color.Orange).Build());
        }
Ejemplo n.º 19
0
        private async Task HandleCommandAsync(SocketMessage messageParam)
        {
            // Don't process the command if it was a System Message
            var message = messageParam as SocketUserMessage;

            if (message == null)
            {
                return;
            }
            // Create a number to track where the prefix ends and the command begins
            int argPos = 0;

            if (!(message.HasStringPrefix(prefix, ref argPos)))
            {
                return;
            }
            // Create a Command Context

            var context = new SocketCommandContext(_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, argPos, _services);

            if (!result.IsSuccess)
            {
                string errtext;
                switch (result.Error)
                {
                case CommandError.UnknownCommand:
                    errtext = StringResourceHandler.GetTextStatic("err", "unknownCommand");
                    break;

                case CommandError.UnmetPrecondition:
                    errtext = StringResourceHandler.GetTextStatic("err", "unmetPrecondition");
                    break;

                case CommandError.MultipleMatches:
                    errtext = StringResourceHandler.GetTextStatic("err", "multipleCommandDefs");
                    break;

                case CommandError.Exception:
                    errtext = StringResourceHandler.GetTextStatic("err", "exception", result.ErrorReason);
                    break;

                default:
                    errtext = result.ErrorReason;
                    break;
                }
                await context.Channel.SendMessageAsync($":no_entry: `{errtext}`");
            }
        }
Ejemplo n.º 20
0
        public async Task Ship([Remainder][Summary("Two targets, separated by `;`")] string targets)
        {
            var args = targets.Split(';');

            if (args.Length == 2)
            {
                await Context.Message.AddReactionAsync(new Emoji("❤"));

                var msg = await ReplyAsync(StringResourceHandler.GetTextStatic("generic", "PleaseWait")).ConfigureAwait(false);

                var tstate      = Context.Channel.EnterTypingState();
                var percentage  = MatchmakingLogic.CalculateMatchmakingPercentage(args[0], args[1]);
                var commenttext = percentage == 100
                    ? StringResourceHandler.GetTextStatic("Fun", "ship_result_8")
                    : percentage > 85
                    ? StringResourceHandler.GetTextStatic("Fun", "ship_result_7")
                    : percentage > 70
                    ? StringResourceHandler.GetTextStatic("Fun", "ship_result_6")
                    : percentage > 55
                    ? StringResourceHandler.GetTextStatic("Fun", "ship_result_5")
                    : percentage > 40
                    ? StringResourceHandler.GetTextStatic("Fun", "ship_result_4")
                    : percentage > 25
                    ? StringResourceHandler.GetTextStatic("Fun", "ship_result_3")
                    : percentage > 10
                    ? StringResourceHandler.GetTextStatic("Fun", "ship_result_2")
                    : percentage > 0
                    ? StringResourceHandler.GetTextStatic("Fun", "ship_result_1")
                    : StringResourceHandler.GetTextStatic("Fun", "ship_result_0");
                if (percentage == 69) // Lenny Face
                {
                    commenttext = StringResourceHandler.GetTextStatic("Fun", "ship_result_9");
                }
                tstate.Dispose();
                await msg.DeleteAsync().ConfigureAwait(false);

                var progressbar = MatchmakingLogic.GenerateProgressBar(percentage, 100, 10);

                var resultembed = new EmbedBuilder()
                                  .WithColor(Color.Magenta)
                                  .AddField(StringResourceHandler.GetTextStatic("Fun", "ship_compatibility"), $"**{percentage}%** `{progressbar}` {commenttext}")
                                  .Build();
                await ReplyAsync($"{StringResourceHandler.GetTextStatic("Fun", "ship_title")}\n{args[0]} :x: {args[1]}", false, resultembed);
            }
            else
            {
                await Context.Message.AddReactionAsync(new Emoji("⛔"));
                await ReplyAsync($":no_entry: `{StringResourceHandler.GetTextStatic("Fun", "ship_incorrectNumOfArgs")}`").ConfigureAwait(false);
            }
        }
Ejemplo n.º 21
0
        public async Task Commands([Remainder] string modulename)
        {
            ModuleInfo targetmodule = null;

            foreach (ModuleInfo module in _cs.Modules)
            {
                if (module.Name.ToLower() == modulename.ToLower())
                {
                    targetmodule = module;
                }
            }
            if ((targetmodule == null) || (targetmodule.IsSubmodule))
            {
                throw new CommandUnsuccessfulException(StringResourceHandler.GetTextStatic("err", "nonexistentModule"));
            }
            else
            {
                EmbedBuilder commandseb = new EmbedBuilder().WithTitle(StringResourceHandler.GetTextStatic("Help", "commands_header", targetmodule.Name)).WithColor(Color.Orange);
                if (targetmodule.Commands.Count > 0)
                {
                    foreach (var command in targetmodule.Commands)
                    {
                        commandseb.AddField("» " + _config.DefaultPrefix + command.Name, command.Summary);
                    }
                }
                else
                {
                    if (targetmodule.Submodules.Count == 0)
                    {
                        commandseb.WithDescription(StringResourceHandler.GetTextStatic("Help", "commandListEmpty"));
                    }
                }
                foreach (ModuleInfo submodule in targetmodule.Submodules)
                {
                    if (submodule.Commands.Count > 0)
                    {
                        foreach (var command in submodule.Commands)
                        {
                            commandseb.AddField("» " + _config.DefaultPrefix + command.Name, command.Summary);
                        }
                    }
                    else
                    {
                        commandseb.WithDescription(StringResourceHandler.GetTextStatic("Help", "commandListEmpty"));
                    }
                }
                await ReplyAsync(Context.User.Mention, false, commandseb.Build());
            }
        }
Ejemplo n.º 22
0
        public async Task ToggleVerboseErrors()
        {
            await Context.Message.AddReactionAsync(new Emoji("👌"));

            _config.VerboseErrors = !_config.VerboseErrors;
            _config.SaveConfig(true);
            _config.ReloadConfig(false);
            var toCueUp = "verboseErrors_disable";

            if (_config.VerboseErrors)
            {
                toCueUp = "verboseErrors_enable";
            }
            await ReplyAsync($":ok_hand: `{StringResourceHandler.GetTextStatic("Admin", toCueUp)}`").ConfigureAwait(false);
        }
Ejemplo n.º 23
0
        public async Task EightBall([Remainder][Summary("The question")] string question)
        {
            await Context.Message.AddReactionAsync(new Emoji("🎱"));

            DaveRNG random = new DaveRNG();
            string  answer = (_config.EightBallResponses.Length > 0)?
                             _config.EightBallResponses[random.Next(_config.EightBallResponses.Length)]:
                             DefaultEightBallResponses[random.Next(DefaultEightBallResponses.Length)];

            await ReplyAsync("", false, new EmbedBuilder()
                             .AddField($":question: {StringResourceHandler.GetTextStatic("Fun", "8ball_question")}", question)
                             .AddField($":8ball: {StringResourceHandler.GetTextStatic("Fun", "8ball_answer")}", answer)
                             .WithColor(Color.Blue)
                             .Build());
        }
Ejemplo n.º 24
0
        public async Task Stats()
        {
            TimeSpan uptime = new TimeSpan(DateTime.Now.Ticks - Program.StartTime.Ticks);

            await ReplyAsync(Context.User.Mention, false, new EmbedBuilder()
                             .WithTitle(StringResourceHandler.GetTextStatic("Utils", "stats_title"))
                             .WithDescription((Program.botName == "PaletteBot") ?
                                              StringResourceHandler.GetTextStatic("Utils", "stats_descriptionPublic")
                :
                                              StringResourceHandler.GetTextStatic("Utils", "stats_description", Program.botName))
                             .WithAuthor($"{Context.Client.CurrentUser.Username} v{typeof(Program).Assembly.GetName().Version}", Context.Client.CurrentUser.GetAvatarUrl())
                             .AddField(StringResourceHandler.GetTextStatic("Utils", "stats_guilds"), Context.Client.Guilds.Count, true)
                             .AddField(StringResourceHandler.GetTextStatic("Utils", "stats_uptime"), uptime.ToString(), true)
                             .Build());
        }
Ejemplo n.º 25
0
        public async Task ShowCustomReaction([Remainder][Summary("Custom reaction to view")] string ikey)
        {
            int          matches  = 0;
            string       inputkey = ikey.Trim().ToLower();
            EmbedBuilder eb       = new EmbedBuilder();

            foreach (var cr in Program.CustomReactions)
            {
                if (cr.Key.Trim().ToLower().Equals(inputkey))
                {
                    string desc    = "";
                    string title   = cr.Key;
                    int    respnum = 1;
                    foreach (var response in cr.Value.ToArray())
                    {
                        desc += $"***{StringResourceHandler.GetTextStatic("CustomReactions", "response", respnum)}*** {response}\n";
                        respnum++;
                    }
                    desc = desc.Trim();
                    if (matches > 0)
                    {
                        title += $" ({matches})";
                    }
                    eb.AddField(title, desc);
                    matches++;
                }
            }
            if (matches == 0)
            {
                eb.WithTitle(StringResourceHandler.GetTextStatic("CustomReactions", "ShowCustomReaction_noResults"))
                .WithDescription(StringResourceHandler.GetTextStatic("CustomReactions", "ShowCustomReaction_noResults_desc", ikey))
                .WithColor(Color.Red);
            }
            else
            {
                eb.WithColor(Color.Green);
                if (matches > 1)
                {
                    eb.WithTitle(StringResourceHandler.GetTextStatic("CustomReactions", "ShowCustomReaction_multipleResults"));
                }
                else
                {
                    eb.WithTitle(StringResourceHandler.GetTextStatic("CustomReactions", "ShowCustomReaction"));
                }
            }
            await ReplyAsync(Context.Message.Author.Mention, false, eb.Build());
        }
Ejemplo n.º 26
0
        public async Task ListCustomReactions()
        {
            if (_config.EnableCustomReactions)
            {
                var    pleasewait = Context.Channel.EnterTypingState();
                string desc       = "";
                int    crcount    = 1;
                foreach (var cr in _config.CustomReactions)
                {
                    if (desc.Length < 800)
                    {
                        desc += "• " + cr.Key + '\n';
                    }
                    else
                    {
                        desc += StringResourceHandler.GetTextStatic("CustomReactions", "ShowCustomReaction_more", cr.Value.Count - crcount);
                        break;
                    }
                    crcount++;
                }
                if (_config.CustomReactions.Count == 0)
                {
                    desc += StringResourceHandler.GetTextStatic("CustomReactions", "lcr_noCustomReactions");
                }
                else if (_config.CustomReactions.Count == 1)
                {
                    desc += StringResourceHandler.GetTextStatic("CustomReactions", "lcr_TotalCountOne");
                }
                else
                {
                    desc += StringResourceHandler.GetTextStatic("CustomReactions", "lcr_TotalCountMultiple", _config.CustomReactions.Count);
                }
                EmbedBuilder eb = new EmbedBuilder()
                                  .WithTitle("📃 " + StringResourceHandler.GetTextStatic("CustomReactions", "ListCustomReactions"))
                                  .WithDescription(desc)
                                  .WithColor(Color.Green);
                await Context.Message.AddReactionAsync(new Emoji("📃"));

                pleasewait.Dispose();
                await ReplyAsync(Context.Message.Author.Mention, false, eb.Build());
            }
            else
            {
                await Context.Message.AddReactionAsync(new Emoji("⛔"));
                await ReplyAsync($":no_entry: `{StringResourceHandler.GetTextStatic("CustomReactions", "disabled")}`").ConfigureAwait(false);
            }
        }
Ejemplo n.º 27
0
        public async Task SetStatus([Summary("Status (Online/Idle/DnD/Invisible)")] string status)
        {
            LogManager.GetCurrentClassLogger().Debug($"Owner ID is \"{Program.OwnerID}\"; author ID is \"{Context.Message.Author.Id.ToString()}\"");
            if (Program.OwnerID == 0) //TODO: Make this check a precondition rather than an in-command hardcoded check
            {
                await ReplyAsync($":no_entry: `{StringResourceHandler.GetTextStatic("err", "noBotOwner")}`");
            }
            else
            {
                if (Program.OwnerID != Context.Message.Author.Id)
                {
                    await ReplyAsync($":no_entry: `{StringResourceHandler.GetTextStatic("err", "notBotOwner")}`");
                }
                else
                {
                    switch (status.ToLower())
                    {
                    case "online":
                        await Context.Client.SetStatusAsync(UserStatus.Online);

                        break;

                    case "idle":
                        await Context.Client.SetStatusAsync(UserStatus.Idle);

                        break;

                    case "dnd":
                        await Context.Client.SetStatusAsync(UserStatus.DoNotDisturb);

                        break;

                    case "invisible":
                        await Context.Client.SetStatusAsync(UserStatus.Invisible);

                        break;

                    default:
                        await ReplyAsync($":no_entry: `{StringResourceHandler.GetTextStatic("err", "invalidStatus")}`");

                        return;
                    }
                    await ReplyAsync($":ok: `{StringResourceHandler.GetTextStatic("Admin", "setStatus")}`").ConfigureAwait(false);
                }
            }
        }
Ejemplo n.º 28
0
        public async Task Modules()
        {
            EmbedBuilder             moduleseb  = new EmbedBuilder().WithTitle(StringResourceHandler.GetTextStatic("Help", "modules_header")).WithColor(Color.Orange);
            IEnumerable <ModuleInfo> moduleList = _cs.Modules;

            foreach (ModuleInfo module in moduleList)
            {
                if (!module.IsSubmodule)
                {
                    moduleseb.AddField("» " + module.Name, (module.Commands.Count > 0) ?
                                       StringResourceHandler.GetTextStatic("Help", "modules_commandcount", module.Commands.Count)
                    :
                                       StringResourceHandler.GetTextStatic("Help", "modules_emptymodule"));
                }
            }
            await ReplyAsync(Context.User.Mention, false, moduleseb.Build());
            await ReplyAsync("", false, new EmbedBuilder().WithDescription(StringResourceHandler.GetTextStatic("Help", "modules_moreInfo", _config.DefaultPrefix)).WithColor(Color.Orange).Build());
        }
Ejemplo n.º 29
0
        public async Task Ban([Summary("User to ban")] IUser target)
        {
            //TODO: Make sure this works properly
            await Context.Guild.AddBanAsync(target);

            await ReplyAsync($":ok: `{StringResourceHandler.GetTextStatic("Moderation", "ban", $"@{target.Username}#{target.Discriminator}")}`").ConfigureAwait(false);

            try
            {
                var userdm = await target.GetOrCreateDMChannelAsync();

                await userdm.SendMessageAsync($":anger: {StringResourceHandler.GetTextStatic("Moderation", "dm_ban_header")}");
            }
            catch (Exception e)
            {
                await ReplyAsync(StringResourceHandler.GetTextStatic("Moderation", "DMFailed", e.Message));
            }
        }
Ejemplo n.º 30
0
        public async Task Shutdown(bool SaveChanges = true)
        {
            await Context.Message.AddReactionAsync(new Emoji("👋"));

            await ReplyAsync($":ok_hand: `{StringResourceHandler.GetTextStatic("Admin", "shutdown")}`").ConfigureAwait(false);

            LogManager.GetCurrentClassLogger().Info(">>SHUTTING DOWN");
            if (SaveChanges)
            {
                _config.SaveConfig(true);
            }
            LogManager.GetCurrentClassLogger().Info("Logging out...");
            await Context.Client.LogoutAsync().ConfigureAwait(false);

            LogManager.GetCurrentClassLogger().Info("The bot is now DOWN!");
            await Task.Delay(2000).ConfigureAwait(false);

            Environment.Exit(0);
        }