通过Webhook C#发送不和谐嵌入

时间:2019-12-18 19:20:20

标签: c# .net wpf discord discord.net

我有以下代码,希望通过嵌入式消息发送到不和谐的Webhook:

var builder = new EmbedBuilder();

builder.WithTitle("Ice Wizard Stats");
builder.AddField("Hit Speed", "1.5sec", true); // True for inline
builder.WithThumbnailUrl("https://i.ibb.co/rc66Lq8/logonew.png");
builder.WithColor(Color.Red);

我应该如何发送?

1 个答案:

答案 0 :(得分:0)

public class dWebHook: IDisposable
    {
        private readonly WebClient dWebClient;
        private static NameValueCollection discord = new NameValueCollection();
        public string WebHook { get; set;}
        public string UserName { get; set; }
        public string ProfilePicture { get; set;}

        public dWebHook()
        {
            dWebClient = new WebClient();
        }


        public void SendMessage(string msgSend)
        {
            discord.Add("username", UserName);
            discord.Add("avatar_url", ProfilePicture);
            discord.Add("content", msgSend);

            dWebClient.UploadValues(WebHook, discord);
        }

        public void Dispose()
        {
            dWebClient.Dispose();
        }

我认为这就是您要寻找的