c#发送discord webhook

时间:2018-05-28 22:44:00

标签: c# discord

有谁知道我如何将用户的所有数据发送到不和谐的webhook消息?

所以我的代码是这样的:

        private void materialSingleLineTextField1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Enter)
        {
            userName = materialSingleLineTextField1.Text;
            rapcount(userName);
            materialLabel2.Text = "Username: " + materialSingleLineTextField1.Text;

            var client = new WebClient();

            var text = client.DownloadString("https://api.roblox.com/users/get-by-username?username=" + materialSingleLineTextField1.Text);

            Post post = JsonConvert.DeserializeObject<Post>(text);

            Id = post.Id;

            materialLabel3.Text = "ID: " + post.Id;
            materialLabel4.Text = "Online: " + post.IsOnline;

            var request = WebRequest.Create("https://www.roblox.com/headshot-thumbnail/image?userId=" + Id + "&width=420&height=420&format=png");

            using (var response = request.GetResponse())
            using (var stream = response.GetResponseStream())
            {
                pictureBox1.Image = Bitmap.FromStream(stream);
            }

            //https://discordapp.com/api/webhooks/450790622446485525/HW8nYfZ39J0VPKDcxEuLoYpwVbBt8qxF4uM1SMJGp8WXIlZ33jlqzSvMThM7rSoxJUJU

            materialSingleLineTextField1.Text = "";
        }
    }

我希望将用户名和ID作为消息发送。请帮忙&lt; 3

1 个答案:

答案 0 :(得分:0)

嗯,我刚从别人那里得到这个 类 Link 代码

using (dWebHook dcWeb = new dWebHook())
{
     dcWeb.ProfilePicture = "https://static.giantbomb.com/uploads/original/4/42381/1196379-gas_mask_respirator.jpg";
     dcWeb.UserName = "Bot";
     dcWeb.WebHook = webHook;
     dcWeb.SendMessage("Hello");
}