#development
1 messages ยท Page 826 of 1
hi make register in discord api that is the errors
I'm dad
Whatever you are doing, stop doing it so much that you are being ratelimited
(node:217) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'size' of undefined
at DBLAPI.postStats (/rbd/pnpm-volume/1e1e1444-03f1-4064-9b93-66c118075417/node_modules/.registry.npmjs.org/dblapi.js/2.4.0/node_modules/dblapi.js/src/index.js:149:79)
at DBLWebhook.<anonymous> (
:7)
at DBLWebhook.emit (events.js:196:13)
at DBLWebhook._emitListening (/rbd/pnpm-volume/1e1e1444-03f1-4064-9b93-66c118075417/node_modules/.registry.npmjs.org/dblapi.js/2.4.0/node_modules/dblapi.js/src/webhook.js:40:10)
at Object.onceWrapper (events.js:284:20)
at Server.emit (events.js:196:13)
at emitListeningNT (net.js:1260:10)
at processTicksAndRejections (internal/process/task_queues.js:83:17)
at process.runNextTicks [as _tickCallback] (internal/process/task_queues.js:58:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:828:11)
(node:217) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:217) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.``` Get this error when I have ```js
dbl.webhook.on('ready', hook => {
console.log(`Discord Bot List Webhook is running at http://${hook.hostname}:${hook.port}${hook.path}`);
dbl.postStats(client.guilds.size)
});```
lol programming in cellphone
That is perfect yes or no
The fact that you sent a password
and you using fingerprints
What password?
Pretty shady
Is that a goddamn selfbot
that basic code
Who are you talking to???
yep, selfbot
Hold on
who is a selfbot
Before you make any accusations
actually, I don't even know what he's trying to achieve
@slender thistle bro I want to talk in dms
not only is it breaking discord ToS but its not even coded well 
Try and see if he actually is
who is a selfbot
Hi all! I'm getting a "Error: Shard 1's Client took too long to become ready." error as well as a weird guild leave event "Shard 1 โ Left a guild called undefined!" from one of my shards. Do you have any idea what could be causing this? It's not a ban, because I got no email, and I get the same error from my computer. What could be causing this? DJS version 11.6.2
You can't prove if he is or not
Why do you want to talk in DMs
bruh
just I need fix my erore
not even good coding
We don't support violating Discord ToS here
If you were gonna self bot, at least do it right
btw I have a help command but im getting this error
smh
Need more than that mate
Ok sorry bro
glitch ayyyyyy
const { MessageEmbed } = require("discord.js");
const { stripIndents } = require("common-tags");
module.exports = {
name: "help",
category: "Info",
description: "Shows you all existing Commands or Info about one single Command",
usage: "[Command]",
run: async (client, message, args) => {
if (args[0]) {
return getCMD(client, message, args[0]);
} else {
return getAll(client, message);
}
}
}
function getAll(client, message) {
const embed = new MessageEmbed()
.setColor("RANDOM")
const commands = (category) => {
return client.commands
.filter(cmd => cmd.category === category)
.map(cmd => `\`${cmd.name}\``)
.join(", ");
}
const info = client.categories
.map(cat => stripIndents`**${cat[0].toUpperCase() + cat.slice(1)}** \n${commands(cat)}`)
.reduce((string, category) => string + "\n" + category);
return message.channel.send(embed.setDescription(info));
}
function getCMD(client, message, input) {
const embed = new MessageEmbed()
const cmd = client.commands.get(input.toLowerCase()) || client.commands.get(client.aliases.get(input.toLowerCase()));
let info = `No information found for command **${input.toLowerCase()}**`;
if (!cmd) {
return message.channel.send(embed.setColor("RED").setDescription(info));
}
if (cmd.name) info = `**Command name**: ${cmd.name}`;
if (cmd.aliases) info += `\n**Aliases**: ${cmd.aliases.map(a => `\`${a}\``).join(", ")}`;
if (cmd.description) info += `\n**Description**: ${cmd.description}`;
if (cmd.usage) {
info += `\n**Usage**: ${cmd.usage}`;
embed.setFooter(`Syntax: <> = required, [] = optional`);
}
return message.channel.send(embed.setColor("GREEN").setDescription(info));
}
snipe time me thinks
thats the command
Sorry
nah, let him be
you will get banned
pls snipe
ooooof
and it seems to be happening on the message.channel.send
not only from here but from discord
Bro
Just set the embed colour in the actual embed
Underneath messageembed type .setColor("GREEN")
actually, that selfbot is programmed so bad that it'll be a miracle if he even sent a message with it
but still, don't make one
I need help how to get role all discord members
bots are easier, better faster and stronger
selfbots are clunky, volatile, limited and forbidden
also you can't bulk retrieve anything with selfbots
Yeah
Plus, bots give you someone to talk to when you are lonely (lmao)
https://corynth.is-inside.me/3GfNrxRj.png How can I lower my memory usage?
holy
no
titles and footers only accept text
https://corynth.is-inside.me/3GfNrxRj.png How can I lower my memory usage?
@golden condor how many servers?
169
lol there's a serious memory leak there
What could be causing it?
it could be anything.
^
I have lavalink music
And this is my package.json
{
"name": "bot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"author": "Cxllm",
"license": "ISC",
"dependencies": {
"discord.js": "^11.6.1",
"express": "^4.17.1",
"express-glitch-keepalive": "^0.2.0",
"simple-youtube-api": "^5.2.1",
"ytdl-core": "^2.0.0",
"random-puppy": "^1.1.0",
"moment": "^2.24.0",
"superagent": "^5.2.2",
"parse-time": "^0.1.4",
"moment-duration-format": "^2.2.2",
"cheerio": "^0.22.0",
"urban": "^0.3.2",
"fs-nextra": "^0.4.7",
"hastebin-gen": "^2.0.5",
"yql": "^1.0.2",
"mathjs": "^6.6.1",
"tinyurl": "^1.1.3",
"node-superfetch": "^0.1.10",
"discord.js-lavalink": "^2.2.3",
"lavalink": "^2.9.0",
"quick.db": "^7.0.0-b22",
"node-opus": "^0.3.2",
"ffmpeg-static": "^4.0.1",
"weather-js": "^2.0.0",
"random-facts": "^1.0.6",
"uuid": "^7.0.2"
},
"repository": {
"url": "stuff"
}
}```
oh my
Do you even use all of those packages
oof
"superagent": "^5.2.2",
"parse-time": "^0.1.4",
"moment-duration-format": "^2.2.2",
"cheerio": "^0.22.0",
if it breaks return them
That's what I did
I ain't doing that ever
@lyric mountain https://corynth.is-inside.me/cUT9o06N.png
An answer
Lmao
SyntaxError: Unexpected token
Rest of code?
@earnest phoenix Mine is fine like this
function play(guild, song) {
check what the ^ points at
I will check my ytdl code
Hold on
I have ytdl and lavalink don't judge me
Still looks like this
function play(guild, song) {
my bot has a channel in client.channels, but not in the actual guild itself, what went wrong? doing client.channels.get("12345").guild.channels.get("12345") returns undefined
my bot has a channel in client.channels
ok, so your bot is trying to search for a channel
but not in the actual guild itself
define that
client.channels.get("12345").guild.channels.get("12345") returns undefined
why not useclient.guilds.get("98765").channels.get("12345")?
no it's not
Ehh
if client.channels.get("12345") returns null then the rest will be null
well it doesnt work anyway
why doesnt this work anymore
@stiff sedge
I think in like v12 you have to use:
msg.guild.emojis.chache.find(r => r.name == emojiname[n])
and client.channels.get("12345") isnt null, but guild.channels.get("12345") is
But then wouldn't null.guild return an error
it'd return undefined afaik
So then null.undefined.channels
probably with an error somewhere

anyway
I'm trying to understand what he meant
@grizzled raven what are you trying to do?
in 5 words or less
why are you getting the same channel twice anyway?
im not
like, client.channels.get(ID) gets the channel
im just saying that the channel isnt logged in guild.channels
so what's the issue?
im just saying that the channel isnt logged in guild.channels
@grizzled raven
but what's the issue? what are you trying to accomplish?
why isnt it logged in guild.channels
@golden condor ur problemo might be cause u host lavalink on glitch atleast what i can see from logs
only one channel is logged in guild.channels
I don't host the node
ok, I understood that, but WHAT is the issue?
I just run the music
i
do you really need to get the guild from a channel retrieval then the the channel again?
just use client.channels.get(ID)
no because messages arent being cached in that channel
and that isnt normal to begin with
what about client.channels.cache.get(ID)?
if you're using d.js v12 then this was one of the changes
lol I still don't get what's your issue
if im using client.channels.get and it works, im not using djs12
if it works why not use it?
can someone help me with this?
ok
im saying im not using v12
yes
should i proceed backwards and repeat what i already said?
no because messages arent being cached in that channel
@grizzled raven
and that isnt normal to begin with
@grizzled raven
start by stating exactly what you're trying to accomplish and what issue you're having
only one channel is logged in guild.channels
@grizzled raven
why isnt it logged in guild.channels
@grizzled raven
only one channel is logged in guild.channels
...
why isnt it logged in guild.channels
WHAT isn't logged in guild.channels?
no only one channel there
thank god tim came
Im confused on whats happening
there is only one channel in the guild cache?
All I see are quoted messages
yes
dafuq
and ghis happens
your turn guys
dafuq
Yup, the situation is FUBAR
I dont think you should put .id at the end
Oh
what I understood until now:
He's having issues retrieving a channel with
client.channels.get(ID).guild.channels.get(ID), but stated thatclient.channels.get(ID)works.For some reason, he refuses to use the working method
client.channels.get().guild is just me getting that guild
it has nothing to do with that
So what are you trying to do with it?
it's v11 btw
client.guild.channels.find(channel => channel.id=== "ID");
there are two channel storages in discord.js: client.channels which contains ALL channels including DMs, and guild.channels which includes channels specific to that guild
@hollow granite it worked, thanks
the issue is that a channel is present in one store, but not in the other, which should always be in both
Am I correct on the code Tim?
but now i have different problem ๐ฆ
wrong variable type
its just var
it must be either a string or GuildEmoji/ReactionEmoji
let seconds = video.length_seconds%60
seconds = seconds < 10 ? "0"+seconds : seconds
const minute = Math.round(seconds/60,0)
const song = {
id: video.id || video.video_id,
title: video.title,
url: video.video_url || "https://www.youtube.com/watch?v=" + video.id,
duration: `${minute}:${seconds}`,
author: {
id: message.author.id,
username: message.author.username
}
}
``` duration is always 'NaN:NaN'
discordjs v12, ytpl, ytdl-core
Just a quick question - are you not allowed to change font color in css for the top.gg website?
you are
wtf am i doign wrong
@elder moss wrong channel
@stiff sedge any errors?
@lyric mountain Wasn't planning on either of those so thanks xd
yeah what tim said
@stiff sedge weren't you supposed to use if (reaction.emoji.name === n)?
and i think because the channel isnt stored in guild channels, the bot doesnt recieve messages there
since you're iterating on every index in that array and getting the value
also, no, emojiname[n] gets the value, n is uust a number
@grizzled raven i have no idea why the channel wouldnt be there, but you could try adding it yourself
guild.channels.set(id,channel)
with js, how can I check if a yt video is invalid (private, deleted...)?
http request it
the video will return a error code if it was deleted or is private
Hello i need help i want to make a total members count in python
Please help ping me when answer
Either client.users if you are caching everything or sum of a list that contains guild.member_count of each of your bot's guild
In python?
Yup
what I said in general, a solution isn't really necessary I just want to see if anyone else at all is experiencing a similar thing because my friend said his bot takes a hell of a long time to login too
@slender thistle thank you so much yooure the BEST!!
Can I use a Discord web hook or do I need to create my own with the website
For what purpose?
Posting votes
you mean getting votes?
Yes
receiving votes is nothing todo with discord webhooks
its just a method used for dbl to send u the votes
if u mean how can i post it using webhooks
Yes
u then have to have a seperate system using discord's webhooks
Ok
hey so
im making a bot
and i need to know how my command
has to be the exact message
because i dont like how message.content.includes works
im using djs 11
yea but then anything after will still run the command
i want it to be that exact message
then message.content === themessage
as an if command?
so like
if message.content === themessage {
message.reply("message")
};```
by "themessage" I mean the actual string to check
i know
but thats what the code is correct
wait is it
bot.on("message", (message) => {
if (message.content === ("themessage")) {
message.reply("message")
};
});```
@lyric mountain
pretty much
it'll only run if someone says themessage
yea ill change it to my command
btw, no need for the extra ()
and you might want to make a command manager, else it'll be hard to add or modify commands later on
so just ```java
if (message.content === "themessage") {
whats a command manager
lol sorry im new to java
ive only done lua before
Basically you have loads of separate files, each one containing code for one command. When someone uses a command, the code from the file is used.
It helps to split code up into readable chunks
are you saying i have to have one manager file, then one for each command and program the manager to start those other files whenever i use node .?
lol sorry im new to java
@naive mantle wait, java?
yes im using java for my bot why
then everything is different
frick.
Do you mean javascript or java?
javascript
meh
javascript javascript
Ah that's alright then
they are different?
javascript IS NOT java
Yeah very
wow
I use javascript so...
anyway how do i run other files from one big file
it's like comparing a skyscrapper with a porsche
oop
anyway how do i run other files from one big file
@naive mantle you import them
Basically you have one file called something like index.js and inside there is some code - a part of this code imports all the files for you
Yeah so in there you just need like 5 lines of code and that imports them all
import * from ('./yourotherfile.js')
But it depends how you want to set up the command manager
Hello how can i make command server-side in python... So it can be used in multiple servers
so like
Hello how can i make command server-side in python... So it can be used in multiple servers
@shadow shale you need a database
i would say import * from ('./command.1.js') implying my file is named command.1.js?
I have suggestion system that saves channel id only for that and if i run it in another server it makes the suggestion id in that saved...
And when anyone change the channel id it will rewrite it
@true ravine import * from ('./command.1.js') if my file was named command.1.js right
and in the same folder
they have to be in the same folder?
And when anyone change the channel id it will rewrite it
@shadow shale you need a database to store configs per guild
they have to be in the same folder?
@naive mantle no, but './afile.js' means that afile.js is in the same folder
How tell me
./ is the same folder
ok
Tell me how to make the database
and that would import the code from that file into the command manager file?
sorry
not you
oh
Ok im patience
@naive mantle I actually used this guide https://discordjs.guide/command-handling/#individual-command-files
no i cant use that
@shadow shale independent of language, you need some kind of database (like PostgreSQL, SQLite, MySQL, etc)
no i cant use that
@naive mantle why?
im using d.js version 11 thats all version 12
It works the same
a lot of the code works have changed
me too
if your code is small, I'd recommend to start using v12 right away
aight so im gonna test the import out
ive tried v12 a lot of the code is harder for me than in v11
but one day you'll have to migrate it due to becoming obsolete
and it's better to migrate while small
As far as I can see nothing in the guide I linked involves code that differs between v11 and v12
The guide is your best bet
https://discordjs.guide/additional-info/changes-in-v12.html#commonly-used-methods-that-changed
Discord.js Guide
Yeah I'm aware of that I'm updating my code to v12 now
Just use the guide it still works
yeah but like, the guide is hard for me to understand
Copy and paste code then
const Discord = require('discord.js');
const bot = new Discord.Client();
bot.on("message", (message) => {
if (message.content.includes(";ping")) {
message.reply("Pong!");
}
});
bot.on("message", (message) => {
if (message.content.includes(";serverinfo")) {
message.reply("\n**server.id** - 656140730963853321 \n**server.name** - [ScD] Scientific Department \n**server.memberCount** - 28 \n**server.ownerID** - 350788382026235905 \n**server.createdAt** - Mon, Dec 16, 2019 9:29 AM");
}
});
bot.on("message", (message) => {
if (message.content.includes(";cmds")) {
message.reply("\n``Command List`` \n`Prefix:` **;** \n \n**serverinfo** - Gives the server information. \n**ping** - Fun command, bot says `Pong!` \n**coinflip** - Flips a coin. \n**cmds** - Sends this command list.");
}
});
bot.on("message", (message) => {
if (message.content === "themessage") {
var array = ['heads','tails']
var choice = array[Math.floor(Math.random() * array.length)]
if (message.content.includes(";coinflip")) {
message.reply(`It's ${choice}!`);
}
};
});```
thats all my code
It's probably the best resource out there aside from the discord.js docs
would that be hard to transfer?
Good plan
You need to uninstall your current discord.js then re install
lol wat
wait
to uninstall all you have to do is npm uninstall discord.js
not manually delete anything
lol ive been doing it the hard way then lmao
the only reason i used v11 is because it used cmd and not powershell
Thank you @lyric mountain thanks for your help
the only reason i used v11 is because it used cmd and not powershell
@naive mantle the terminal you used shouldn't matter
like, powershell is pretty much a cmd v2
powershell is just a cmd with more features
I'm trying to look for a job but I can't find one who can help?
npm init --discord.js@12.0.0 or has it been updated a more recent version
@elder moss this is for help about making a bot not asking to be recruited
v12.0.2 has been released
ok
@naive mantle but atleast give me some suggestions
i dont have any
let h
var h
im a pupil of code let alone could I teach
nvm lol
well, those are the only ones I know of
kuu it says npm ERR! 404 'create-discord.js@12.0.2' is not in the npm registry.
unless you live in brazil, but I guess you don't
Thanks anyway
@naive mantle npm install discord.js
@lyric mountain are they office jobs in Brazil like you need to be in a office?
@elder moss there are homeoffice jobs, but you'd need to search for them
but why look for them in such country?
like, probably in NA there're better options
I don't have the money right now but I just need more money to move to a different country
So if its a home officer and I'm like a different country it doesn't really matter as a long as I'm in contact with them that's all that matters
Office*
pro-tip: you don't want to come to brazil, not with its current finnacial situation
dollar at R$ 5,00
anyway, time to move to #memes-and-media
Yh
holdup
npm ERR! 404 'create-discord.js@latest' is not in the npm registry.
@lyric mountain
do the following:
i said npm init discord.js
k
why cant i use my old folder
then transfer your code to it
why cant i use my old folder
@naive mantle you can, but it's not worth the hassle since your code is still small
ok
ight its downloading now
@lyric mountain i got another error message
i said npm init
which one?
then i said npm init discord.js after i said yes
npm ERR! 404 Not Found - GET https://registry.npmjs.org/create-discord.js - Not found
npm ERR! 404
npm ERR! 404 'create-discord.js@latest' is not in the npm registry.
just dont
dont what
Do anyone know how to make AI chatbot? If yes ping me
do it in this exact sequence:
npm init
npm i discord.js
ok
Do anyone know how to make AI chatbot? If yes ping me
@shadow shale define AI
sigh
Self learning machine
ok, I'll try to explain
are you talking about the thing that dyno does
Please in my dms explain
like you can setup to have a response to certain messages?
I dont want find the text in here tommorow
@shadow shale
cuz that would be hard
making a true AI is almost impossible
like you can setup to have a response to certain messages?
@naive mantle ik but thats not fun
What hosting should I use for under $5?
are you talking about a vps
Yes lol
What hosting should I use for under $5?
@vestal star contabo
it litterally wouldnt be viable to have a true AI chatbot
Ok
the processing power needed
What?
is insane
its 5000 mb for 10$ a month
that's why it's near impossible
ive used machine learning to get it somewhat near
Cantabo had better specs I think
but that was weeks of training
It's private and not renting it atm
oop
I'll check contabo, then if your hosting works for me I'll dm you
contabo really good specs for the cost
@shadow shale https://discordapp.com/channels/264445053596991498/272764566411149314/689566465015153041
It's not impossible, but you'll spend pretty much your entire life researching it to even scratch the "artificial intelligence" concept
How is contabo so cheap?
Oh
they are pretty much the #1 vps service
their dedi prices arent that bad either tbh
But why does Google cloud not have such low prices if they have so many costumers?
so lots of customers + lots of money * actually good CEO = great service
contabo actually cares for their customers
like, you could eat pizza with them
Oh okay, next what plan should I use, that's under $5 usd
Ok
or if you want more speed:
The 300GB storage is good for websites or image storage too which is what i use it for
lol yeah
even the page's style seems like a scam
@lyric mountain
im trying to import
like this
import * from('./command.1.js')
and it keeps saying as and from expected
are you concatting?
import * from ('./command.1.js')
not
import * from('./command.1.js')
isnt that the same thing
I don't think so
from what i've heard, the reason contabo is so cheap is that their cpus are shared and not dedicated, and their ram is possibly a virtualized ssd lmao
so what code do i say
still a good business model
https://adrianmejia.com/getting-started-with-node-js-modules-require-exports-imports-npm-and-beyond/
@naive mantle
ok
import x from y is not supported by default in node.js afaik
unless you enable the experimental flag
ah
or unless you're using typescript
are you sure your code supports that kind of imports?
im trying to import files from my folder but i dont know what code to use
im using visual studio
the import syntax is available starting from node.js v13.2
i just not i selected download current version
ok
v13.11.0
definitely have that
ok, then check this and see if it works
yes, try that
yes
thats a warning, you can ignore it
will my code still work
well the value is never read
i dont know what that means
all i need is for my import to work @mossy vine
im on a tight schedule someone please help
does it work now
no
Hello i desperately need help!
I have 11 shards running with the ShardingManager of Discord.js.
Sometimes a certain shard wont come online and it says "Shard 5's Client took too long to become ready". Also if i restart, always the same shard wont come online.
Even if i let the program run, the shard will eventually retry to get ready, but again tell me that "Shard 5's Client took to long to become ready", in a loop.
Meanwhile i get errors from within the shard saying "bot.connect is not a function" or "Cannot read property prefix of undefined".
All other shards are running fine!
What can it be?
and what is the error
what do you want to do
import the code from those files into that file like a command manager
that is not how you do it
tell me how please
say this is your project structure
folder/
file.js
index.js```
say file.js looks like this
module.exports.coolVariable = 'cool'```
in index.js you can do this
import * as coolThings from "./folder/file.js"
console.log(coolThings.coolVariable) // 'cool'```
my project structure is this
index.js
cmds.js```
or
theyre both in the folder
import { coolVariable } from "./folder/file.js"
console.log(coolVariable) // 'cool'```
of course
yes
this doesnt make sense
how familiar are you with javascript
i literally started yesterday
then jumping into bot development may not be a good idea
thats the reason why i started javascript
ive been getting by fine
this is the only thing that stumped me
just let me explain
i have a folder named bot storage
in that folder, there is index.js and another file called cmds.js
cmds.js has a command for my bot in it
i want to import all of the code from cmds.js into index.js without having to type it all in index.js
how do i do that
@mossy vine
how do you define commands in cmds.js
the code in cmds.js is as follows:
bot.on("message", (message) => {
if (message.content === ";cmds") {
message.reply("\n``Command List`` \n`Prefix:` **;** \n \n**serverinfo** - Gives the server information. \n**ping** - Fun command, bot says `Pong!` \n**coinflip** - Flips a coin. \n**cmds** - Sends this command list.");
};
});```
thats the only code
just to make it clear, you do not need a new bot.on for every command
i know
all i need is to import that code into index.js without having to type all of my commands in there so its easier to manage
at that point you might as well just write an actual command handler
thats what i need to do
tysm
@viral spade there is an issue with the sharding manager apparently
Oh man so its not really in my hands right now?
This is a very recent problem that might have a fix on the way?
im not sure, i've seen people complaining about it for several days now, but only today someone posted an issue about it
@mossy vine wait, would it work if i said
//cmds.js
module.exports = bot.on("message", (message) => {
if (message.content === ";cmds") {
message.reply("\n``Command List`` \n`Prefix:` **;** \n \n**serverinfo** - Gives the server information. \n**ping** - Fun command, bot says `Pong!` \n**coinflip** - Flips a coin. \n**cmds** - Sends this command list.");
};
});
//index.js
require("./cmds.js")```
not only would that not work, its a terrible idea
i need someone to explain to me how to do this rather than give me a link and learn from that, often times its harder for my brain
are you doing a command handler?
i would make an embed
so basically, step one: load all files in a folder
i already have that
then for each file, require it and add it somewhere, like an object or a Map
how do i do that
you can also attach it to the client for storing
client.commands = new Map();
let files = fs.readdirSync(...);
for(file of files) {
let name = file.split(".")[0];
let command = require("./folder/" + file)
client.commands.set(name, command);
}```
now in your command files, you need to export a function
ok
./folder/ shoulder be my folder name right
module.exports = function(your arguments here, ie client or message) {
// your command code here
}```
yes of course lol
fill it up with whatever is relevant for you, like readdirSync(...)
the code is pretty much self explaining
you said you already had that
uuh
so my folder name?
how did you do it before?
you shouldn't be doing this if you don't even know how loops work
@naive mantle
oh
that defeats the whole purpose of having a command handler
anyways, fs is node.js's built in file system class, it contains all functions you need to access your local hard disk and files
fs.readdir is the function that reads all files in a folder
look i cant handle this with all you talking at the same time
fs.readdirSync is the sync version of it
what do you mean by load all of the files in a folder
ie
you have a folder called "commands"
and inside this folder you have several files
if you do fs.readdirSync("./commands")
it will give you the list of all files in that folder
dude
maybe let him do the static version of folder structuring before loading commands dynamically from the files
why doesn't d.js come with a built in command framework
Is the command handler the same in v12 as it is in v11?
if you want that, use commando
discord.js has commando for that
@zenith terrace yes
Ok good
@naive mantle yes
ok then in index js
i thinl
to get a list of files in the folder
client.commands = new Map();
let files = fs.readdirSync(...);
for(file of files) {
let name = file.split(".")[0];
let command = require("./folder/" + file)
client.commands.set(name, command);
}
that is what is in index.js right
when he said he had all files in a folder loaded, i think he emant he had all files in a folder
yes
uhh
when tim added ... inside of readdirSync he didn't mean you to literally paste it
this is what i have so far
client.commands = new Map();
let files = fs.readdirSync("./commands");
for(file of files) {
let name = file.split(".")[0];
let command = require("./folder/" + file)
client.commands.set(name, command);
}```
./folder/ do i change to ./commands again?
yes
ok
unless you have a folder named "folder", then obviously yes
doesnt matter
ok
personal preference i think
i think fs does it for you for folders
client.commands = new Map();
let files = fs.readdirSync("./commands");
for(file of files) {
let name = file.split(".")[0];
let command = require("./commands/" + file)
client.commands.set(name, command);
}
so that is in index.js
for example, the variable file contains the name of the file, like botinfo.js
if you dont put the slash there, it becomes ./commandsbotinfo.js
does that make sense?
nope
then do i put
module.exports = function(your arguments here, ie client or message) {
// your command code here
}```
in each of my command files
there u go
but
wait what
iT bRoKe
your events, ie client.on("message", => bla) should go in the main file, not in the commands
unless you want to make a specific file for events
Tim thank you again for redirecting me to the discord.js github issues page with others with the same problem. You saved me a lot of time here..
np, i've been seeing it happen for several days, idk why it took so long to post an issue
lmao
i dont use the shard manager myself, but what happened to me was that some specific guilds would randomly not arrive, or take ages to arrive
which caused the library to never fire the ready event lol
internal sharding
ah yes
-รงal sa
What is the preferred way of starting specific id shards with a shardingmanager (possibly even less ids, than there are totalShards, because the other ids will be started on another machine)?
are you on v11 or v12?
in nginx how can i make it so that if people are going to directly to /premium for ex, itll server the try_files that it should be trying, however any /premium/BLAH is proxy_passed somewhere else
yes
that is not helping
yes
On the emojiUpdate or EmojiCreate/Delete events, would the following work for getting the guild
client.on("emojiCreate", (emoji) => {
let guild_id = emoji.guild.id
})
discord.js v11.6.2
sure.
and what would trigger the emoji update event? I can only think of the emoji's name being changed that would trigger it
yeah
Hey guys, whats the usual strategy when adding a command to the bot that takes params is?
something like - !addCommand 'hey its me' 'no its not'
args
every !addCommand you write a json line?
yea but how do you save all the commands the users wrote
was thinking about creating a json with the commands, every addCommand adds a new line and etc
is that whats usually done?
use mongodb
was trying to avoid that since it wouldnt be many commands, but i guess ill have to settle one
thanks guys
Input
var { Logs } = require(`${process.cwd()}/src/Structures/Constants/Models.js`),
config = Logs.find({guildID: msg.guild.id}).then(items => items[0])
config
Output (model)
{
channelUpdatesEnabled: true,
channelUpdatesChannel: '689208139660525704',
memberUpdatesEnabled: false,
memberUpdatesChannel: 'Not Set',
messageUpdatesEnabled: false,
messageUpdatesChannel: 'Not Set',
emojiUpdatesEnabled: false,
emojiUpdatesChannel: 'Not Set',
_id: 5e6ffcc7dc6f09247b38b655,
guildID: '632641076850851862',
__v: 0,
guildChangeLogsChannel: '[#689239485325901904](/guild/264445053596991498/channel/689239485325901904/)',
channelUpdates: [Object]
}
Why, when I do config.memberUpdatesEnabled, it returns undefined and the same for everything else.
I am probably just being stupid haha
but if someone could explain why i am stupid would be handy HA
What permission lets people disconnect others in vc ?
move members
thanks
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
They should mention it
make sure it is included in the package.json
if the package name is "node-cron" then require("node-cron")
but it seems like you're trying to use "cron" not "node-cron"
they are two different packages/libraries
my problem has been lost :/ if anyone could help would be nice
https://discordapp.com/channels/264445053596991498/272764566411149314/689613113284362305
are you using mongoose?
yup
actually
this would be more accurate
The solution is saying to make sure the field is in the schema, but I have already done that so I do not know what is up with it
try this then
When I use .toObject(), it converts it from model to an object, yet still does not work
well you're using a promise and not awaiting it (i just noticed it now lol)
where haha, i must be blind tbh
i mean, i dont use mongoose so idk what it returns, but if .find returns a promise, then yeah its not being awaited
it returns items in the callback, but not out of it
promise.then(something => {
something exists here
})
something does not exist here```
so config would be Promise<pending> and config.whatever will indeed be undefined
if your eval supports async/await then do config = await Logs.find(...); config[0]
although mongoose is weird af so you never know
How do I make it so my bot filters swear words? @blazing fox needs info
wont a self-invoking async function return undefined to the eval command itself?
unless the eval itself is async, it will always expect sync code only
@blazing fox
try sending it as a message instead of returning it
Tim are you talking to me?
to status
Ok
yep, love being called status :/
lul
const blocked_words = ["word1", "word2", "a bad phraseeee"]
blocked_words.forEach(blocked_word => {
if(message.content.toLowerCase().includes(blocked_word.toLowerCase())) {
// do things like delete the message or whatever haha
}
})
thats the beginner developer way i would do it @earnest phoenix HAHA
oh wait
i did blocked_words twice
like a nob
Ok thanks
Oke thanks ,)
What is the preferred way of starting specific id shards with a shardingmanager (possibly even less ids, than there are totalShards, because the other ids will be started on another machine)?
Any idea why my discord bot token might be changing?
For some reason i always caught i rejection of token now
not sure what happened
(node:4) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
was it reset? check your email
ah fuck
token was compromised because ive uploaded to github
makes perfect sense
haha
ill have to check how to make a heroku env variable for this then
it should be fine unless your repository was public
it was 
How would I make a set prefix command for discord.js?
you need some form of a database
Mhmm
could it be quickdb, json (should be avoided) or sql
any paid ones will do
make sure that the company has a good reputation
you don't want your database to get leaked
hm.
is there any other like hosting platform that supports sql database or does it have to deal with sql?
any web hosting company
/platform
the problem is that they would usually have a maximum concurrent connections
like 2 or 4
you need to use pools.
.setDescription(`<#${channel.id}> has been created by **${await executer("CHANNEL_CREATE", channel.guild.id)}`)
async function executer(type, guildID) {
const audit = await client.guilds.get(guildID).fetchAuditLogs({type: type}).then(audit => audit.entries.first());
return audit.executer;
}
#test has been created by **undefined
Pretty sure it's .executor and not .executer
Also you're missing the markdown that makes the text bold at the end (**)
What is the preferred way of starting specific id shards with a shardingmanager (possibly even less ids, than there are totalShards, because the other ids will be started on another machine)?
Guys what are some good moderation bots that can show user punishments and can do automod
Auttaja
Dyno, Auttaja, etc. Search the site.
const audit = await client.guilds.get(guildID).fetchAuditLogs({type: type}).then(audit => audit.entries.first());
return audit.executor;
ok, so I have the above code in a function, calling it with ${await getExecutor("CHANNEL_DELETE", channel.guild.id)}, and it works and all, but sometimes, instead of giving returning the person who deleted the channel, it returns the previous one... why is that?
im not good in java
but
it nay have something to do with
may
await.entries.first());
...
that gets the latest one
and since its getting it, as soon as the channel is deleted, the latest one SHOULD be that action from the user that did that action
your getting the first thing in the audit log correct
and since this executes immediately as the channel is deleted it will be that
right?
yup
i don't think its wrong on your end
discord has been working slowly lately
lots of outages
and i think its deleting but not being sent into the audit log enough time
so your bot picks up the last person before that
when it actually goes into the audit log
๐
um is it ok to talk about coronavirus?
not here
not in here
at least I develop something related to that, that poses problem?
yea cuz discord stinky
what is it
this is for development questions
not just talking about it
let { body } = snekfetch.get("https://coronavirus-19-api.herokuapp.com/all")
const classic = new Discord.RichEmbed()
.setColor('#dc143c')
.setTitle(`Stat du CoronaVirus`)
.setDescription(`
> > Total :
> > Nombre de cas : ${body.cases}
> > Nombre de membre rรฉtablie : ${body.recovered}
> > Nombre de mort : ${body.deaths}`)
.setFooter(`demande de ${message.author.username}`, message.guild.iconURL)
.setTimestamp()``` I don't know why it doesn't work
"UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'cases' of undefined"
what do you get when you console.log(body)
i will watch
why are you destructuring body?
I get "undefined" wtf?
just let body would be ok
snekfetch is deprecated
use node-fetch instead
^
I thought snekfetch was for images
oh it's for a lot of things
oop
but so is node-fetch/axios/request (deprecated)/got/etc.
nice api
i think it didn't recover cases from the http
<node-fetch>.get ?
is it used the same way?
.json()
undefined 
const fetch = require("node-fetch")
fetch(url)
.then(res => res.json())
.then(json => {
// json is reponse, json.cases would work etc.
})
thats how i do it ha
or use await
thx
Hey.
return process.dlopen(module, path._makeLong(filename));
^
Error: /app/data/DiscordBot/node_modules/canvas/build/Release/canvas.node: invalid ELF header
at Object.Module._extensions..node (module.js:682:18)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/app/data/DiscordBot/node_modules/canvas/lib/bindings.js:3:18)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
How could i fix this?
I tried reinstalling
and stuff
in what context is this happening, like what are you doing to get the error
@pine aspen
I'm trying to run my bot.

