Giter Site home page Giter Site logo

tfagaming / discordjs-v14-bot-template Goto Github PK

View Code? Open in Web Editor NEW
333.0 6.0 147.0 6.14 MB

A Discord bot with commands, components and events handler based on the latest discord.js v14 and fully written in JavaScript.

License: GNU General Public License v3.0

JavaScript 100.00%
bot-template discord-bot discord-js discord-js-v14 discord-v14 discord-bot-template discord-command-handler discordjs discordjs-v14 discord

discordjs-v14-bot-template's Introduction

Hi there, I'm T.F.A. 👋



Hi there, I'm T.F.A, an 18-year-old self-taught developer. I like making open-source projects for Discord bots and Minecraft plugins. When I started coding, I used to program Discord bots in JavaScript and then I learned TypeScript for the types and fewer errors and debugging when running a bot. Now, I like making Minecraft plugins using Java.

If you wonder why my name is "T.F.A", it's my real-life name. The T is my first name, and the F and A is my last name.

Skills & Tools



Statistics

My Best open-source projects

Discord Server

discordjs-v14-bot-template's People

Contributors

adamt20054 avatar atreeshine avatar codeblitz97 avatar codixer avatar panintegralus avatar provant15 avatar saunakghosh10 avatar slendertaker avatar tfagaming avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

discordjs-v14-bot-template's Issues

Command Cooldown Request

Hey, I tried like 50 things and asked chatgpt for help but I just simply can't get a command cooldown to work.
Is it possible you guys make it so you can just like type "cooldown: 60000" (in milliseconds) in the "structure:" section in slash commands and maybe like for prefix commands too? Or if that already is a thing please let me know because I am unaware of it

Unable to load application commands

When i run node .
it gives me this error before starting the bot:
[ERROR] Unable to load application commands to Discord API: Cannot read properties of undefined (reading 'guild')

I haven't used 2 diffrent bots for token and id and havn't touched the slash commands, so im a bit lost here.

What code can i send to help solve this?

How can i add options?

I tried using the old v13 one but that didnt work... heres what i tried doing:

    options: [
    {
      name: "destination",
      description: "channel to send it in",
      type: "CHANNEL",
      channelTypes: ["GUILD_TEXT"],
      required: true,
    },
],

Bot crashes upon any and all DMs

events/Guild/messageCreate.js initiates the constant variable 'prefix' before checking to see if the message was sent in a guild text channel. Because there is no guild.id object for direct messages, this crashes the bot.

I start the bot on repl.it

But only ping and mymodal commands show up nothing else please explain this to me I already brought up this issue.

how to make add slash command options?

i've tried

const { SlashCommandBuilder } = require("discord.js");

module.exports = {
    name: "test",
    description: "test",
    type: 1,
    options: [],
    permissions: {
        DEFAULT_MEMBER_PERMISSIONS: "SendMessages"
    },
    run: async (client, interaction, config, db) => {
        const data = new SlashCommandBuilder()
        .setName('echo')
        .setDescription('Replies with your input!')
        .addStringOption(option =>
            option.setName('input')
                .setDescription('The input to echo back'));
    },
};

but the input option doesnt show up

Node .

when i do node . it says
C:\Users/name\Downloads\DiscordJS-V14-Bot-Template-2.3.0 (2)>node .
node:internal/modules/cjs/loader:452
throw err;
^

Error: Cannot find module 'C:\Users\name\Downloads\DiscordJS-V14-Bot-Template-2.3.0 (2)\index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:444:19)
at Module._findPath (node:internal/modules/cjs/loader:715:18)
at resolveMainPath (node:internal/modules/run_main:26:23)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:24)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
path: 'C:\Users\name\Downloads\DiscordJS-V14-Bot-Template-2.3.0 (2)\package.json',
requestPath: 'C:\name\eriks\Downloads\DiscordJS-V14-Bot-Template-2.3.0 (2)'
~

pleasr fix

ID SyntaxError

I am not very talented for this but I copied my bot ID from discord and then put it in the config.js file and then this happens:
B23C292B-AC86-4E05-A0BA-03DF65267F52
How can I fix this ?
(I run the program on replit)

