Make Your Own Discord Bot | Command Handler

Make Your Own Discord Bot | Command Handler

CodeLyon

4 года назад

47,113 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

No Name
No Name - 24.06.2022 09:11

Now the Russian-speaking discord servers is a bastard habitat.discord server does not play any role.only from the occupancy of the bastard himself

Ответить
No Name
No Name - 01.02.2022 09:04

Discord disappointed. There are a bunch of characters of different sorts. There are not only characters sitting in the discord itself, there are also the persons serving the discord itself (that is, this is the technical support of the discord itself and everyone connected with it). This discord is praised from all sides. This is partly true, but there is a downside to this discord. Which few people talk about. Being in this discord can be fraught for some. Better think twice. Is it worth going to this discord? And what do you need from this discord?

Pros:
1) can get caught in places, but not always a normal team for communication on different topics;
2) passing raids in games that cannot be passed without communication, even if you try;
3) designed for cooperative games;

Minuses:
1) in the discord there is no "confidentiality" from the word at all .;
2) different types of characters can be caught in the discord (criminals, hackers, rich characters, humorists and characters who don't care about everything and the technical support of the discord itself), as well as young people who are not quite adequate .;
3) the attendants of the discord itself who follow the discord itself do not follow their own rules from the word at all. (Technical support and everyone who is associated with the discord).
4) in discord, only "selected" characters can scold someone, swear at someone, and so on. Otherwise, they will mix the whole discord with shit in the literal sense of the word.
5) communication with a friend on the discord is disclosed by the hackers themselves and the discord service personnel. The secrecy of correspondence is not respected at all.
6) if you start swearing with someone, then his defenders who have nothing to do with swearing will crawl out, and the persecution will start from their side, and after that absolutely the entire discord is connected.
7) hackers and "knocked down on their heads" (they can and will pretend to be) comedians begin to look for people via the Internet to annoy them at home. Seeing a discord blows their heads completely.
8) in discord, not only children, but also adults (pretending to be fools) take part in this.

SO FOLLOW WHAT YOU SAY AND TO WHOM YOU SPEAK.

PS: at the moment, there is no need to be present in the discord. There is a certain society that has its own laws and rules at the moment. They will mix anyone with shit. either you (the group united) with shit will mix or do not knowing who at its discretion).

P.S: this is a kind of group that found its own cozy little world in discord and choose new ones and evaluate them, then they draw conclusions, and then the consequences.
"Cozy little world"

Here we are talking about the Russian language discord.

Russian Federation (RF)

Russian Discord Problem

Ответить
H H
H H - 12.03.2021 21:24

can you make a video on how to keep your bot online 24/7

Ответить
MASTER DELUXE
MASTER DELUXE - 21.02.2021 09:01

The ` ` is called ticks i think Yes i am pretty sure

Ответить
Sephstar Offical
Sephstar Offical - 17.10.2020 19:05

Its giving me an error..
bot.commands.get('m').execute(message, args);
^
TypeError: Cannot read property 'execute' of undefined

Ответить
ash
ash - 11.10.2020 04:05

Thank god your using a switch statements I saw someone use if and else it was absolute cancer

Ответить
Ben
Ben - 28.09.2020 05:14

commandFiles is not defilned, help please

Ответить
Weasel AU
Weasel AU - 26.09.2020 12:31

TypeError: Cannot read property 'set' of undefined
at Object.<anonymous> (D:\Discord Bot OFFT\index.js:15:18)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47

Ответить
king gengar yt
king gengar yt - 06.09.2020 20:14

let botMsg = await message.channel.send("〽️ Pinging")

botMsg.edit({ embed: {
title: "📶 Ping",
description: [
"**Server**: `" + (botMsg.createdAt - message.createdAt) + "ms`",
"**API**: `" + Math.round(client.ping) + "ms`",
"**Uptime**: `" + msToTime(client.uptime) + "`"
].join("\n"),
color: config.color,
footer: { text: "Requested by " + message.author.tag, icon_url: message.author.displayAvatarURL },
timestamp: new Date()
}}).catch(() => botMsg.edit("🆘 An unknown error occurred. Do I have permission? (Embed Links)"));
}

