-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
73 lines (67 loc) · 1.48 KB
/
Copy pathindex.js
File metadata and controls
73 lines (67 loc) · 1.48 KB
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
const { ReactionRole } = require("reaction-role");
const { bargs } = require("bargs");
const { config } = require("dotenv");
config();
const client = new ReactionRole(process.env.BOT_TOKEN, process.env.MONGODB_URI);
const prefix = "!";
client.on("message", async (message) => {
if (
message.author.bot ||
!message.guild ||
!message.content.startsWith(prefix)
)
return;
const [command, ...split] = message.content
.slice(prefix.length)
.trim()
.split(/ +/g);
if (command === "rr") {
const args = bargs(
[
{
name: "emoji",
type: String,
aliases: ["e"],
},
{
name: "role",
type: String,
aliases: ["r"],
},
{
name: "channel",
type: String,
aliases: ["c"],
},
{
name: "msg",
type: String,
aliases: ["m"],
},
{
name: "add",
type: String,
aliases: ["a"],
},
{
name: "remove",
type: String,
aliases: ["rm"],
},
],
split,
);
const { emoji, role, channel, msg, add, remove } = args;
if (!emoji || !role || !channel || !msg)
return message.reply(
"!rr -e <emoji> -r <role_id> -c <channel_id> -m <message_id> -a <add_message> -rm <remove_message>",
);
const c = await client.channels.fetch(channel);
const m = await c.messages.fetch(msg);
await m.react(emoji);
const option = client.createOption(emoji, [role], add, remove);
await client.createMessage(channel, msg, 1, option);
message.reply("created!");
}
});
client.init();