Giter VIP home page Giter VIP logo

discordjs-v14-template's Introduction

Discordjs-v14-Template

Features:

  • Advanced DJS v14 Handler
  • Supports Only Slash Commands Now Supports Legacy Commands as well!!!
    • Legacy commands are meant for bots which are in less than 100 guilds.
      • If you plan to use this in more than 100 guilds, You will have to apply for the MessageContent Intent through Discord.
      • Legacy Commands are meant for the developer of the bot only!
    • Cooldowns enabled on Legacy Commands
    • Cannot run any interaction commands in Bot's DMs
    • Supports Cooldowns
      • Supports Component Cooldowns
  • Executes the bot In a Base Class
  • Custom Handler for Components
  • Custom Handler for Pagination Embeds
  • Sends an embed to the guilds system channel when a member joins and leaves.
  • Sends a message to the DevChannel when the bot is added to a new guild (and removed).
  • Added the ability to block guilds from using/inviting the bot.
    • Will be adding ability for users to appeal directly in Bot's DM's (Will be checking to see if it is the owner of the appealed guild).
  • I am not adding a reload command due to having too many issues with the function.

Logs Everything to the console when starting

Imgur

Easy to Read

Slash Commands:

  • Example Location of command: "./src/commands/(category)/(command)"
const { SlashCommandBuilder, PermissionsFlagsBits } = require("discord.js");

module.exports = {
    owner: boolean, //  whether command can only be used by the bot owner?
    developer: boolean, // weather the command is for developer guild or global: true or false
    category: "category",
    cooldown: Number,
    data: new SlashCommandBuilder()
        .setName('name') // command name - Must be lowercase!!
        .setDescription('description') // command description
        .setDefalultMemberPermissions(PermissionsFlagsBits.<permission>), // member permissions
  async execute (interaction, client) => {
    // Code here
  },
};

Legacy Commands:

  • Example Location of command: "./src/legacyCommands/(category)/(command)"
module.exports = {
    // The following properties can be in any order and Required options are NAME and EXECUTE function.
    name: "name",
    description: "description",
    category: "category",
    cooldown: Number, // how many seconds to wait for the command to be used again.
    owner: boolean, // whether command can only be used by the bot owner?
    enabled: boolean, // whether the command can be executed?
    aliases: [], // other words that can activate this command. separate with commas: ["test", "te", "t"]
  async execute (interaction, client) => {
    // Code here
  },
};

Components:

  • Example Location of component: "./src/components/(type)/(category)/(command)/(component)"
  • type: button/ select menu/ modal
  • category: should match the command category
  • command: folder is named the same as the command name
  • component: file that matches the custom id that you created
module.exports = {
    cooldown: Number,
    data: {
      id: "custom_id", // Must be lowercase
    },
  async execute (interaction, client) => {
    // Code here
  },
};

Getting Started

Click Use this template at the top of this page or fork the repo to your own profile.

  • Rename .env.example to .env (THIS FILE CANNOT HAVE ANY SPACES)

    • REQUIRED:

      • Paste in your BotToken and AppID from the Discord Developer Portal
      • Insert your Developer Guild ID for testing purposes in DevGuild
      • Insert a channel id of your choosing to send logs to in DevChannel
      • Insert your own UserID as BotOwnerID
        • If this is not done, commands with ownerOnly will not function and your project will error and crash.
      • Insert your mongoose connection string as Connect, Get your free connection string Here
        • If you don't know how to get this string, there are videos on this like this one
      • Insert your desired legacy command prefix as Prefix.
  • After you have edited and saved the env file to your needs, you are ready ready to start the bot!

Important installation prerequisites for MACOS users!

  • In order to install certain packages namely: node-canvas, the following is REQUIRED.
  • Please install homebrew from the terminal using the following command:
    • Please copy and paste these commands exactly into a terminal!
      • /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
      • arch -arm64 brew install pkg-config cairo pango libpng jpeg giflib librsvg
    • These commands do take a while to download and install so be patient.
    • After the second one is finished, it will tell you to export a few paths to finish as shown below. Please do these or it won't work. Imgur

  • Install all dependencies with npm install << Remember, DO NOT INCLUDE ANY PACKAGE NAMES HERE!
  • Run the bot with nodemon.
  • Customize the project to your liking and enjoy!

  • Member add event fires a canvas to welcome the new member.
  • For the member remove events to work, the guild MUST have the System Channel enabled.

Found any bugs or have any suggestion about the template? Create an issue or pull request!

discordjs-v14-template's People

Contributors

peter-mj-parker avatar needhamgary avatar dexi22 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.