forked from hayday1/slash-activities
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
178 lines (170 loc) · 6.99 KB
/
index.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
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
const client = new(require("discord.js").Client)
const {
MessageEmbed
} = require('discord.js');
const fetch = require('node-fetch')
const {
Slash
} = require("discord-slash-commands");
const slash = new Slash({
client: client
})
const embed = new MessageEmbed();
slash.on("create", (d) => {
console.log(`Command created: ${JSON.parse(d.config.data).name}`)
})
slash.on("command", async (command) => {
if (command.name === "activities") {
let channel = client.channels.cache.get(command.options.find(m => m.name === "channel").value);
if (channel.type !== "voice") return command.callback("Channel must be a voice channel.")
if (command.options.find(m => m.name === "type").value === "yt") {
fetch(`https://discord.com/api/v8/channels/${channel.id}/invites`, {
method: "POST",
body: JSON.stringify({
max_age: 86400,
max_uses: 0,
target_application_id: "755600276941176913",
target_type: 2,
temporary: false,
validate: null
}),
headers: {
"Authorization": `Bot ${client.token}`,
"Content-Type": "application/json"
}
})
.then(res => res.json())
.then(invite => {
embed.setTitle("Activity added!")
embed.setDescription(`Added **YouTube Together** to [${channel.name}](https://discord.gg/${invite.code})\n> Click on the hyperlink to join.`)
embed.setFooter(`Requested by ${command.author.username + "#" + command.author.discriminator}`)
embed.setColor("#7289DA")
command.callback({
embeds: embed
});
})
}
if (command.options.find(m => m.name === "type").value === "pn") {
fetch(`https://discord.com/api/v8/channels/${channel.id}/invites`, {
method: "POST",
body: JSON.stringify({
max_age: 86400,
max_uses: 0,
target_application_id: "755827207812677713",
target_type: 2,
temporary: false,
validate: null
}),
headers: {
"Authorization": `Bot ${client.token}`,
"Content-Type": "application/json"
}
})
.then(res => res.json())
.then(invite => {
embed.setTitle("Activity added!")
embed.setDescription(`Added **Poker Night** to [${channel.name}](https://discord.gg/${invite.code})\n> Click on the hyperlink to join.`)
embed.setFooter(`Requested by ${command.author.username + "#" + command.author.discriminator}`)
embed.setColor("#7289DA")
command.callback({
embeds: embed
});
})
}
if (command.options.find(m => m.name === "type").value === "bio") {
fetch(`https://discord.com/api/v8/channels/${channel.id}/invites`, {
method: "POST",
body: JSON.stringify({
max_age: 86400,
max_uses: 0,
target_application_id: "773336526917861400",
target_type: 2,
temporary: false,
validate: null
}),
headers: {
"Authorization": `Bot ${client.token}`,
"Content-Type": "application/json"
}
})
.then(res => res.json())
.then(invite => {
embed.setTitle("Activity added!")
embed.setDescription(`Added **Betrayal.io** to [${channel.name}](https://discord.gg/${invite.code})\n> Click on the hyperlink to join.`)
embed.setFooter(`Requested by ${command.author.username + "#" + command.author.discriminator}`)
embed.setColor("#7289DA")
command.callback({
embeds: embed
});
})
}
if (command.options.find(m => m.name === "type").value === "fio") {
fetch(`https://discord.com/api/v8/channels/${channel.id}/invites`, {
method: "POST",
body: JSON.stringify({
max_age: 86400,
max_uses: 0,
target_application_id: "814288819477020702",
target_type: 2,
temporary: false,
validate: null
}),
headers: {
"Authorization": `Bot ${client.token}`,
"Content-Type": "application/json"
}
})
.then(res => res.json())
.then(invite => {
embed.setTitle("Activity added!")
embed.setDescription(`Added **Fishington.io** to [${channel.name}](https://discord.gg/${invite.code})\n> Click on the hyperlink to join.`)
embed.setFooter(`Requested by ${command.author.username + "#" + command.author.discriminator}`)
embed.setColor("#7289DA")
command.callback({
embeds: embed
});
})
}
}
})
client.on("ready", () => {
console.log("Ready");
slash.create({
guildOnly: false,
data: {
name: "activities",
description: "Voice channel activities",
options: [{
name: "channel",
description: "Select the voice channel you want.",
required: true,
type: 7,
},
{
name: "type",
description: "Type of activity.",
required: true,
type: 3,
choices: [{
name: "YouTube Together",
value: "yt"
},
{
name: "Betrayal.io",
value: "bio"
},
{
name: "Poker Night",
value: "pn"
},
{
name: "Fishington.io",
value: "fio"
}
]
}
]
}
})
})
client.login(process.env.TOKEN)