Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Minha index.js, altere como desejar, pegue referências no Código e etc...
- Requisitos: Crie uma pasta chamada "source" e uma Subpasta chamada "cmd"
- Packages: discord.js ( Versão 14.11.0 )
- quick.db ( Versão 1.6.7 )
- better-sqlite3 ( Versão 8.2.0 )*/
- const { InteractionType, Client, Collection, GatewayIntentBits } = require("discord.js");
- const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
- client.login("TOKEN DO BOT");
- const { QuickDB } = require("quick.db");
- const db = new QuickDB();
- module.exports = db;
- const fs = require("node:fs");
- const path = require("node:path");
- const PastaCmd = path.join(__dirname, "./source/cmd");
- const Arquivos = fs.readdirSync(PastaCmd).filter(f => f.endsWith(".js"));
- client.slashCommands = new Collection();
- const arr = [];
- for (const f of Arquivos) {
- const ArquivoDaPasta = path.join(PastaCmd, f);
- const Arquivo = require(ArquivoDaPasta);
- client.slashCommands.set(Arquivo.name, Arquivo);
- arr.push(Arquivo);
- }
- client.on("ready", () => {
- client.application.commands.set(arr);
- console.log(`[Client] ~ Login feito com Sucesso em "${client.user.tag}".\n[FilesLoader] ~ Carregado com Sucesso ${Arquivos.length} Arquivo(s).\n[DataBase] ~ Banco de Dados Pronto!`);
- });
- client.on("interactionCreate", async interaction => {
- if (interaction.user.bot) return;
- if (!interaction.guild) {
- return await interaction.reply({ content: `Me desculpe ${interaction.user.username} ! Mas você só pode executar meus comandos em um Servidor.`, ephemeral: true })
- }
- if (interaction.type === InteractionType.ApplicationCommand) {
- const cmd = await client.slashCommands.get(interaction.commandName);
- if (!cmd) return await interaction.reply(`Algum erro inesperado ocorreu enquanto o Comando ${interaction.commandName} estava sendo Executado! Tente novamente.`);
- await cmd.run(client, interaction);
- }
- });
- client.on("messageCreate", async msg => {
- if (msg.author.bot) return;
- if (msg.content == `<@${client.user.id}>` || msg.content == `<@!${client.user.id}>`) {
- await msg.reply("Olá **${msg.author.username}** !");
- }
- });
- module.exports = client;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement