-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
76 lines (56 loc) · 2.56 KB
/
bot.js
File metadata and controls
76 lines (56 loc) · 2.56 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
74
75
76
const botconfig = require("./config.json");
const Discord = require("discord.js");
const fs = require("fs");
const bot = new Discord.Client({disableEveryone: true});
bot.commands = new Discord.Collection();
fs.readdir("./commands/", (err, files) => {
if(err) console.log(err);
let jsfile = files.filter(f => f.split(".").pop() === "js")
if(jsfile.length <= 0){
console.log("Não consegui achar os comandos!");
return;
}
jsfile.forEach((f, i) =>{
let props = require(`./commands/${f}`);
console.log(`${f} - carregado!`);
bot.commands.set(props.help.name, props);
});
});
bot.on("guildMemberAdd", (member) => { // Check out previous chapter for information about this event
let guild = member.guild;
let memberTag = member.user.tag;
let canalGeral = guild.channels.find(j => j.name === "💜bem-vindo");
if(!canalGeral) return message.reply("Não achei o canal 💜bem-vindo");
if(guild.systemChannel){
canalGeral.send(new Discord.RichEmbed() // Creating instance of Discord.RichEmbed
.setTitle("Boas-vindas!") // Calling method setTitle on constructor.
.setDescription(memberTag + " juntou-se ao Power Pixel Fórum.") // Setting embed description
.setThumbnail(member.user.displayAvatarURL) // The image on the top right; method requires an url, not a path to file!
.addField("Membros no servidor: ", `**${member.guild.memberCount}**`) // Adds a field; First parameter is the title and the second is the value.
.setTimestamp() // Sets a timestamp at the end of the embed
);
}
});
bot.on("ready", async () => {
console.log(`[SUCESSO] ${bot.user.username} - nosso BOT está online!`)
let status = require('./activityMSG.json');
let setActivity = () =>{
let alteraStatus = status.activitys[Math.floor(Math.random()*status.activitys.length)];
let mensagem = alteraStatus.message.replace('{users}', bot.users.size).replace('{guilds}', bot.guilds.size).replace('{channels}', bot.channels.size)
bot.user.setActivity(mensagem, {type: alteraStatus.type})
}
setActivity();
setInterval(()=>setActivity(), 1000 * 15);
}
);
bot.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type === "dm") return;
let prefix = botconfig.prefix;
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);
let commandfile = bot.commands.get(cmd.slice(prefix.length));
if(commandfile) commandfile.run(bot,message,args);
})
bot.login(botconfig.token);