-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBot.js
More file actions
92 lines (73 loc) · 2.94 KB
/
Bot.js
File metadata and controls
92 lines (73 loc) · 2.94 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const botconfig = require("./botconfig.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("Could not file coomads.");
return;
}
jsfile.forEach((f, i) =>{
let props = require(`./commands/${f}`);
console.log(`${f} loaded!`);
bot.commands.set(props.help.name, props);
});
});
// Displays the message in console
bot.on("ready", async () => {
console.log(`${bot.user.username} is online and ready to kill!`);
bot.user.setActivity("*Commands | https://sanandreasdpjrp.wixsite.com/sadpj", {type: "Playing"});
bot.user.setStatus('dnd') // Online, idle, invisible & dnd
});
// Bot Start
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);
if (!message.content.startsWith(prefix)) return;
let commandfile = bot.commands.get(cmd.slice(prefix.length));
if(commandfile) commandfile.run(bot, message, args);
// Hello Command
if(cmd === `${prefix}hello`){
return message.channel.send("Hello Mate!");
}
// Web Command
if(cmd === `${prefix}web`){
return message.channel.send("The website is https://sanandreasdpjrp.wixsite.com/sadpj");
}
// ip Command
if(cmd === `${prefix}ip`){
return message.channel.send("45.35.193.130:30120");
}
// ip Command
if(cmd === `${prefix}cad`){
return message.channel.send("The cad is https://sadpj-cad.bubbleapps.io/");
}
});
bot.on("guildMemberAdd", member => {
var role = member.guild.roles.find("name", "Guest");
member.addRole(role)
});
bot.on('guildMemberAdd', member => {
// Send the message to a designated channel on a server:
const channel = member.guild.channels.find('name', 'welcome');
// Do nothing if the channel wasn't found on this server
if (!channel) return;
// Send the message, mentioning the member
channel.send(`Welcome to The SADPJ Discord Server ${member}. Enjoy your stay, also be sure to check <#367811763418300417> and <#456937602277310474>`);
});
bot.on('guildMemberRemove', member => {
// Send the message to a designated channel on a server:
const channel = member.guild.channels.find('name', 'welcome');
// Do nothing if the channel wasn't found on this server
if (!channel) return;
// Send the message, mentioning the member
channel.send(`Thanks for stopping by, ${member}. `);
});
bot.login(botconfig.token);