discordjs-gen 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ TOKEN=
2
+ PREFIX=!
@@ -0,0 +1,7 @@
1
+ export default {
2
+ name: 'heloword',
3
+
4
+ run: async(client, message, args) => {
5
+ message.reply(`Helo word!`)
6
+ }
7
+ }
@@ -0,0 +1,8 @@
1
+ export default {
2
+ name: "ping",
3
+ aliases: ["pi"],
4
+
5
+ run: async (client, message, args) => {
6
+ message.reply(`🏓 Meu ping atual é ${client.ws.ping}ms`);
7
+ },
8
+ };
@@ -0,0 +1,6 @@
1
+ import client from '../../index.js';
2
+ import { Events } from 'discord.js';
3
+
4
+ client.on(Events.ClientReady, () => {
5
+ console.log(`[APP] Aplicação iniciada com sucesso!`)
6
+ });
@@ -0,0 +1,68 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { fileURLToPath } from "url";
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+
8
+ export default async (client) => {
9
+ // ===============================
10
+ // 📦 COMANDOS PREFIX
11
+ // ===============================
12
+ const prefixPath = path.join(__dirname, "../Commands");
13
+
14
+ fs.readdir(prefixPath, (err, pastas) => {
15
+ if (err) return console.error(err);
16
+
17
+ pastas.forEach((subpasta) => {
18
+ const subPath = path.join(prefixPath, subpasta);
19
+
20
+ fs.readdir(subPath, async (err, arquivos) => {
21
+ if (err) return console.error(err);
22
+
23
+ for (const arquivo of arquivos) {
24
+ if (!arquivo.endsWith(".js")) continue;
25
+
26
+ const filePath = path.join(subPath, arquivo);
27
+ const { default: comando } = await import(
28
+ `file://${filePath}`
29
+ );
30
+
31
+ if (!comando?.name) continue;
32
+
33
+ client.prefixCommands.set(comando.name, comando);
34
+
35
+ if (comando.aliases?.length) {
36
+ comando.aliases.forEach((alias) => {
37
+ client.prefixCommands.set(alias, comando);
38
+ });
39
+ }
40
+ }
41
+ });
42
+ });
43
+ });
44
+
45
+ // ===============================
46
+ // ⚡ EVENTOS
47
+ // ===============================
48
+ const eventosPath = path.join(__dirname, "../Events");
49
+
50
+ fs.readdir(eventosPath, (err, pastas) => {
51
+ if (err) return console.error(err);
52
+
53
+ pastas.forEach((subpasta) => {
54
+ const subPath = path.join(eventosPath, subpasta);
55
+
56
+ fs.readdir(subPath, async (err, arquivos) => {
57
+ if (err) return console.error(err);
58
+
59
+ for (const arquivo of arquivos) {
60
+ if (!arquivo.endsWith(".js")) continue;
61
+
62
+ const filePath = path.join(subPath, arquivo);
63
+ await import(`file://${filePath}`);
64
+ }
65
+ });
66
+ });
67
+ });
68
+ };
@@ -0,0 +1,45 @@
1
+ import { Client, GatewayIntentBits, Collection } from "discord.js";
2
+ import "dotenv/config";
3
+ import handler from "./handler/index.js";
4
+
5
+ const client = new Client({
6
+ intents: [
7
+ GatewayIntentBits.Guilds,
8
+ GatewayIntentBits.GuildMessages,
9
+ GatewayIntentBits.MessageContent,
10
+ GatewayIntentBits.GuildMembers,
11
+ GatewayIntentBits.GuildVoiceStates,
12
+ ],
13
+ });
14
+
15
+ export default client;
16
+
17
+
18
+ const prefix = process.env.PREFIX || "!";
19
+ client.prefixCommands = new Collection();
20
+ handler(client);
21
+
22
+ client.on("messageCreate", (message) => {
23
+ if (
24
+ message.author.bot ||
25
+ !message.guild ||
26
+ !message.content.startsWith(prefix)
27
+ ) return;
28
+
29
+ const args = message.content.slice(prefix.length).trim().split(/ +/);
30
+ const comando = args.shift().toLowerCase();
31
+
32
+ const cmd = client.prefixCommands.get(comando);
33
+ if (!cmd) {
34
+ return message.reply("🤨 Esse comando não existe não, meu nobre.");
35
+ }
36
+
37
+ try {
38
+ cmd.run(client, message, args);
39
+ } catch (err) {
40
+ console.error(err);
41
+ message.reply("💀 Deu ruim ao executar o comando.");
42
+ }
43
+ });
44
+
45
+ client.login(process.env.TOKEN);
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "discordjs-gen",
3
+ "version": "",
4
+ "description": "Prefix",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "dev": "node ."
9
+ },
10
+ "keywords": [],
11
+ "author": "",
12
+ "license": "ISC",
13
+ "type": "module",
14
+ "dependencies": {
15
+ "discord.js": "^14.25.1",
16
+ "djs-template-gen": "^2.0.1",
17
+ "dotenv": "^17.2.3"
18
+ }
19
+ }
@@ -0,0 +1 @@
1
+ TOKEN=
@@ -0,0 +1,12 @@
1
+ import * as Discord from "discord.js";
2
+
3
+ export default {
4
+ name: "ping",
5
+ description: "Veja a latência da aplicação.",
6
+ type: Discord.ApplicationCommandType.ChatInput,
7
+
8
+ run: async (client, interaction) => {
9
+ const ping = client.ws.ping;
10
+ interaction.reply(`**O ping do bot é ${ping}ms**`);
11
+ },
12
+ };
@@ -0,0 +1,6 @@
1
+ import client from '../../index.js';
2
+ import { Events } from 'discord.js';
3
+
4
+ client.on(Events.ClientReady, () => {
5
+ console.log(`[APP] Aplicação iniciada com sucesso!`)
6
+ })
@@ -0,0 +1,58 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { pathToFileURL } from "url";
4
+
5
+ export default async (client) => {
6
+ const SlashsArray = [];
7
+
8
+ // === SLASH COMMANDS ===
9
+ fs.readdir("./Commands", async (error, folders) => {
10
+ if (error) return console.error(error);
11
+
12
+ for (const subfolder of folders) {
13
+ const files = fs.readdirSync(`./Commands/${subfolder}`);
14
+
15
+ for (const file of files) {
16
+ if (!file.endsWith(".js")) continue;
17
+
18
+ const filePath = pathToFileURL(
19
+ path.resolve(`./Commands/${subfolder}/${file}`)
20
+ ).href;
21
+
22
+ const command = (await import(filePath)).default;
23
+ if (!command?.name) continue;
24
+
25
+ client.slashCommands.set(command.name, command);
26
+ SlashsArray.push(command);
27
+ }
28
+ }
29
+ });
30
+
31
+ // === EVENTS ===
32
+ fs.readdir("./Events", async (error, folders) => {
33
+ if (error) return console.error(error);
34
+
35
+ for (const subfolder of folders) {
36
+ const files = fs.readdirSync(`./Events/${subfolder}`);
37
+
38
+ for (const file of files) {
39
+ if (!file.endsWith(".js")) continue;
40
+
41
+ const filePath = pathToFileURL(
42
+ path.resolve(`./Events/${subfolder}/${file}`)
43
+ ).href;
44
+
45
+ await import(filePath);
46
+ }
47
+ }
48
+ });
49
+
50
+ // === REGISTER SLASH ===
51
+ client.on("ready", async () => {
52
+ client.guilds.cache.forEach(guild => {
53
+ guild.commands.set(SlashsArray);
54
+ });
55
+
56
+ console.log("🚀 Slash commands carregados!");
57
+ });
58
+ };
@@ -0,0 +1,19 @@
1
+ import * as Discord from "discord.js";
2
+ import handler from "./handler/index.js";
3
+ import "dotenv/config";
4
+ const client = new Discord.Client({ intents: [ Discord.GatewayIntentBits.Guilds ] });
5
+
6
+ export default client;
7
+
8
+ client.on('interactionCreate', (interaction) => {
9
+ if(interaction.type === Discord.InteractionType.ApplicationCommand){
10
+ const cmd = client.slashCommands.get(interaction.commandName);
11
+ if (!cmd) return interaction.reply(`Error`);
12
+ interaction["member"] = interaction.guild.members.cache.get(interaction.user.id);
13
+ cmd.run(client, interaction);
14
+ }
15
+ })
16
+
17
+ client.slashCommands = new Discord.Collection()
18
+ handler(client);
19
+ client.login(process.env.TOKEN);
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "discordjs-gen",
3
+ "version": "",
4
+ "description": "Slash",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "dev": "node ."
9
+ },
10
+ "keywords": [],
11
+ "author": "",
12
+ "license": "ISC",
13
+ "type": "module",
14
+ "dependencies": {
15
+ "discord.js": "^14.25.1",
16
+ "djs-template-gen": "^2.0.1",
17
+ "dotenv": "^17.2.3"
18
+ }
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "discordjs-gen",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Gerador de templates para bots Discord.js",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",