-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
129 lines (119 loc) · 4.91 KB
/
Form1.cs
File metadata and controls
129 lines (119 loc) · 4.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Discord_Webhook
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.button1.Location = new System.Drawing.Point(11, 111);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(261, 47);
this.button1.TabIndex = 0;
this.button1.Text = "Send!";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.BackColor = System.Drawing.SystemColors.Window;
this.textBox1.Location = new System.Drawing.Point(12, 28);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(260, 20);
this.textBox1.TabIndex = 1;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(12, 70);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(260, 20);
this.textBox2.TabIndex = 2;
this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(13, 13);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(53, 13);
this.label1.TabIndex = 3;
this.label1.Text = "Message:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(13, 51);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(82, 13);
this.label2.TabIndex = 4;
this.label2.Text = "Webhook URL:";
//
// Form1
//
this.AutoSize = true;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.BackColor = System.Drawing.SystemColors.InfoText;
this.ClientSize = new System.Drawing.Size(284, 186);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.ForeColor = System.Drawing.SystemColors.Control;
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(300, 225);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(300, 225);
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Discord Webhook Sender";
this.ResumeLayout(false);
this.PerformLayout();
}
private void button1_Click(object sender, EventArgs e)
{
{
// Get the webhook URL and message from the text boxes
string webhookUrl = textBox2.Text;
string message = textBox1.Text;
// Create a new HttpClient to send the request
var httpClient = new HttpClient();
// Set the request content as a JSON object with the message to send
var requestContent = new StringContent(
"{\"content\": \"" + message + "\"}",
Encoding.UTF8,
"application/json"
);
// Send the POST request to the webhook URL
var response = httpClient.PostAsync(webhookUrl, requestContent).Result;
// Print the response status code to the console
Console.WriteLine($"Response status code: {(int)response.StatusCode}");
}
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
}
}