Ejemplo n.º 1
0
        private async Task SendEmojiWithName(string name)
        {
            string emoji = name switch
            {
                "sans" => "<a:sans:719488632104288286>",
                "thonk" => "<:thonk:718853430969368637>",
                "mindblowing" => "<:mindblowing:719492411369324584>",
                "rotatethink" => "<a:rotatethonk:719491269885427752>",
                "hyper" => "<a:hyper:719494595313926244>",
                "xd" => "<:xd:719510255402352690>",
                "rainbowcat" => "<a:catrainbow1:719513824511656037><a:catrainbow2:719513824553861121>\n<a:catrainbow3:719513824905920603><a:catrainbow4:719513825040400415>",
                "yes" => "<a:yes:719496630902063149>",
                "no" => "<a:no:719496639471157288>",
                "calculated" => "<:calculated:719518217730654218>",
                _ => "unknown"
            };

            var cxt           = base.Context;
            var webhook       = await((ITextChannel)cxt.Channel).CreateWebhookAsync(((IGuildUser)cxt.User).Nickname ?? cxt.User.Username);
            var webhookClient = new DiscordWebhookClient(webhook);

            await cxt.Channel.DeleteMessageAsync(base.Context.Message);

            await webhookClient.SendMessageAsync(emoji, avatarUrl : cxt.User.GetAvatarUrl());

            await webhookClient.DeleteWebhookAsync();
        }
    }
Ejemplo n.º 2
0
        public async Task Hook([Remainder] string Text)
        {
            await Context.Message.DeleteAsync();

            var webhook = await(Context.Channel as SocketTextChannel).CreateWebhookAsync(Context.Guild.Name);

            using var webhookClient = new DiscordWebhookClient(webhook);
            await webhookClient.SendMessageAsync(Text, false, null, webhook.Name, Context.Guild.IconUrl);

            await webhookClient.DeleteWebhookAsync();
        }
Ejemplo n.º 3
0
        public async Task TestAsync(string command, string name = "Default Name", string msg = "")
        {
            switch (command)
            {
            case "webhook":
                ITextChannel t       = Context.Channel as ITextChannel;
                var          webhook = await t.CreateWebhookAsync(name);

                DiscordWebhookClient w = new DiscordWebhookClient(webhook);
                await w.SendMessageAsync(msg);

                await w.DeleteWebhookAsync();

                await webhook.DeleteAsync();

                break;

            case "box":
                ulong id = 0;
                try
                {
                    ITextChannel here = Context.Channel as ITextChannel;
                    var          iBox = await here.CreateWebhookAsync("Touhou Box");

                    id = iBox.Id;

                    DiscordWebhookClient weeb = new DiscordWebhookClient(iBox);

                    await weeb.ModifyWebhookAsync(x => { x.Image = new Image(GetStreamFromURL("http://img.zeryx.xyz/LewdBoxLogo.jpg")); });

                    await weeb.SendFileAsync(GetStreamFromURL("http://img.zeryx.xyz/lewdboxes/touhou/cir001.png"), "cir001.png", "You got Cirno!");

                    await weeb.DeleteWebhookAsync();

                    break;
                }
                catch (Exception e)
                {
                    Log(e.Message);

                    ITextChannel tempc = Context.Channel as ITextChannel;
                    var          tempw = await tempc.GetWebhookAsync(id);

                    await tempw.DeleteAsync();

                    break;
                }
            }
        }