This repository has been archived by the owner on Oct 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
62 lines (56 loc) · 1.78 KB
/
bot.js
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
const express = require("express");
const app = express();
const port = 3000;
app.get("/", (req, res) => res.send("no_"));
app.listen(port, _ => 0);
const Discord = require("discord.js-light");
const MSG_SWEEP_SECONDS = 3;
const client = new Discord.Client(
{ intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_MESSAGE_REACTIONS"]
, makeCache: Discord.Options.cacheWithLimits(
{ ApplicationCommandManager: 0
, BaseGuildEmojiManager: Infinity
, ChannelManager: Infinity
, GuildChannelManager: Infinity
, GuildBanManager: 0
, GuildInviteManager: 0
, GuildManager: Infinity
, GuildMemberManager: Infinity
, GuildStickerManager: 0
, MessageManager:
{ maxSize: Infinity
, sweepInterval: MSG_SWEEP_SECONDS
}
, PermissionOverwriteManager: 0
, PresenceManager: 0
, ReactionManager: 0
, ReactionUserManager: 0
, RoleManager: 0
, StageInstanceManager: 0
, ThreadManager: 0
, ThreadMemberManager: 0
, UserManager: 0
, VoiceStateManager: 0
})
});
const EMOJI_ID = process.env.BONK_EMOJI_ID;
const DISCORD_TOKEN = process.env.DISCORD_TOKEN;
const BONKBOT_USER_ID = process.env.BONKBOT_USER_ID;
const IMMUNE_USER_IDS = process.env.IMMUNE_USER_IDS.split(',');
const REACT_WAIT_TIME = MSG_SWEEP_SECONDS * 1000;
client.on("messageCreate", msg =>
{
if (IMMUNE_USER_IDS.includes(msg.author.id))
{
const collector = msg.createReactionCollector();
collector.on("collect", (reaction, reactor) =>
{
if (reactor.id === BONKBOT_USER_ID && reaction.emoji.id === EMOJI_ID)
{
reaction.remove();
}
});
setTimeout(collector.stop.bind(collector), REACT_WAIT_TIME);
}
});
client.login(DISCORD_TOKEN);