-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
106 lines (95 loc) · 3.29 KB
/
Program.cs
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
using Discord;
using Discord.WebSocket;
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace lohostaria
{
class Program
{
private readonly DiscordSocketClient _client;
static void Main(string[] args)
=> new Program()
.MainAsync()
.GetAwaiter()
.GetResult();
public Program()
{
var config = new DiscordSocketConfig
{
GatewayIntents = GatewayIntents.AllUnprivileged | GatewayIntents.MessageContent
};
_client = new DiscordSocketClient(config);
_client.Log += LogAsync;
_client.Ready += ReadyAsync;
_client.MessageReceived += MessageReceivedAsync;
_client.InteractionCreated += InteractionCreatedAsync;
}
public async Task MainAsync()
{
string token = File.ReadAllText("token.txt");
await _client.LoginAsync(TokenType.Bot, token);
await _client.StartAsync();
await Task.Delay(Timeout.Infinite);
}
private Task LogAsync(LogMessage log)
{
Console.WriteLine(log.ToString());
return Task.CompletedTask;
}
private Task ReadyAsync()
{
Console.WriteLine($"{_client.CurrentUser} is connected!");
return Task.CompletedTask;
}
private async Task MessageReceivedAsync(SocketMessage message)
{
string prefix = "l.";
// The bot should never respond to itself.
if (message.Author.Id == _client.CurrentUser.Id)
return;
/*
if (message.Content == prefix + "")
{
await message.Channel.SendMessageAsync("");
}
*/
if (message.Content == prefix + "ping")
{
// Create a new ComponentBuilder, in which dropdowns & buttons can be created.
/*
var cb = new ComponentBuilder()
.WithButton("text", "id", ButtonStyle.Primary);
*/
await message.Channel.SendMessageAsync("pong!" /*, components: cb.Build()*/);
}
if (message.Content == prefix + "help")
{
await message.Channel.SendMessageAsync("I'm sorry I'm currently in development");
}
if (message.Content == prefix + "whoami")
{
await message.Channel.SendMessageAsync((message.Author).ToString());
}
if (message.Content == prefix + "project-detail")
{
await message.Channel.SendMessageAsync("This project is NotRealSean's hobby project of creating his own bot");
}
}
private async Task InteractionCreatedAsync(SocketInteraction interaction)
{
/*
if (interaction is SocketMessageComponent component)
{
if (component.Data.CustomId == "id")
{
await interaction.RespondAsync("respond");
}
else
Console.WriteLine("An ID has been received that has no handler!");
}
*/
}
}
}