node . error

I have all the dependencies but i have the following error:

`C:\Users\Rocío\Videos\DiscordJS-V14-Bot-Template-1.6.0\node_modules\bindings\bindings.js:121
        throw e;
        ^

Error: The module '\\?\C:\Users\Rocío\Videos\DiscordJS-V14-Bot-Template-1.6.0\node_modules\better-sqlite3\build\Release\better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 108. This version of Node.js requires
NODE_MODULE_VERSION 102. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1179:18)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at bindings (C:\Users\Rocío\Videos\DiscordJS-V14-Bot-Template-1.6.0\node_modules\bindings\bindings.js:112:48)
    at new Database (C:\Users\Rocío\Videos\DiscordJS-V14-Bot-Template-1.6.0\node_modules\better-sqlite3\lib\database.js:48:64)
    at Database (C:\Users\Rocío\Videos\DiscordJS-V14-Bot-Template-1.6.0\node_modules\better-sqlite3\lib\database.js:11:10)  
    at new SqliteDriver (C:\Users\Rocío\Videos\DiscordJS-V14-Bot-Template-1.6.0\node_modules\quick.db\out\drivers\SqliteDriver.js:8:25)
    at new QuickDB (C:\Users\Rocío\Videos\DiscordJS-V14-Bot-Template-1.6.0\node_modules\quick.db\out\index.js:17:28) {      
  code: 'ERR_DLOPEN_FAILED'
}
`

Cannot find command handler path. (Only happens on VPS)

I cloned your repo on my local machine. Works perfect. Soon as I clone it on my VPS I get a path error:

Error: ENOENT: no such file or directory, scandir './src/commands/'
    at readdirSync (node:fs:1451:3)
    at module.exports (/home/ubuntu/DiscordJS-V14-Bot-Template/src/handlers/commands.js:10:24)
    at module.exports.start (/home/ubuntu/DiscordJS-V14-Bot-Template/src/class/ExtendedClient.js:37:9)
    at Object.<anonymous> (/home/ubuntu/DiscordJS-V14-Bot-Template/src/index.js:6:8)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  errno: -2,
  syscall: 'scandir',
  code: 'ENOENT',
  path: './src/commands/'
} Promise {
  <rejected> Error: ENOENT: no such file or directory, scandir './src/commands/'
      at readdirSync (node:fs:1451:3)
      at module.exports (/home/ubuntu/DiscordJS-V14-Bot-Template/src/handlers/commands.js:10:24)
      at module.exports.start (/home/ubuntu/DiscordJS-V14-Bot-Template/src/class/ExtendedClient.js:37:9)
      at Object.<anonymous> (/home/ubuntu/DiscordJS-V14-Bot-Template/src/index.js:6:8)
      at Module._compile (node:internal/modules/cjs/loader:1218:14)
      at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
      at Module.load (node:internal/modules/cjs/loader:1081:32)
      at Module._load (node:internal/modules/cjs/loader:922:12)
      at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
      at node:internal/main/run_main_module:23:47 {
    errno: -2,
    syscall: 'scandir',
    code: 'ENOENT',
    path: './src/commands/'
  }
}

error in package.json

I tried opening a pull request but it wasnt working for me so im opening an issue.

In line 18 in package.json is missing "," at the end. this can be fixed by changing the line text to ""ms": "^2.1.3","

Error reading client

TypeError: Cannot read properties of undefined (reading 'set')
at /app/handlers/application_commands.js:72:33

MongoDB problem: ReplicaSetNoPrimary

I forked a bot on repl.it and I didn't change anything, but config.js like it was said in guide. I don't understand why there's problem, because I searched it on internet and I've done what others said - I added my IP on whitelist and it's not working. Please, help me.

image

Fix package.json

Hello,
For success install you need to fix little your package.
Here is full working package.json
{ "name": "discordjs-v14-bot-template", "version": "14.0.0", "description": "A Discord Bot template built by T.F.A#7524!", "main": "index.js", "scripts": { "start": "node index.js" }, "keywords": [], "author": "T.F.A#7524", "license": "ISC", "dependencies": { "better-sqlite3": "^8.2.0", "colors": "^1.4.0", "discord-api-types": "^0.36.2", "discord.js": "^14.5.0", "mathjs": "^11.7.0", "moment": "^2.29.4", "mongoose": "^6.4.4", "ms": "^2.1.3", "node-fetch": "^2.6.7", "pretty-ms": "^6.0.1", "quick.db": "^9.0.5", "super-djs": "^1.7.4" } }

