-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaintenance.cs
35 lines (30 loc) · 1.12 KB
/
Maintenance.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
using DSharpPlus;
using DSharpPlus.EventArgs;
namespace BirthdayBot
{
public class Maintenance
{
public static Task Initialize(DiscordClient client)
{
client.ChannelDeleted += OnChannelDeleted;
client.GuildMemberRemoved += OnMemberLeave;
return Task.CompletedTask;
}
// Remove database rows of embeds in deleted channel
private static async Task OnChannelDeleted(DiscordClient client, ChannelDeleteEventArgs e)
{
ulong deletedChannelId = e.Channel.Id;
await Database.RemoveListEmbedByChannelId(deletedChannelId);
}
// Remove member from server's birthday list when they leave server
private static async Task OnMemberLeave(DiscordClient client, GuildMemberRemoveEventArgs e)
{
ulong leftMemberId = e.Member.Id;
ulong guildId = e.Guild.Id;
await Database.RemoveBirthday(guildId, leftMemberId);
await Functions.UpdateListEmbeds(e.Guild, client);
}
//TODO:
// Remove embed db entry after a time period in busy channel
}
}