This repository has been archived by the owner on Nov 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
68 lines (58 loc) · 2.41 KB
/
index.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
const { Console } = require('console');
const { Client, Collection, MessageEmbed } = require('discord.js');
const { glob } = require("glob");
const { promisify } = require("util");
const globPromise = promisify(glob);
try {
config = require("./config/config.json");
channels = require("./config/channels.json");
} catch {}
const permissionCheck = ["MANAGE_CHANNELS", "SEND_MESSAGES", "VIEW_CHANNEL", "MANAGE_WEBHOOKS"]
client = new Client({
intents: 32767,
partials: ["CHANNEL"],
});
const eventFiles = fs.readdirSync(`${GetResourcePath(GetCurrentResourceName())}/events/`).filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const event = require(`./events/${file}`);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}
const commandFiles = fs.readdirSync(`${GetResourcePath(GetCurrentResourceName())}/commands/`).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const event = require(`./commands/${file}`);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}
client.on('messageCreate', async (message) => {
const {channel, content, guild, author} = message;
if(content.toLowerCase().startsWith(`${client.config.prefix}players`)){
const tUser = await message.guild.members.cache.get(author.id);
if(!tUser.permissions.has("MANAGE_MESSAGES")) return message.reply({content: "⛔ | Missing Permissions to use this command.\nNeeded permission flag: `MANAGE_MESSAGES`"})
const players = await exports[GetCurrentResourceName()].GetPlayers()
let playerlist = 'No Players Online.'
for (const [k, v] of Object.entries(players)) {
console.log(k,v)
if(playerlist === 'No Players Online.'){
playerlist = `**${Number(k) + 1}.** ${GetPlayerName(v)} - Server ID: \`${v}\``
} else {
playerlist = `\n${playerlist} **${k + 1}.** ${GetPlayerName(v)} - Server ID: \`${v}\``
};
};
message.reply({embeds: [new MessageEmbed().setColor("RANDOM").setDescription(playerlist)]})
}
})
process.on('unhandledRejection', error => {
console.log(error);
});
process.setMaxListeners(20);
try {
client.config = config;
client.login(config.token);
} catch {}