,function msToTime(ms){
days = Math.floor(ms / 86400000); // 24*60*60*1000
daysms = ms % 86400000; // 24*60*60*1000
hours = Math.floor(daysms / 3600000); // 60*60*1000
hoursms = ms % 3600000; // 60*60*1000
minutes = Math.floor(hoursms / 60000); // 60*1000
minutesms = ms % 60000; // 60*1000
sec = Math.floor(minutesms / 1000);

let str = "";
if (days) str = str + days + "d";
if (hours) str = str + hours + "h";
if (minutes) str = str + minutes + "m";
if (sec) str = str + sec + "s";

return str;

Ответить
Echo Matmat
Echo Matmat - 30.08.2020 00:58

I just put a const { message } = require('discord.js') and it actually work with the command handler

Edit: i just puted at ping.js

Ответить
Funminotaur3880
Funminotaur3880 - 26.08.2020 18:35

I don't thinks it is really smart to show your token

Ответить
Vulre
Vulre - 13.08.2020 06:11

My trash bot dooesntttt go onlinee

Ответить
F.G.P YT
F.G.P YT - 07.08.2020 20:22

when I run with the cmd I get "cannot read property 'Client' of undefinied". Help me

Ответить
dokblack
dokblack - 31.07.2020 11:44

how to install this?

Ответить
Echo Matmat
Echo Matmat - 30.07.2020 23:40

When i type the command it doesn't respond

Ответить
Airoez
Airoez - 27.07.2020 21:14

im getting error module_not_found

Ответить
blendjam
blendjam - 23.07.2020 12:01

I have a command:
!start
Bot sends some text:
then user sends:
(some text without prefix)

So my question is how do I call a function after the !start command and have access to the Word sent by the user. Like the fight bot.

Ответить
Anonymous Misnomer
Anonymous Misnomer - 21.07.2020 06:17

I get an error when loading and also I get errors in my command files that args is an unused declaration.

Ответить
Crunchiest
Crunchiest - 20.07.2020 05:03

What theme are you using on Visual Studio Code?

Ответить
French Noodles
French Noodles - 16.07.2020 00:00

may i ask what theme do you use ? because mine doesnt look as good and im trying to make vs code look more appealing

Ответить
Swaggz Playz
Swaggz Playz - 13.07.2020 13:21

anyone know whats wrong with this?
name:'Info',
description: "Helps with infomation",
execute(message, args){
case :"info"
if(args[1] === 'version';{

Ответить
amphonix
amphonix - 09.07.2020 12:51

Hey my bot accepts many prefixes like i have kept my prefix as = but it also accepts -, +, >, <, how do i fix this?

Ответить
Lorenzo Garese
Lorenzo Garese - 06.07.2020 00:14

Is there any way I could write commands on a console and the bots responds correctly to those commands?

Ответить
Hayder Mohammed
Hayder Mohammed - 04.07.2020 17:09

why do i feel like he is depressed

Ответить
mile.
mile. - 24.06.2020 21:29

how do i make a help?

Ответить
Wlox gG
Wlox gG - 23.06.2020 01:58

the command handler isnt working somehow it doesnt give me any errors but the bot doesnt replies to the commands please help

Ответить
Kieran Hernandez
Kieran Hernandez - 21.06.2020 18:38

Whenever I run node . terminal says
const fs = require ('fs');
^

SyntaxError: Identifier 'fs' has already been declared
i'm not sure what i'm doing wrong if anyone could help me that would be great!

Ответить
Isa
Isa - 21.06.2020 09:25

const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
^

TypeError: fs.readdirSync is not a function

Help me pls

Ответить
Sean
Sean - 19.06.2020 21:05

The switch(args[0]) section is unnecessary. You'd have to update it every time you add a new command.
Do this instead:
const command = bot.commands.get(args[0]);
if(command){
command.execute(message, args);
}
else {
message.reply(`The command ${args[0]} wasn't recognized.`);
}
Now you don't have to update anything if you make new commands. They'll work as long as you add them to your commands structure
I haven't tried using Discord.Collection, myself, so if commands.get() throws an error instead of returning null/undefined, then do it like this:
try {
const command = bot.commands.get(args[0]);
command.execute(message, args);
}
catch (error){
message.reply(`The command ${args[0]} wasn't recognized.`);
}

Ответить
Pex
Pex - 16.06.2020 20:04

Btw if you want it to only answer when you use the prefix do if(!message.content.startsWith (PREFIX)) return; before the switch command worked for me also change PREFIX with the name of the const your prefix is in

Ответить
KortGrabb
KortGrabb - 16.06.2020 14:39

Before saying its fake.. actually follow the tutorial and do it RIGHT bc it works

Ответить
April_
April_ - 15.06.2020 22:52

Faker. Got loads of errors went to a coding server and its not even valid javascript acording to 2 persons. >:(

Ответить
Shwibi
Shwibi - 11.06.2020 14:43

The back slash quotations you were mentioning are called "backticks"

Ответить
Carla Garrucho Rendeiro
Carla Garrucho Rendeiro - 10.06.2020 00:25

is cmder good? i got a warning virus

Ответить
Bacon APo?
Bacon APo? - 09.06.2020 01:22

a

Ответить
Mick G
Mick G - 06.06.2020 07:12

"and its just going to.... crash" xD i caught the error right as you left the visual studio screen. nice video tho :)

Ответить
Jacob Tabanian
Jacob Tabanian - 05.06.2020 08:49

how about making site monitors? Like webscraping but anytime the webscraper detects anything it sends it to the server

Ответить
DrawdeZiur
DrawdeZiur - 31.05.2020 02:58

v11
v12
?

Ответить
R2
R2 - 30.05.2020 12:53

SyntaxError: Unexpected token 'case' ?

Ответить
Reece Wong
Reece Wong - 29.05.2020 21:34

What would the code for kicking look using the command handler, I tried doing something but it keep there was an error?

Ответить
Zeradris
Zeradris - 29.05.2020 17:40

help bot.commands.get('rules').execute(message, args);
^

TypeError: Cannot read property 'execute' of undefined

Ответить
R2
R2 - 28.05.2020 12:44

bot is not defined :DD ?

Ответить
Zeradris
Zeradris - 28.05.2020 12:05

btw does this not work with embeds? i've had problems with embeds it doesnt work

Ответить
lushkiwi
lushkiwi - 27.05.2020 22:31

What about async functions? how do you make this work with stuff like axios? That's the main thing im struggling with...

Ответить
lushkiwi
lushkiwi - 26.05.2020 23:54

what if you need to use some libraries, like jimp? do you need to require it in the separate file, or index.js?

Ответить
Lilyianna
Lilyianna - 24.05.2020 00:28

it does work for me

Ответить
Bottle o' Games
Bottle o' Games - 23.05.2020 07:08

im getting this error please help
index.js:73
Bot.commands.get('Clear').execute(message, args);
^

ReferenceError: message is not defined
nvm fixed it
thx for the vid btw but PLEASE make the permissions video

Ответить