-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
102 lines (86 loc) · 4.26 KB
/
bot.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
const { Client, Attachment } = require('discord.js');
const botsettings = require("./bot_settings.json");
const Discord = require("discord.js");
const bot = new Discord.Client({disableEveryone: true})
const prefix = botsettings.prefix;
const fs = require("fs");
bot.commands = new Discord.Collection();
fs.readdir("./Commands/", (err, files) => {
if(err) console.error(err);
let jsfiles = files.filter(f => f.split(".").pop() === "js");
if(jsfiles.length <= 0) {
console.log(`
_____ _____ _____ _____ _____
_ _ _ _ _ _ _ _ _ _ _ _ _ _ | __| __ | __ | | __ | _ _ _ _ _ _ _ _ _ _ _ _ _ _
|_'_|_'_|_'_|_'_|_'_|_'_|_'_| | __| -| -| | | -| |_'_|_'_|_'_|_'_|_'_|_'_|_'_|
|_,_|_,_|_,_|_,_|_,_|_,_|_,_| |_____|__|__|__|__|_____|__|__| |_,_|_,_|_,_|_,_|_,_|_,_|_,_|
`);
console.log("No Commands to load!");
}
if(jsfiles.length >=1){
console.log(`
_ _ _ _
| | | |___| |___ ___ _____ ___
| | | | -_| | _| . | | -_| _
|_____|___|_|___|___|_|_|_|___| |_|
`)
console.log(`Loading ${jsfiles.length} commands!`);
}
jsfiles.forEach((f, i) => {
let props = require(`./Commands/${f}`);
console.log(`${i + 1}: ${f} loaded!`);
bot.commands.set(props.help.name, props);
});
})
bot.on("ready", async() =>{
console.log(`
___ ___ ___ ___ ___ ___ ___ ___ ___ ___
|___|___|___|___|___|___|___|___|___|___|
`);
console.log(`Logged in as ${bot.user.username}#${bot.user.discriminator}`)
console.log(`Bot Version: ${botsettings.version}`)
bot.user.setActivity(`Bot Version: ${botsettings.version}`, { type: 'LISTENING' })
.then(presence => console.log(`Activity set to ${presence.game ? presence.game.name : 'none'}`))
.catch(console.error);
console.log(`Generating invite link...`);
try{
let link = await bot.generateInvite(["ADMINISTRATOR"]);
console.log(link);
} catch(e){
console.log(e.stack);
}
})
bot.on("message", async message =>{
if(message.author.bot) return;
if(message.channel.type === "dm") return message.reply("Get outta my DM's BOY!");
let messageArray = message.content.split(" ");
let command = messageArray[0];
let args = messageArray.slice(1);
if(!command.startsWith(prefix)) return;
let cmd = bot.commands.get(command.slice(prefix.length));
if(cmd) cmd.run(bot, message, args);
})
bot.on('guildMemberAdd', member => {
const channel = member.guild.channels.find(ch => ch.name === 'member-log');
if(!channel) return console.log(`${member.guild.name} has no log channel! I am unable to log their joined users!`);
channel.send(`User, ${member.user.mention}#${member.user.discriminator} has joined the ${message.guild.name} sever!`);
new Discord.RichEmbed(embed);
embed.AddField()
})
bot.on("messageDelete", messageDelete => {
const channel = messageDelete.guild.channels.find(ch => ch.name === 'jlogs');
if(!channel) return console.log(`${messageDelete.guild.name} has no log channel! I am unable to log their deleted messages!!`);
channel.send(`The message : "${messageDelete.content}" by ${messageDelete.author} was deleted.`);
})
bot.on("channelCreate", channelCreate =>{
const channel = channelCreate.guild.channels.find(ch => ch.name === 'jlogs');
if(!channel) return console.log(`${channelCreate.guild.name} has no log channel! I am unable to log their created channels!`);
channel.send(`Channel or Category: ${channelCreate.name} was created by ${channelCreate.author}.`);
});
bot.on('message', message => {
if (message.content == 'rip') {
const attachment = new Attachment('https://i.imgur.com/w3duR07.png');
message.react(`670514373294424071`)
}
});
bot.login(botsettings.token);