Created
August 8, 2019 15:15
-
-
Save PichotM/1af83b8fa73e3e237dfa38bb4585815b to your computer and use it in GitHub Desktop.
GTALife bot recrutement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Discord = require('discord.js'); | |
const client = new Discord.Client(); | |
const recruteurRoleID = "339431470462664705"; | |
const mainServerID = "329623622819905546"; | |
var entretienStarted = false; | |
var count = 0 | |
function hasEnoughPermissions(msg, perm) { | |
return msg.member && msg.member.hasPermission && msg.member.hasPermission(perm || 'KICK_MEMBERS'); | |
} | |
function IsRecruteur(msg){ | |
return msg.member.roles.has(msg.guild.roles.find("id", recruteurRoleID).id); | |
} | |
function sendEmbedMessage(message, data){ | |
message.channel.send({embed: { | |
color: data.color || 3447003, | |
author: { name: message.author.username, icon_url: message.author.avatarURL }, | |
title: data.title || "Informations", | |
description: data.desc || "", | |
fields: data.fields | |
}}).catch(console.error); | |
} | |
client.on('ready', async client => { | |
console.log("Init succesful."); | |
}); | |
const countToEmoji = ["0⃣", | |
"1⃣", | |
"2⃣", | |
"3⃣","4⃣","5⃣","6⃣","7⃣","8⃣","9⃣","9️⃣ " | |
] | |
client.on('message', async (message, userID) => { | |
const IsGTALife = message.guild && message.guild.id && message.guild.id == mainServerID; | |
const channelType = message.channel.type; | |
const channelID = message.channel.id; | |
if (channelID == "339371044945264651" && entretienStarted) { | |
count = count + 1; | |
const countStr = count.toString(); | |
message.react(countToEmoji[countStr.substring(0, 1)]).then(() => { | |
if (countStr.substring(1, 2)) | |
message.react(countToEmoji[countStr.substring(1, 2)]); | |
}); | |
} else if (channelID == "481489084292923402") { | |
if(message.content.indexOf("?") != 0 || channelType != 'text') return; | |
const args = message.content.slice(1).trim().split(/ +/g); | |
const command = args.shift().toLowerCase(); | |
if (command == "start" && !entretienStarted) { | |
console.log('received'); | |
const recrutementChannel = client.channels.find('id', '339371044945264651'); | |
if (recrutementChannel) { | |
recrutementChannel.send("Début des entretiens."); | |
entretienStarted = true; | |
} | |
} | |
} | |
}) | |
client.login(key); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment