-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathindex.js
58 lines (48 loc) · 1.94 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
const express = require('express')
const app = express();
const port = 3000
app.get('/', (req, res) => res.send('Yo boi!!'))
app.listen(port, () =>
console.log(`Your app is listening to http://localhost:${port}`)
);
const Discord = require("discord.js")
const fetch = require("node-fetch");
const client = new Discord.Client()
const config = {
"token": (process.env.token) ,
"prefix": "!"
}
client.login(config.token)
client.on("ready",()=>{
console.log(`BOT ${client.user.tag} Has now been launched!! 🚀 Coded by 365 ɢᴀᴍɪɴɢ ɴ ᴍᴏʀᴇ_2.0#0002`)
client.user.setActivity("MINIGAMES", {type:"COMPETING"})
})
client.on("message", async (message) => {
if(!message.guild || message.author.bot || !message.content.trim().startsWith(config.prefix)) return;
// "!ytt asda" --> "ytt asda" --> ["ytt", "asda"]
var args = message.content.slice(config.prefix.length).trim().split(" ")
// ["ytt", "asda"] --> cmd = "ytt" & ["asda"]
var cmd = args.shift().toLowerCase()
const { channel } = message.member.voice;
if(!channel) return message.reply("You need to join a Voice Channel")
if(cmd == "ytt" || cmd == "youtubetogether"){
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 ${config.token}`,
"Content-Type": "application/json"
}
}).then(res => res.json())
.then(invite =>{
if(!invite.code) return message.reply(":x: Cannot start minigame")
message.channel.send(`Click on the **__Link__** to start the GAME:\n> https://discord.com/invite/${invite.code}`)
})
}})