Exemple #1
0
        public async Task SetPrefix(string prefix)
        {
            SocketGuild target = Context.Guild;

            var serverAccount = ServerAccounts.GetAccount((SocketGuild)target);

            serverAccount.Prefix = prefix;
            ServerAccounts.SaveAccounts();

            var embed = new EmbedBuilder();

            embed.WithTitle($"Prefix changed to `{prefix}` !");
            embed.WithDescription($"You can still use @ModernWarfareStats as the Prefix to execute commands.");
            embed.AddField("Example:", "<@695738324425375805> help");
            embed.WithColor(new Discord.Color(128, 213, 255));
            await Context.Channel.SendMessageAsync("", false, embed.Build());

            var converter         = new HtmlConverter();
            var generationStrings = new HelpGenerationFiles();

            string css   = generationStrings.HelpCss();
            string html  = String.Format(generationStrings.HelpHtml(serverAccount.Prefix));
            int    width = 520;
            var    bytes = converter.FromHtmlString(css + html, width, CoreHtmlToImage.ImageFormat.Png);

            File.WriteAllBytes($"Resources/{Context.Guild.Id}.png", bytes);

            css   = generationStrings.HelpCss();
            html  = String.Format(generationStrings.AdminHelpHtml(serverAccount.Prefix));
            width = 520;
            bytes = converter.FromHtmlString(css + html, width, CoreHtmlToImage.ImageFormat.Png);
            File.WriteAllBytes($"Resources/{Context.Guild.Id}Admin.png", bytes);
        }
Exemple #2
0
        public async Task AdminHelp()
        {
            if (Context.Channel is IDMChannel)
            {
                await Context.Channel.SendMessageAsync($"https://i.imgur.com/6ifbG8t.png");

                return;
            }

            SocketGuild target        = Context.Guild;
            var         serverAccount = ServerAccounts.GetAccount((SocketGuild)target);
            var         prefix        = serverAccount.Prefix;

            if (!File.Exists($"Resources/{Context.Guild.Id}Admin.png"))
            {
                var converter         = new HtmlConverter();
                var generationStrings = new HelpGenerationFiles();

                string css   = generationStrings.HelpCss();
                string html  = String.Format(generationStrings.AdminHelpHtml(prefix));
                int    width = 520;
                var    bytes = converter.FromHtmlString(css + html, width, CoreHtmlToImage.ImageFormat.Png);
                File.WriteAllBytes($"Resources/{Context.Guild.Id}Admin.png", bytes);
            }
            await Context.Channel.SendFileAsync($"Resources/{Context.Guild.Id}Admin.png");
        }