Skip to content

Commit 1deea90

Browse files
committed
Module exports
1 parent ae7ab95 commit 1deea90

File tree

336 files changed

+59474
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

336 files changed

+59474
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const Discord = require('discord.js');
2+
3+
module.exports = {
4+
name: "test",
5+
description: "Comando di test",
6+
execute(message, args) {
7+
message.channel.send("TEST");
8+
}
9+
}

Module exports/events/message.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
name: "message",
3+
execute(message) {
4+
console.log(message.content);
5+
}
6+
}

Module exports/events/ready.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
name: "ready",
3+
execute() {
4+
console.log("CIAO!")
5+
}
6+
}

Module exports/index.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const Discord = require('discord.js');
2+
global.client = new Discord.Client();
3+
4+
client.login("Token");
5+
6+
const fs = require("fs");
7+
8+
client.commands = new Discord.Collection();
9+
10+
const commandsFiles = fs.readdirSync("./commands").filter(file => file.endsWith(".js"));
11+
for (const file of commandsFiles) {
12+
const command = require(`./commands/${file}`);
13+
client.commands.set(command.name, command);
14+
}
15+
16+
const commandsFolder = fs.readdirSync("./commands");
17+
for (const folder of commandsFolder) {
18+
const commandsFiles = fs.readdirSync(`./commands/${folder}`).filter(file => file.endsWith(".js"));
19+
for (const file of commandsFiles) {
20+
const command = require(`./commands/${folder}/${file}`);
21+
client.commands.set(command.name, command);
22+
}
23+
}
24+
25+
const eventsFiles = fs.readdirSync("./events").filter(file => file.endsWith(".js"));
26+
for (const file of eventsFiles) {
27+
const event = require(`./events/${file}`);
28+
client.on(event.name, (...args) => event.execute(...args))
29+
}
30+
31+
client.on("message", message => {
32+
const prefix = "!";
33+
34+
if (!message.content.startsWith(prefix) || message.author.bot) return
35+
36+
const args = message.content.slice(prefix.length).trim().split(/ +/);
37+
const command = args.shift().toLowerCase();
38+
39+
if (!client.commands.has(command) && !client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(command))) return
40+
41+
var comando = client.commands.get(command) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(command))
42+
43+
if (comando.onlyStaff) {
44+
if (!message.member.hasPermission("ADMINISTRATOR")) {
45+
message.channel.send("Non hai il permesso di eseguire questo comando")
46+
return
47+
}
48+
}
49+
50+
comando.execute(message, args);
51+
})

Module exports/node_modules/.package-lock.json

Lines changed: 169 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)