-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBanList.cs
43 lines (39 loc) · 1.38 KB
/
BanList.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
using Discord;
using Discord.Commands;
using Discord.WebSocket;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace bot.Handlers
{
public class BanList : ModuleBase<SocketCommandContext>
{
[Command("banlist")]
public async Task BanListAsync()
{
await Context.Message.DeleteAsync();
if (!Context.Message.Channel.Id.Equals(Global.SetupId))
{
var msg = await Context.Channel.SendMessageAsync
("You can use `!banlist` command only in `setup` channel");
await Task.Delay(5000);
await Context.Channel.DeleteMessageAsync(msg);
return;
}
var banList = (await File.ReadAllLinesAsync("banlist.txt")).ToList();
var embed = new EmbedBuilder();
embed.WithTitle("Banlist");
foreach (var id in banList)
{
var user = Context.Guild.GetUser(ulong.Parse(id));
embed.Description += $"{user}\n";
}
var message = await ReplyAsync(embed: embed.Build());
await Task.Delay(5000);
await Context.Channel.DeleteMessageAsync(message);
}
}
}