-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiscordCommands.cs
80 lines (62 loc) · 2.99 KB
/
DiscordCommands.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
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Transactions;
using Discord;
using Discord.Commands;
namespace DiscordBot
{
public class DiscordCommands : ModuleBase<SocketCommandContext>
{
[Command("donators"), RequireContext(ContextType.Guild)]
public async Task DiscordCommandDonators()
{
var guildUser = Context.Guild.GetUser(Context.User.Id);
if (guildUser is null) return;
if (guildUser.Roles.All(x => x.Id != 616641490336219137)) return;
var basicDonators = Context.Guild.Users.Where(x => x.Roles.Any(x => x.Id == 673911514004062208)).ToList();
Console.WriteLine($"Found {basicDonators.Count()} Basic Donators");
var donatorPros = Context.Guild.Users.Where(x => x.Roles.Any(x => x.Id == 793170213759746049)).ToList();
Console.WriteLine($"Found {donatorPros.Count()} Donator Pros");
string donators = "";
if (basicDonators.Any())
{
foreach (var basicDonator in basicDonators)
{
donators =
$"{donators}\nUser: {basicDonator.Username} - Nick: {basicDonator.Nickname} - Basic Donator";
}
}
if (donatorPros.Any())
{
foreach (var proDonator in donatorPros)
{
donators =
$"{donators}\nUser: {proDonator.Username} - Nick: {proDonator.Nickname} - Pro Donator";
}
}
await File.WriteAllTextAsync($"{Directory.GetCurrentDirectory()}/donatorList-{DateTime.Now.Day}-{DateTime.Now.Month}.txt", donators);
var channel = Context.Channel as ITextChannel;
if (channel == null) return;
await channel.SendFileAsync(
$"{Directory.GetCurrentDirectory()}/donatorList-{DateTime.Now.Day}-{DateTime.Now.Month}.txt",
$"Here is the latest donator list {Context.User.Mention}! {basicDonators.Count()} " +
$"Basic Donators & {donatorPros.Count()} Pro Donators! That's {basicDonators.Count() + donatorPros.Count()} Donators!");
File.Delete(
$"{Directory.GetCurrentDirectory()}/donatorList-{DateTime.Now.Day}-{DateTime.Now.Month}.txt");
}
[Command("wipe"), RequireContext(ContextType.Guild), RequireUserPermission(ChannelPermission.ManageMessages)]
public async Task DiscordCommandWipe(int wipeCount = 1)
{
wipeCount += 1;
var messages = await Context.Channel.GetMessagesAsync(wipeCount, CacheMode.AllowDownload).FlattenAsync();
foreach (var message in messages)
{
await message.DeleteAsync();
await Task.Delay(50);
}
await Context.User.SendMessageAsync($"I've deleted the required messages sir!");
}
}
}