コード例 #1
0
                public async Task ListPlugins(CommandContext context)
                {
                    var builder = new MaterialEmbedBuilder(context.Client);

                    _ = builder.WithTitle(context.Client.CurrentUser.Username + " / Plugins", context.Client.CurrentUser.AvatarUrl);

                    foreach (Base.Plugins.Plugin plugin in Base.PluginLoader.Plugins)
                    {
                        builder.AddListTile("puzzle", $"{plugin.Name} by {plugin.Author}");
                    }

                    _ = await context.Message.RespondAsync(embed : builder.Build());
                }
コード例 #2
0
        public async Task Translate(CommandContext context, string input, string target = "en")
        {
            if (Program.Flags["translate"])
            {
                var result = await Translation.TranslateAsync(input, target);

                var builder = new MaterialEmbedBuilder(context.Client);
                builder.WithTitle("Translator", "translate");
                builder.WithFooter($"Google Translate • {result.SourceLanguage} -> {result.TargetLanguage}", "https://i.imgur.com/hOZBVvU.png");
                builder.WithText(result.TranslatedText);
                await context.RespondAsync(embed : builder.Build());
            }
            else
            {
                await context.RespondAsync("The translation debug flag has not been enabled.");
            }
        }
コード例 #3
0
            public async Task Info(CommandContext context)
            {
                var builder = new MaterialEmbedBuilder(context.Client);

                _ = builder.WithTitle(context.Client.CurrentUser.Username + " / Bot Info", context.Client.CurrentUser.AvatarUrl);

                builder.AddSection(null, "General",
                                   new MaterialEmbedListTile(
                                       "discord",
                                       $"[{await context.GetStringAsync("Bot_Info_DSharpPlusVersion")}](https://github.com/DSharpPlus/DSharpPlus/)",
                                       context.Client.VersionString),

                                   new MaterialEmbedListTile(
                                       "account-star",
                                       await context.GetStringAsync("Bot_Info_Creator"),
                                       "<@!194891941509332992>"),

                                   new MaterialEmbedListTile(
                                       "help-circle",
                                       await context.GetStringAsync("Bot_Info_HelpCommand"),
                                       $"`{context.Prefix}help`")
                                   );

                builder.AddSection(null, await context.GetStringAsync("Bot_Info_Statistics"),
                                   new MaterialEmbedListTile(
                                       "clock-fast",
                                       await context.GetStringAsync("Bot_Info_Uptime"),
                                       (DateTime.UtcNow - Process.GetCurrentProcess().StartTime.ToUniversalTime()).ToConversationalString()),

                                   new MaterialEmbedListTile(
                                       "blank",
                                       await context.GetStringAsync("Bot_Info_Commands"),
                                       context.Client.GetExtension <CommandsNextExtension>().RegisteredCommands.Count.ToString()),

                                   new MaterialEmbedListTile(
                                       "blank",
                                       await context.GetStringAsync("Bot_Info_Servers"),
                                       context.Client.Guilds.Count.ToString())
                                   );

                builder.WithText($"[{"github-circle".GetEmojiString()}](https://github.com/Craftplacer/CraftBot) [{"earth".GetEmojiString()}](https://craftplacer.trexion.com/projects/craftbot)");

                _ = await context.Message.RespondAsync(embed : builder.Build());
            }
コード例 #4
0
            public async Task Info(CommandContext context, DiscordUser user = null)
            {
                if (user == null)
                {
                    user = context.User;
                }

                var builder = new MaterialEmbedBuilder(context.Client);

                builder.WithTitle($"{user.Username} / {await context.GetStringAsync("GeneralTerms_Information")}", user.AvatarUrl);

                builder.AddSection(null, await context.GetStringAsync("User_Info_Identification"),
                                   new MaterialEmbedListTile(
                                       "pencil",
                                       await context.GetStringAsync("User_Info_Username"),
                                       user.Username
                                       ),
                                   new MaterialEmbedListTile(
                                       "pound",
                                       await context.GetStringAsync("User_Info_Discriminator"),
                                       user.Discriminator.ToString()
                                       ),
                                   new MaterialEmbedListTile(
                                       "id",
                                       await context.GetStringAsync("User_Info_Id"),
                                       user.Id.ToString()
                                       )
                                   );

                builder.AddSection(null, await context.GetStringAsync("GeneralTerms_General"),
                                   new MaterialEmbedListTile(
                                       "calendar-plus",
                                       await context.GetStringAsync("User_Info_UserSince_Title"),
                                       string.Format(await context.GetStringAsync("User_Info_UserSince_Value"), user.CreationTimestamp.ToString())
                                       ),
                                   new MaterialEmbedListTile(
                                       user.IsBot,
                                       await context.GetStringAsync("User_Info_IsBot")
                                       ),
                                   user.Verified.HasValue ? new MaterialEmbedListTile(
                                       user.Verified.Value,
                                       await context.GetStringAsync("User_Info_IsVerified")
                                       ) : null
                                   );

                bool isMember = context.Guild.Members.Any(m => m.Value.Id == user.Id);

                if (isMember)
                {
                    DiscordMember member = await context.Guild.GetMemberAsync(user.Id);

                    builder.AddSection(null, await context.GetStringAsync("User_Info_MemberInformation"), !string.IsNullOrWhiteSpace(member.Nickname) ?
                                       new MaterialEmbedListTile(
                                           "pencil",
                                           await context.GetStringAsync("User_Info_Nickname"),
                                           member.Nickname
                                           ) : null,
                                       new MaterialEmbedListTile(
                                           "calendar-plus",
                                           await context.GetStringAsync("User_Info_MemberSince_Title"),
                                           string.Format(await context.GetStringAsync("User_Info_MemberSince_Value"), member.JoinedAt.ToString())
                                           ),
                                       new MaterialEmbedListTile(
                                           member.IsOwner,
                                           await context.GetStringAsync("User_Info_IsOwner")
                                           )
                                       );
                }

                builder.AddSection(null, await context.GetStringAsync("GeneralTerms_BotRelated"),
                                   new MaterialEmbedListTile(
                                       await user.IsQuotingEnabledAsync(),
                                       await context.GetStringAsync("User_Info_Quoting")
                                       ),
                                   new MaterialEmbedListTile(
                                       await user.GetDelayDeletingAsync(),
                                       await context.GetStringAsync("User_Info_DelayDelete")
                                       )
                                   );

                if (user.IsCurrent)
                {
                    builder.WithFooter(await context.GetStringAsync("User_Info_ThatsMe"));
                }

                await context.RespondAsync(embed : builder.Build());
            }