Exemple #1
0
        public async Task WhoIsAsync(CommandContext e)
        {
            if (!e.Arguments.Take(out string arg))
            {
                throw new ArgumentNullException();
            }

            IDiscordGuildUser user = await DiscordExtensions.GetUserAsync(arg, e.Guild);

            //if (user == null)
            //{
            //	user = e.Author as IGuildUser;
            //}

            var embed = e.CreateEmbedBuilder();

            embed.WithTitle("whois_title", user.Username);
            embed.SetColor(0.5f, 0f, 1.0f);

            embed.SetImage(user.GetAvatarUrl());

            var roles = (await e.Guild.GetRolesAsync()).Where(x => user.RoleIds?.Contains(x.Id) ?? false && x.Color.Value != 0).OrderByDescending(x => x.Position);

            Color c = roles.FirstOrDefault()?.Color ?? new Color(0);

            StringBuilder builder = new StringBuilder();

            builder.AppendLine($"User Id      : **{user.Id}**");
            builder.AppendLine(
                $"Username: **{user.Username}#{user.Discriminator} {(string.IsNullOrEmpty((user as IDiscordGuildUser).Nickname) ? "" : $"({(user as IDiscordGuildUser).Nickname})")}**");
            builder.AppendLine($"Created at: **{user.CreatedAt.ToString()}**");
            builder.AppendLine($"Joined at   : **{user.JoinedAt.ToString()}**");
            builder.AppendLine($"Color Hex : **{c.ToString()}**");

            embed.AddField(
                e.CreateResource("miki_module_whois_tag_personal"),
                new RawResource(builder.ToString())
                );

            string r = string.Join(" ", roles.Select(x => x.Name));

            if (string.IsNullOrEmpty(r))
            {
                r = "none (yet!)";
            }

            if (r.Length <= 1000)
            {
                embed.AddField(
                    e.CreateResource("miki_module_general_guildinfo_roles"),
                    new RawResource(r)
                    );
            }

            await embed.Build().QueueToChannelAsync(e.Channel);
        }
Exemple #2
0
        public async Task PrefixHelpAsync(CommandContext e)
        {
            var context = e.GetService <MikiDbContext>();

            await e.CreateEmbedBuilder()
            .WithTitle("miki_module_general_prefix_help_header")
            .WithDescription("prefix_info", await e.EventSystem.GetDefaultPrefixTrigger()
                             .GetForGuildAsync(context, e.GetService <ICacheClient>(), e.Guild.Id))
            .Build().QueueToChannelAsync(e.Channel);
        }
Exemple #3
0
        public async Task GuildBankBalance(CommandContext e, MikiDbContext context, GuildUser c)
        {
            var account = await BankAccount.GetAsync(context, e.Author.Id, e.Guild.Id);

            await e.CreateEmbedBuilder()
            .WithTitle(new LanguageResource("guildbank_title", e.Guild.Name))
            .WithColor(new Color(255, 255, 255))
            .WithThumbnailUrl("https://imgur.com/KXtwIWs.png")
            .AddField(
                new LanguageResource("guildbank_balance_title"),
                new LanguageResource("guildbank_balance", c.Currency.ToFormattedString()),
                true
                )
            .AddField(
                new LanguageResource("guildbank_contributed", "{0}"), new StringResource(account.TotalDeposited.ToFormattedString())
                ).Build().QueueToChannelAsync(e.Channel);
        }
Exemple #4
0
        public async Task PingAsync(CommandContext e)
        {
            (await e.CreateEmbedBuilder()
             .WithTitle(new RawResource("Ping"))
             .WithDescription("ping_placeholder")
             .Build()
             .QueueToChannelAsync(e.Channel))
            .ThenWait(200)
            .Then(async x =>
            {
                float ping         = (float)(x.Timestamp - e.Message.Timestamp).TotalMilliseconds;
                DiscordEmbed embed = new EmbedBuilder()
                                     .SetTitle("Pong - " + Environment.MachineName)
                                     .SetColor(Color.Lerp(new Color(0.0f, 1.0f, 0.0f), new Color(1.0f, 0.0f, 0.0f), Math.Min(ping / 1000, 1f)))
                                     .AddInlineField("Miki", ((int)ping).ToFormattedString() + "ms").ToEmbed();

                await embed.EditAsync(x);
            });
        }
Exemple #5
0
        public async Task GuildBankInfoAsync(CommandContext e)
        {
            var context = e.GetService <MikiDbContext>();

            string prefix = await e.EventSystem
                            .GetDefaultPrefixTrigger()
                            .GetForGuildAsync(context, e.GetService <ICacheClient>(), e.Guild.Id);

            await e.CreateEmbedBuilder()
            .WithTitle(new LanguageResource("guildbank_title", e.Guild.Name))
            .WithDescription(new LanguageResource("guildbank_info_description"))
            .WithColor(new Color(255, 255, 255))
            .WithThumbnailUrl("https://imgur.com/KXtwIWs.png")
            .AddField(
                new LanguageResource("guildbank_info_help"),
                new LanguageResource("guildbank_info_help_description", prefix),
                true
                ).Build().QueueToChannelAsync(e.Channel);
        }