Skip to content

feme12/Discord-bot-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 Discord Bot Template

  • Base setup for a Discord bot using discord.js, dotenv, and commandkit 🚀
  • Made by feme12 & goldmen1131 👥

📦 Setup

  • Run this command to install all packages:
    npm i
  • Go into the example.env file, rename it to .env, and add your Discord bot token. Example:
    TOKEN=MTE3NTE5NjE0MTMxMTIzMDAzMw.G8BOqk.ZvqEW9vhS4YNMJQVKLDTO4INbdq87FJ3JRLzBY

🛡️ Guild Manager

  • Used to lock down your bot to only certain Discord servers.
  • You can edit the config.js to your liking.
  • Change enabled to true to use it or to false to disable it.
  • You can add guilds like this: ["GUILD1ID", "GUILD2ID"]
  • You can add users like this too: ["USERID1", "USERID2"]
export const guild_manager = {
    "enabled": false,
    "guilds": [""],
    "user_ids": [""]
}

📜 Command Template src/commands/template.js

import { EmbedBuilder, SlashCommandBuilder, TextChannel } from 'discord.js';

/** @type {import('commandkit').CommandData}  */
export const data = new SlashCommandBuilder()
    .setName('template') // DO NOT HAVE SPACES OR CAPS!!!
    .setDescription('This is a template command.') // Description that shows up.

/**
 * @param {import('commandkit').SlashCommandProps} param0 
 */
export const run = async ({ interaction }) => {
    interaction.reply("Hello, this is a template command.")
};

/** @type {import('commandkit').CommandOptions} */
export const options = {
    // https://commandkit.js.org/typedef/CommandOptions  
};

🎉 Event Template src/events/ready/template.js

/** * @param {import('discord.js').Client} client */
export default (client) => {
    console.log(`${client.user.tag} is online!`.green);
}

✅ Validations Template src/validations/template.js

module.exports = ({ interaction, commandObj, handler }) => {
  if (interaction.user.id === '123123123123123' ) { // Check the user id.
    interaction.reply({
      content: "You are not allowed to run commands.",
      ephemeral: true,
    });

    return true; // True to prevent command execution, false to allow it.
  }
};

🐞 Reporting Bugs

If you encounter any bugs or issues while using this template, please submit an issue on GitHub using the bug report template. Your feedback is valuable and helps improve the project! 🛠️

📜 License

This project is licensed under the GNU General Public License v3.0 ✍️