blob: a0290388bb26e26395cd06af1ca502391ffc31fb (
plain) (
blame)
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
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Discord;
using Discord.WebSocket;
namespace AleeChat_for_Discord_Bots
{
public partial class DiscordBot : Form
{
DiscordSocketClient Client;
public DiscordBot()
{
InitializeComponent();
}
private void exitButton_Click(object sender, EventArgs e)
{
}
private void guildComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
channelBox.Items.Clear();
foreach(var Guild in Client.Guilds)
{
if(Guild.Name == guildComboBox.Text)
{
foreach(var Tc in Guild.TextChannels)
{
channelBox.Items.Add(Tc.Name);
}
}
}
}
private async void loginButton_Click(object sender, EventArgs e)
{
Client = new DiscordSocketClient(new DiscordSocketConfig()
{
LogLevel = LogSeverity.Verbose
});
Client.Log += Client_Log;
try
{
await Client.LoginAsync(TokenType.Bot, tokenBox.Text);
await Client.StartAsync();
}
catch
{
MessageBox.Show("Error occured while connecting your Bot!", "ERROR");
return;
}
await Task.Delay(3000);
foreach (var Guild in Client.Guilds)
{
guildComboBox.Items.Add(Guild.Name);
}
guildComboBox.SelectedIndexChanged += guildComboBox_SelectedIndexChanged;
}
private Task Client_Log(LogMessage arg)
{
Invoke((Action)delegate
{
discordConsole.AppendText(arg + "\n");
});
return null;
}
private void discordConsole_TextChanged(object sender, EventArgs e)
{
}
private void tokenBox_TextChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void sendButton_Click(object sender, EventArgs e)
{
}
}
}
|