Repository navigation
Expand file tree
/
Copy pathmain.js
More file actions
158 lines (134 loc) · 6.99 KB
/
Copy pathmain.js
File metadata and controls
158 lines (134 loc) · 6.99 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// ---- Dependencies --------------------------------------------------------------------------------
const Discord = require('discord.js');
const prbot = require('./locked.json');
const Canvas = require('canvas');
const fs = require('fs');
const { Player } = require('discord-player');
const cheerio = require('cheerio');
const request = require('request');
// --------------------------------------------------------------------------------------------------
// ---- The Actual Bot ------------------------------------------------------------------------------
const client = new Discord.Client();
// --------------------------------------------------------------------------------------------------
// ---- makes a collection and assigns the commands and to them -------------------------------------
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
const player = new Player(client)
client.player = player;
for(const file of commandFiles){
const command = require(`./commands/${file}`)
client.commands.set(command.name, command)
}
// ---------------------------------------------------------------------------------------------------
// ---- Status ---------------------------------------------------------------------------------------
client.once("ready", ()=> {
console.log(`${prbot.name} is Online!`)
let status = prbot.prefix + 'help'
client.user.setActivity(status, { type: 'LISTENING' })
})
// ---------------------------------------------------------------------------------------------------
// ---- Reaction Role --------------------------------------------------------------------------------
client.on('messageReactionAdd' , async (reaction, user) => {
})
// ---------------------------------------------------------------------------------------------------
// ---- Music ----------------------------------------------------------------------------------------
client.player.on('trackStart' , (message, track) => {
const newEmbed = new Discord.MessageEmbed().setTitle(`Now Playing ${track.title} [Requested by ${message.author.username}]`).setColor('#424242').setURL(`${track.url}`).setDescription(`${track.duration}`).setThumbnail(client.user.displayAvatarURL());
message.channel.send(newEmbed);
})
.on('trackAdd' , (message,queue ,track) => {
const newEmbed = new Discord.MessageEmbed().setTitle(`${track.title} [Requested by ${message.author.username}] is added in the queue.`).setColor('#424242').setURL(`${track.url}`).setDescription(`${track.duration}`).setThumbnail(client.user.displayAvatarURL());
message.channel.send(newEmbed);
})
.on('musicStop', () =>{
message.channel.send('**STOPPED**');
})
.on('queueEnd', async(message, queue) =>{
message.channel.send('QUE END')
})
// ---------------------------------------------------------------------------------------------------
// ---- Welcomer -------------------------------------------------------------------------------------
client.on('guildMemberAdd', member => {
client.commands.get('welcomer').execute(member, Canvas, Discord)
})
// ---------------------------------------------------------------------------------------------------
client.on('message', async (message)=> {
if (!(message.content.startsWith(prbot.prefix)) || message.author.bot) {
return
}
const temp = message.content.slice(prbot.prefix.length).split(" ");
const args = [];
for(let i = 0; i < temp.length ; i++){
if (typeof temp[i] == "string") {
args.push(temp[i].toLowerCase());
}
}
const command = args.shift().toLowerCase();
if (command === 'ping') {
client.commands.get('ping').execute(message, args);
} else if(command === 'log'){
console.log(message.content);
} else if(command === 'date' || command === 'time'){
client.commands.get('date').execute(message, args);
} else if(command === 'avatar'){
client.commands.get('avatar').execute(message, args);
} else if(command === 'clear' || command === 'delete' || command === 'nuke'){
client.commands.get('clear').execute(message, args)
} else if(command === 'create' ){
client.commands.get('create').execute(message, args);
} else if(command === 'help'){
client.commands.get('help').execute(message, args, Discord, prbot);
} else if(command === 'roleadd'){
client.commands.get('roleadd').execute(message);
} else if(command === 'rolesnatch'){
client.commands.get('gif').execute(message, args, cheerio, request);
client.commands.get('rolesnatch').execute(message);
} else if(command === 'image'){
client.commands.get('image').execute(message, args, cheerio, request);
} else if(command === 'memecreate'){
let meme_template = ['./meme_templates/1.jpg']
for(const file of meme_template)
{
message.channel.send(file.split('/')[2], {
files:[
file,
],
});
}
} else if(command === 'join'){
client.emit('guildMemberAdd' , message.member);
}
else if(command === 'play'){
const args_new = args.join();
client.commands.get('music').execute(message, args_new, command, client, Discord)
} else if(command === 'pause'){
client.commands.get('music').execute(message, args, command, client, Discord)
} else if(command === 'stop'){
client.commands.get('music').execute(message, args, 'pause', client, Discord)
} else if(command === 'disconnect'){
client.commands.get('music').execute(message, args, 'stop', client, Discord)
const newEmbed = new Discord.MessageEmbed().setTitle(`BYE.... :wave:`).setColor('#424242').setThumbnail(client.user.displayAvatarURL());
message.channel.send(newEmbed)
} else if(command === 'skip'){
client.commands.get('music').execute(message, args, command, client, Discord)
} else if(command === 'resume'){ //embed
client.commands.get('music').execute(message, args, command, client, Discord)
} else if(command === 'seek'){
client.commands.get('music').execute(message, args, command, client, Discord)
} else if(command === 'remove'){
let queue = client.player.getQueue(message);
console.log(args[0]-1);
console.log(queue);
const newEmbed = new Discord.MessageEmbed().setTitle(`${queue.tracks[args[0]-1].title} is removed`).setThumbnail(client.user.displayAvatarURL());
client.commands.get('music').execute(message, args, command, client, Discord)
message.channel.send(newEmbed);
} else if(command === 'fetchmessage') {
const fetchmessage = await message.channel.messages.fetch(args[0]);
console.log(fetchmessage);
console.log(fetchmessage.embeds[0].thumbnail)
} else if(command === 'def'){
console.log('def');
client.commands.get('def').execute(message, args, cheerio, request, Discord);
}
})
client.login(prbot.token)