Problem with permissions

I place in DEFAULT_MEMBERS_PERMISSION the string "Administrator" but allow all users to execute the command.
Any way to solve it?

webstorm64_VQX3bMFynu

I wants to use this command from v13

I hade a bot on v13 but now im using ur handler template and i want to use this command how can i do it

const { DiscordTogether } = require('discord-together');

module.exports = {
name:'youtubetogether',
aliases: ['youtube'],
description:'Make Youtube Together',
run: async (client, message, args,prefix) => {

if(!message.member.permissions.has("USE_ACTIVITIES")) return message.channel.send(`You Musst Have USE ACTIVITIES permission.`)
    if(message.member.voice.channel) {
        client.discordTogether.createTogetherCode(message.member.voice.channel.id, 'youtube').then(async invite => {
          return message.channel.send(`Click on the link to start! ${invite.code}`);
        });
      } else {
        if (!message.member.voice.channel) {
            return message.reply('**Please Join Vc At First!**')
        }
      }
}

}

and also i wants change

module.exports = {
config: {
name: "",
description: "",
usage: ""
},

to somthing like this

module.exports = {
name:'youtubetogether',
aliases: ['youtube'],
description:'Make Youtube Together',
run: async (client, message, args,prefix) => {

i main without config things if i cudent wcplain im in ur server BXINO#6217

Create new command

Hi!

I'm trying to create a new simple command for testing.
Here is my code :

const { ChatInputCommandInteraction, SlashCommandBuilder } = require('discord.js');
const ExtendedClient = require('../../../class/ExtendedClient');

// Pour envoyer un e-mail
//const nodemailer = require('nodemailer');


module.exports = {
    structure: new SlashCommandBuilder()
        .setName('Mail')
        .setDescription('Test d\'envoi de mail'),
    /**
     * @param {ExtendedClient} client 
     * @param {ChatInputCommandInteraction} interaction 
     */
    run: async (client, interaction) => {
        await interaction.reply({
            content: 'Mail envoyé',
            ephemeral: true
        });
    }
};

As you can see, It's just a respond to a message. I also downloaded nodemailer using npm.
Here is a part of the error I'm getting :

ExpectedConstraintError > s.string.regex
  Invalid string format

  Expected: expected /^[\p{Ll}\p{Lm}\p{Lo}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+$/u.test(expected) to be true

  Received:
  | 'Mail'

Do you know what's the problem?
Sorry if my English isn't perfect. I'm French.

test.js not working?

A function in the code seems to not work? This is the user command/app called ./commands/message/test (See images)

image
image

Modal Error.

Eeverything works but when i click submit the modal gives error. Console is clear and everything works. how do i remove the error in modal
image_2022-09-10_144806837

subcommands

you could make subcommands, to be able to name the command with a space for example: Server Icon, not Servericon

Cannot Run The Bot in Replit

I been receiving the same response I cannot run the bot and for some reason the bot went online while this response:

Screenshot_20220811-101157

The Bot is Running but I keep saying this and a moment later it turned off
Screenshot_20220811-102337

bit of a problem [off-topic](sort of)

I'm trying to make it so that when someone joins, it gives them a role but it isnt working
here's the src

const { EmbedBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder } = require("discord.js");
const client = require("../../index");
const config = require("../../config.js");

module.exports = {
  name: "WelcomeSystem"
};

client.on('guildMemberAdd', member => {
    console.log('User: ' + member.user.username + ' has joined the server!');
    member.roles.add("1046263875382808629");
});

Show only text channels when using options for slash commands

I tried using

channelTypes: ["GUILD_TEXT"],

but that didn't work and I would like to know how to make it so the user can only select text channels in this new versio

also is it still something like const thingy = interaction.options.getString('blahblahblah');
(found out it is but with numbers its getInteger)

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.