通过Webhook C#发送不和谐嵌入 [英] Send a Discord Embed via Webhook C#
本文介绍了通过Webhook C#发送不和谐嵌入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码,希望通过嵌入式消息发送到不和谐的Webhook:
I have this code that I want to send to a discord webhook via an embedded message:
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);
我应该如何发送?
推荐答案
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();
}
我认为这就是您要寻找的
I think this is what you are looking for
这篇关于通过Webhook C#发送不和谐嵌入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文