-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.ts
204 lines (188 loc) · 8.98 KB
/
main.ts
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
import { ActivityType, CategoryChannel, Client, REST, Routes, TextChannel } from 'npm:discord.js'
import { handleShowcaseMessage, sendBanMessage, sendLeaveMessage, sendPrivateMessage, sendVoice } from './helper.ts';
import { handleInteraction } from "./interactions.ts";
import { PartnerManager } from './partner.ts';
import { findUser } from "./db.ts";
const client = new Client({ intents: 3276799 });
client.on("ready", () => {
console.log(`Logged in as ${client.user!.tag}!`);
client.user!.setActivity('bbn.one', { type: ActivityType.Listening });
const rest = new REST().setToken(Deno.env.get("TOKEN")!);
(async () => {
try {
console.log('Started refreshing application (/) commands.');
await rest.put(Routes.applicationCommands(client.user!.id), {
body:
[
// {
// name: 'setup',
// description: 'Setup the Voice Locker',
// },
{
name: 'verify',
description: 'Verify a User',
},
{
name: 'daily',
description: 'Claim your daily reward',
},
{
name: 'balance',
description: 'See your current balance',
options: [
{
name: 'user',
description: 'Check the balance of another user',
type: 9,
required: false,
}
]
},
{
name: 'addcoins',
description: 'Add coins to a user',
options: [
{
name: 'user',
description: 'The user to add coins to',
type: 9,
required: true,
},
{
name: 'coins',
description: 'The amount of coins to add',
type: 4,
required: true,
}
]
},
{
name: 'removecoins',
description: 'Remove coins from a user',
options: [
{
name: 'user',
description: 'The user to remove coins from',
type: 9,
required: true,
},
{
name: 'coins',
description: 'The amount of coins to remove',
type: 4,
required: true,
}
]
},
{
name: 'escalate',
description: 'Escalate a ticket to the next support level'
},
{
name: 'addpartner',
description: 'Add a partner to the partner list',
options: [
{
name: 'user',
description: 'The user to remove coins from',
type: 9,
required: true,
},
{
name: 'cpu',
description: 'The amount of cpu to add',
type: 4,
required: true,
},
{
name: 'ram',
description: 'The amount of ram to add',
type: 4,
required: true,
},
{
name: 'storage',
description: 'The amount of storage to add',
type: 4,
required: true,
},
{
name: 'slots',
description: 'The amount of slots to add',
type: 4,
required: true,
}
]
},
{
name: 'removepartner',
description: 'Remove a partner from the partner list',
options: [
{
name: 'user',
description: 'The user to remove coins from',
type: 9,
required: true,
}
]
},
{
name: 'partners',
description: 'List all partners'
},
{
name: "servers",
description: "List all servers",
options: [
{
name: 'user',
description: 'The user to list servers from',
type: 9,
required: true,
}
]
},
{
name: "deescalate",
description: "Deescalate a ticket to the previous support level",
}
]
});
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
});
const partnerManager = new PartnerManager(client);
client.on('inviteCreate', async () => await partnerManager.cacheInvites());
client.on('inviteDelete', async () => await partnerManager.cacheInvites());
client.on('guildMemberAdd', async (member) => await partnerManager.onMember(member, 'join'));
client.on('guildBanAdd', (ban) => sendBanMessage(ban, true))
client.on('guildBanRemove', (ban) => sendBanMessage(ban, false))
client.on('guildMemberRemove', sendLeaveMessage)
client.on('messageCreate', (message) => sendPrivateMessage(message, client))
client.on('messageCreate', (message) => handleShowcaseMessage(message));
client.on('voiceStateUpdate', sendVoice);
client.on('interactionCreate', (interaction) => handleInteraction(interaction));
client.on('guildMemberUpdate', async (oldMember, newMember) => {
if (oldMember.premiumSince !== newMember.premiumSince && newMember.premiumSince) {
const dbuser = await findUser(newMember.id);
if (dbuser) {
(await newMember.guild.channels.fetch(Deno.env.get("GENERAL_CHANNEL")!) as TextChannel).send(`<@${newMember.id}> will now get a 10x /daily reward for the duration of their boost!`);
} else {
if (newMember.guild.channels.cache.find((channel) => channel.name === `link-${newMember.id}`))
return;
const channel = await newMember.guild.channels.create({
name: `link-${newMember.id}`,
parent: await newMember.guild.channels.fetch(Deno.env.get("LINK_CATEGORY")!) as CategoryChannel,
});
await channel.permissionOverwrites.create(newMember, { ViewChannel: true });
await channel.send({ content: `<@${newMember.id}> Looks like you just boosted the server! Unfortunately, you are not linked to your BBN account yet. Please send your Email address to this channel to link your account. Our Team will respond as soon as possible.`, allowedMentions: { users: [ newMember.id ] } });
}
}
})
client.login(Deno.env.get("TOKEN")!).then(() => {
console.log('Logged in');
partnerManager.cacheInvites();
});