-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.cs
31 lines (24 loc) · 976 Bytes
/
Utils.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
using Discord;
using Discord.WebSocket;
namespace QuoteBot;
public static class Utils {
public static async Task<ITextChannel?> GetQuotesChannel(this SocketSlashCommand cmd, DiscordSocketClient client) {
ulong? channelId = Program.Storage.GetQuoteChannel(cmd.GuildId!.Value);
if (channelId == null) {
return null;
}
IChannel channel = await client.GetChannelAsync(channelId.Value);
return channel as ITextChannel;
}
public static async Task<ITextChannel?> GetQuotesChannel(this DiscordSocketClient client, ulong guild) {
ulong? channelId = Program.Storage.GetQuoteChannel(guild);
if (channelId == null) {
return null;
}
IChannel channel = await client.GetChannelAsync(channelId.Value);
return channel as ITextChannel;
}
public static MessageReference ToReference(this SocketMessage msg) {
return new MessageReference(msg.Id);
}
}