forked from warstrolo/join4join-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
77 lines (73 loc) · 2.33 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
const Discord = require('discord.js');
const client = new Discord.Client();
const request = require('./request')
const config = require('./config.json')
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('guildMemberRemove', async member => {
let res = await request.leave(member.id, member.guild.id)
})
client.on('message', async message => {
let array = message.content.split(' ')
if (message.content === config.prefix+'join') {
let res = await request.join(message.author.id, message.guild.id)
if (res[0] == false && !res[1])
{
return message.reply("Error occured")
}
if (res[0] == true)
{
if (res[1][0] == false)
{
return message.reply("You have a code or a message waiting for you \n" + "||"+res[1][1]+"||")
}
if (res[1][0] == true)
{
return message.reply("A new code is waiting for you \n" + "||"+res[1][1]+"||")
}
}
//message.reply("No ads currently here so you cant get a join4join join code")
}
if (message.content === config.prefix+'farm') {
let res = await request.farm(message.author.id)
if (res == false)
{
return message.reply("An error occured")
}
if (res[0] == "ok")
{
let msg = "Farm this servers to get coins \n";
res[1].forEach(element => {
msg = msg + "\n"+ element.name + " : https://discord.gg/" + element.invite
});
return message.reply(msg)
}
if (res[0] == "error")
{
message.reply(res[1])
}
//message.reply("No ads currently here so you cant get a join4join join code")
}
if (array[0]=== config.prefix+'buy') {
if (!array[1] || isNaN(array[1]) || !parseInt(array[1]))
{
return message.reply("You must specify the buy number")
}
let invite = await message.channel.createInvite(
{
maxAge: 0, // maximum time for the invite, in milliseconds
maxUses: 0 // maximum times it can be used
});
console.log(invite.code)
let res = await request.buy(message.author.id, message.guild.id,invite.code, array[1] )
console.log("test")
if (res == false)
{
return message.reply("An error occured")
}
return message.reply(res)
//message.reply("No ads currently here so you cant get a join4join join code")
}
});
client.login(config.bottoken);