#development
1 messages · Page 862 of 1
you can delete the .git folder iirc
i want to keep the files locally tho
@clever storm anyway, you said the shard wouldnt read user from the promise, was it throwing a user is not defined error? if so, it was because of that console.log
ok C0bra why are you boadcasting it when you can just fetch the channel?
its not irrelevant
i added that just now, was throwing before
yes it is lmao
the error is in the description
now you say it?
you showed a piece of code, i looked at the piece of code, and told you whats wrong with it
would i use rm -rf .git
if you neither specified exactly what the error was, nor provided the correct piece of code, thats not my fault
in the directory im working with
I did provide what and where it was lmao
right here
Either way its literally the same thing
Cobra why are you not just fetching the channel?
the var isnt defined in either place
@crimson vapor Do you know how brodcast eval works?
yes.
you cant send to a channel off shard
ur not even defining user in the broadcastEval
^
im aware
then define it
Lmfao this is my ENTIRE question
what?
if the promise is outside the eval, user isnt defined inside the eval. If my promise is inside the eval, it care read vote
So one of the values is always undefined in the evaled code
ok I am confused atm, why are you even evaling?
May I suggest using async and await
That way you can await the values and get both things to be defined inside the eval
dbl.webhook.on('vote', async vote => {
const user = await client.users.fetch(`${vote.user}`);
const voteLogs = await client.channels.fetch("693204858068664491");
const embed = new Discord.MessageEmbed()
.setAuthor('New Vote!', client.user.avatarURL())
.setDescription(`\`${user.username}#${user.discriminator}\``)
.setColor(0x2F3136)
.setTimestamp().toJSON();
if (voteLogs) voteLogs.send(embed);
});``` iirc this code should work the exact same way
or should do the same thing*
You cant send msgs to channels off shard
That's the whole purpose of brocastEval here
What doe this mean?
(node:7102) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 guildMembersChunk listeners added. Use emitter.setMaxListeners() to increase limit
bot wont start
@barren swallow LMAO
do you have 11 guildmember events
Use a webhook then

@clever storm what?
Just funny were here at the same time
😄
client.users.fetch(vote.user).then((user) => {
client.shard.broadcastEval(`
const user = "${user.tag}"
const voteLogs = this.channels.cache.get('693204858068664491')
if (voteLogs) {
let embed = new Discord.MessageEmbed()
.setAuthor('New Vote!', client.user.avatarURL())
.setDescription(user)
.setColor(0x2F3136)
.setTimestamp()
voteLogs.send(embed)
}
`)
})
``` i would do it like this
my bot will not start
@clever storm try using a webhook that way you won't have issues sending a message off shard
@quartz kindle This seems like it would work, lemme try
@barren swallow you got a possible memory leak
how do I fix?
You gotta check your code
@barren swallow are you using guild.fetchMembers / guild.members.fetch() anywhere?
ye
whats your discord.js version?
v12
show your code
client.guilds.cache.map(async (guild) => {
await client.checkGuild(guild);
await guild.members.fetch();
});
ready.js
ok 😄
if you have 500 guilds, that code is creating guild.members.fetch() 500 times at once
doesnt discord.js already do that?
d.js does cache all the guilds
but not the users?
if you want to fetch all members, use the client option instead
although that's not recommended
new Discord.Client({fetchAllMembers: true})
i dont really need it anyway
@crimson vapor if it caches online users / users who send messages as far as I'm aware
bot still wont start
any error?
oh
Discord is dying so if your bot can't connect wait a couple of minutes and try again
Oh yeah discord is dying rn some servers are having an outage rn
oh k
when does discord not die
True
got it up on heroku, only for it to crash 10 mins later, can anyone help me understand these errors?
2020-04-10T23:01:11.989353+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=dragon-aid.herokuapp.com request_id=4f87dc23-e1df-4511-8e33-109bf2018eab fwd="99.50.195.102" dyno= connect= service= status=503 bytes= protocol=https
2020-04-10T23:01:12.400368+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=dragon-aid.herokuapp.com request_id=7e491281-92a7-4dd9-97d2-19e127a22421 fwd="99.50.195.102" dyno= connect= service= status=503 bytes= protocol=https
that log doesnt contain any relevant information
Status 503 is unavailable isn't it?
ye
So that's a site issue
so not my fault
but that error is refering to itself, its own status
You use them don't you? Use services for what they're made for
Oh, makes sense
so do i just push it again?
you need to find the relevant logs
the actual error that crashed the bot is not there
what about before the state change
just the bot logging in succesfully
the entire log off the app
2020-04-10T22:55:47.333018+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-10T22:55:47.336241+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-10T22:55:52.340267+00:00 app[web.1]:
2020-04-10T22:55:52.340282+00:00 app[web.1]: > thegreatdiscorddanddbotproject@1.0.0 start /app
2020-04-10T22:55:52.340283+00:00 app[web.1]: > node index.js
2020-04-10T22:55:52.340283+00:00 app[web.1]:
2020-04-10T22:55:53.037829+00:00 app[web.1]: Logged in as Dragon Aid#3458!
2020-04-10T22:56:50.900834+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-10T23:01:11.989353+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=dragon-aid.herokuapp.com request_id=4f87dc23-e1df-4511-8e33-109bf2018eab fwd="99.50.195.102" dyno= connect= service= status=503 bytes= protocol=https
2020-04-10T23:01:12.400368+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=dragon-aid.herokuapp.com request_id=7e491281-92a7-4dd9-97d2-19e127a22421 fwd="99.50.195.102" dyno= connect= service= status=503 bytes= protocol=https
Show your procfile
In discord.js v11 how can I check if there is a catagory with this name logs?
Wouldnt it have crashed befor starting if it was something in my code
Yes, category is a channel type
there were no inputs while it was up either
.find(channel => channel.name === "logs" && channel.type === "category")
@valid gyro show your code
is it not all in the github?
its all on the github
i didnt even check his github lmao nvm
except for the .env file ofc
and before i heroku'd it, it was running perfectly locally
can you try running heroku local and see if it runs locally
Do you have the buildpack set to nodejs on the dashboard?
try removing the dependencies you dont use, such as git, node-fetch and axios, also try downgrading node to v12 in engines and remove npm from there
and do what noctember said
@spice pier yes
Just remove them from the package?
yeah those are there from when i was trying different api modules
alright after changing that it logged itself in again,
o
crashed again!
like every time i say it starts workin it decides to crash
@quartz kindle if i downgrade node versions wont i have to change a bunch of syntax?
no errors for this crash yet, is there a site like heroku thats specifically or discord bots?
i think ill try glitch and see if that works any better
What's the issue?
how do i get all guilds the bot is in
and all users combined that the bot can see in all guilds
on discord.js
What?
Nani
djs version?
12
@zinc condor u want to know how to get all the server your bot is in
If so then it's what leny32 said
i need to get all the members in all the guilds as a count combined too
client.guilds.cache.uses.size I think
client.guilds.cache.reduce((a,b) => a + b.memberCount, 0)
Check the discord js guide
and all users combined:
you should use:
let count = 0;
client.guilds.cache.forEach(guild => {
count += guild.memberCount
});
return count;
I don't know if I did it correctly, but you can go over it.
bot.guilds.cache.forEach(guild => {
console.log(" - " + guild.name);
});
that will make it more cleaner
for the name of guilds
can someone help me revert back to node.js / discord.js 11.0.0
12.0.0 is not working out for me
Define not working for u?
Alright
like everytime I start my bot (normally) even with cache added to all the required lines, etc, "RichEmbed is not a constructor" and everytime I make it "MessageEmbed" with or without .type, it says "fields.flat is not a function", whilst I do not have fields.flat in my programming
You can use npm install discord.js@11.0.0
You need at least nodejs 12 I think
Weird.
its not finding any node 12.0.0 or higher
npm install npm@latest -g
@elder vine not npm
lets see if that works then
when you update node change the bin location and re-add to path
(your nvm line)
fucking fixed
It's nvm
Node version manager
I can use npm -v etc. to see node version (I think) lemme check
it says installing so I'll wait for that to finish
will I need to restart my PC
I think
You can use both nvm and npm
I don't think you will
On my Linux server node just installs
Then I can use it right away
😭
What...
13.12.0 is current but 12.16.2 is recommended for most users.
i just downloaded the latest version of node
13.12 should work
but it keeps saying 10.9.0 when I do node -v
unless I need to restart my windows 10 desktop
it installed the latest NPM but not node .-.
got my bot up, should be good now. Thanks to everyone who helped me
You shouldn't need to restart.
@elder vine problem is that toxic can't get nice to change versions
nice?
did you restart cmd
negative.
lol
should I restart cmd
yes
whenever some changes happen to the PATH variable, the process utilizing it needs to restart to see applied changes
Oh yes windows
uninstall your old node version
or change the PATH variable to include your new node version
restarting your PC does nothing
we're not in 1999 anymore
Can't you just download from https://nodejs.org ?
@obtuse wind you might just need to manually install with the download
Uninstall node.js before you download?
i did that too.
@earnest phoenix also restarting sometimes is required
Especially with node on windows
here I think I know what to do
You can try and do a restart.
because my computer is actually a remote desktop
i've never had to restart my pc when installing a devkit/runtime/any program since 2014 lol
I'll try going to my other PCs and doing all the same code
the only exceptions are drivers
I've had multiple needed restarts because of such, but maybe because I download lots of shit
I'll just restart real quick
Yea, do that.
if (message.content === '!new ticket'){
message.channel.send(message.author.username + ' created a ticket.')
message.guild.channels.create(message.author.username + ' ticket.' , {
permissionOverwrites: [
{
id: message.author.id,
allow: ["VIEW_CHANNEL"],
role: everyone,
deny: ["VIEW_CHANNEL"],
}
],
})
}
});
im making a ticket feature
how do i make it so everyone cant see channel
discord.js btw
java script
v?
?
i think so
latest one
idk
how do i find out
@elder vine most resent
v12 i think
it appears my restart did not work.
oof
What?
Its still saying 10.9.0
Weird
@elder vine did u find doc
i just want to update omg do I need to reset my entire goddamn computer
SEND_MESSAGES: false,
READ_MESSAGES: false
but what about the id
of everyone
how do i get that
role: everyone,
deny: ["VIEW_CHANNEL"],
like that ^
channel.overwritePermissions(role everyone, {
SEND_MESSAGES: false,
READ_MESSAGES: false
});
gn
i dont get it
on c:/program files/nodejs
it says is 13 and so does the loader but on my bot file its still 10.9.0
and I think I forgot the way to download node 13.12.0 to my bot file .-.
@still lily somewhat help, ill link the section
I need help with the widget embed.. it shows up like this on discord, but when i click on the link it shows 105 (the actual number of servers)
ok
show your code @visual sandal
const sourceEmbed = send.embed()
.setTitle(`${config.client_name}'s Source`)
.setThumbnail(`https://i.imgur.com/oqhqt65.jpg`)
.setImage(`https://top.gg/api/widget/662517805983334416.png`)
The web browser is saving the embed
@fleet chasm https://media.discordapp.net/attachments/272764566411149314/698327801484410960/Screen_Shot_2020-04-10_at_8.25.02_PM.png
but how i do that for everyone
so no one can view
but the one guy
its a ticket bot
thing
just view the docs
ignore thats irrelavent.message.guild.cache.members maybe?
@fleet chasm its not in there
Kurasad are you using BetterDiscord?
nobody cares
Against tos
no
again, nobody cares
@elder vine. No one cares about it
@obtuse wind Cannot read property 'members' of undefined
oof
why isnt this in the docs
I said its irrelevant
let role = rows[0].roleID
await channel.permissionOverwrites.forEach(async (role) => {
console.log(role)
await channel.updateOverwrite(role, { VIEW_CHANNEL: false });
})
await channel.updateOverwrite(role, { VIEW_CHANNEL: false });
```
what about something like this maybe?~~~
idk i don't know how to program channel permissions with bots I do that manually
@still lily
well then I cannot help you, again I do things manually with permissions
ok
message.guild.members
does message.guild.members work
it depends on what kind of version you are on jake
im v12
no it wont
ooof
most things are under
otherwise try my code but put .cache before my forEach
yeah because of that
whatever the fuck its called
yea lts works
d.jsV12 requires node12
yes it wont work
Because of the embed constructor
how do I put node v13.12.0 my recently downloaded version into my bot folder?
you cant install to a specific dir
cause I tried
npm i c:/useres/administrator/onedrive/desktop/discord_bot/node_modules/node
which that line did work but it didn't update the damn node
lol
why do you keep ignoring this message https://discordapp.com/channels/264445053596991498/272764566411149314/698324486788874290

it said successfully installed node 13.12.0 and guess what I do node -v and it said::::::::: 10.9.0
array.flat exists in some node v11 versions 
yea do what cry said
yes it is
NVM doesn't work on installing that I tried that already
if it didn't work for you, you didn't do it correctly
that's not what i said to do
read the message again
and then after that, read it again
and then after reading it again, read it again
I changed the damn path 🤦
do you think he knows what a PATH var is?
Why is everyone calling me a he omg
node_modules/node
oh surprise surprise puppy surprise

Everyone be nice
gender neutral pronouns 
wait what
here let me just do
@obtuse wind also most of the discord userbase are guys do it's kinda normal
npm uninstall node
no you cant install node with npm 
toxic, you should backtrack a bit and first learn how to work with node.js and npm in the first place, and then after learning how the language works and how the runtime works, start making a discord bot
huh
we been knew 💅
what do mean start making a discord bot I have 16 applications that I host
ok and
I know how it works its not working what you guys are telling me
Bet
if you cant install node.js then something is wrong
this is my 6th time telling you to change the PATH variable to include your new node version
ok in my program files in my c: drive, its 13.12.0, in my bot folder, its 10.9.0
your PATH variable is not working I tried that
I'll try it again and send you screenshots
what did you try
Object.defineProperty(node, "PATH", {
value: "13.12.0"
})
lol
bad gateway
now i have to use raw events to make everything worse until i rewrite to djs12 and get partials
well it happens way too often for me, possibly meaning i should start sharding but /shrug
how many servers?
i shard my 2 server bot
yeah ih
😎
dont u have 2.4k
1.8k
i should
pls start
internal sharding
my body's also telling me no
my program folder for node VS my bot folde,r again I tried the path option.
what exactly did you do when you were changing the PATH variable
I'm not gonna even answer that its just dumb
what
ergo you didn't do it
I did but its useless
I didnt get node with npm i installed it from the site
what exactly did you do when changing the PATH variable
change program files folder to discord_bot folder
my PC does not have user variables or system variables
Sidenote: I changed Path, nothing worked.
Other sidenote: I completely reinstalled discord.js and node into my bot folder
Other sidenote; I deleted my entire node_modules folder, and reinstalled discord.js and node; it says installed 12.1.0, 13.12.0 and guess whattttt: node -v === 10.9.0
how do i get permissions for my bot
need to check if the bot has permissions for stuff
@zinc condor what version are you on
12
I think its bot.Permissions(checkAdmin) but I'm probably incorrect.
or its
no idk documentation is weird now
I need to find the discord.js.org server
Dark reader too?
I have always used dark theme.
dark for everything
Whats going on here?
Whenever I try to get to my bots page it always says 403 forbidden

I was able to revert to discord v11 and now it says "setActivity(<activity in quotes/or this ` `>)" is not a function was that deprecated
.setPresence was the solution
obvs you're doing it wrong
but like
without seeing what you're doing I can't actually help
nor do I have enough time tho
I'm working on something rn
is there anything I can do to reduce the caching of d.js?
Would appreciate some direction!
I mean, you can go and change some of the options here: https://discord.js.org/#/docs/main/v11/typedef/ClientOptions
Not everything, but some.
a-
why?
i think i know why but its better coming from someone else
no i do know why but why does it happen
It has to do with its prototype/this and how it was called. You lose its reference when you do that.
where do I put JSON-params in a http request using node.js
hmm
hey
i want to make a bot for my server and idk how make my idea come true
so can anyone help?
where do I put JSON-params in a http request using node.js
@rugged hatch What library are you using for HTTP requests?
i want to make a bot for my server and idk how make my idea come true
so can anyone help?
@wet apex most things are possible. What exactly do you want to make?
still remeber me?
Nevan what do you need help with?
im finding
i forget hes name
like hes name is new vortex
or something like that
how to make verified bot?
What? What do you mean?
some bot has verified
like
dank memer
and groovy
how to make like that?
do i need to go to discord office?
Oh, that's a new addition. It's explained in this article: https://blog.discord.com/the-future-of-bots-on-discord-4e6e050ab52e
In order to apply for verification, you must have a bot in at least 75+ servers. It's a requirement to gain more servers past 100. In order to apply, you'll need to identify yourself and submit a form on your bot's application page (https://discordapp.com/developers/applications).
@sudden geyser well i want to make a introduction bot. i have its blueprint ready in my mind but it need database and idk much about database
there's a first time for everything
and docs
you have billions of learning resources online
if you want to learn it, do research on the subject
you're right bro
it seems like you're a very experienced bot developer
which bot you have developed? @earnest phoenix
cry took down their bot
ooh why?
yes, I do
@sudden geyser I already got it. But thx though!
How do I make the bot react to the message, not command.
V11
Not command trigger
Like having a user input?
If ur in node you can do that with a simple arguement script
It's a suggestion command
Send the message and get the message that's sent. For example:
message.channel.send(...).then((msg) => {
// `msg` is the new message.
})```
you can also use async if you want a cleaner code
using async and await you can keep everything inside a single scope
Why does pm2 keep making two instances it's so anniying
It only restarts knce
But commands run twice
damn, we use the same prefix
actually surprised that this works! it's amazing!
const Discord = require('discord.js');
module.exports = {
name: 'guide',
description: 'pong!',
execute(message, args){
if (message.author.id !== '622694560501596161') return;
const Aembed = new Discord.RichEmbed()
.setColor('yellow')
.setTitle('꧁ৡৢۜ͜ ༺**STAFF GUIDE**༻ৡৢۜ͜꧂')
.setDescription('꧁ৡৢۜ͜ ༺**HELPERS**༻ৡৢۜ͜꧂\nMust report to Mods if a user breaks a rule\nWarn members when they break rules\n\n꧁ৡৢۜ͜ ༺**MODS**༻ৡৢۜ͜꧂\nMust moderate chat\nTempmute members when they break rules multiple times\nMust do helper jobs\n\n꧁ৡৢۜ͜ ༺**SERVER DEVELOPERS**༻ৡৢۜ͜꧂\nkick members who haven\'t verified themselves in 1 week\nMust do MODS jobs, and helper\'s job\nhelps set up/edit the server\nMust do all staff jobs when asked\n\n--[**ALL STAFF**]--\nhelp out members\nBump our bots\nKeep chat active\nhelp support the server')
message.channel.send(Aembed)
const Bembed = new Discord.RichEmbed()
.setColor('yellow')
.setTitle('꧁ৡৢۜ͜ ༺**RULES**༻ৡৢۜ͜꧂')
.setDescription('DO NOT BREAK SERVER RULES!\nMust follow staff guide\nMust not abuse your power\n Must be a good rolemodel\n Please don\'t unnecessary pin messages')
message.channel.send(Bembed)
const Cembed = new Discord.RichEmbed()
.setColor('cyan')
.setTitle('꧁ৡৢۜ͜ ༺**PUNISHMENTS**༻ৡৢۜ͜꧂')
.setDescription('Any rules broken or not abiding by the staff guide will result in demotion and ultimately removal from the staff team, you will be notified if you are going to be demoted/removed from the staff team, you cannot reapply as staff once you are demoted.\n\n\n Remember, Teamwork makes the dreamwork!')
message.channel.send(Cembed)
}
}
the only problem is that the embeds are the wrong color.
what color are they
whata
@crimson vapor what is the name of your bot?
try using color codes
probably a good idea
I think I could create a color.json file and just paste in color codes in there ig.
yeah
How to stop pm2 spawning two instaces
Cxllm, did you try pm2 start <yourserverscript.js> -i 1. Found it in the first link on google
Eh, ok? but how will that work?
im like 100
nope
nost likely using CYAN is most likely undefined and sends something else
or yes
not supported
you probably added something to your bot files to make it supported.
Hm,
exports.Colors = {
DEFAULT: 0x000000,
WHITE: 0xffffff,
AQUA: 0x1abc9c,
GREEN: 0x2ecc71,
BLUE: 0x3498db,
YELLOW: 0xffff00,
PURPLE: 0x9b59b6,
LUMINOUS_VIVID_PINK: 0xe91e63,
GOLD: 0xf1c40f,
ORANGE: 0xe67e22,
RED: 0xe74c3c,
GREY: 0x95a5a6,
NAVY: 0x34495e,
DARK_AQUA: 0x11806a,
DARK_GREEN: 0x1f8b4c,
DARK_BLUE: 0x206694,
DARK_PURPLE: 0x71368a,
DARK_VIVID_PINK: 0xad1457,
DARK_GOLD: 0xc27c0e,
DARK_ORANGE: 0xa84300,
DARK_RED: 0x992d22,
DARK_GREY: 0x979c9f,
DARKER_GREY: 0x7f8c8d,
LIGHT_GREY: 0xbcc0c0,
DARK_NAVY: 0x2c3e50,
BLURPLE: 0x7289da,
GREYPLE: 0x99aab5,
DARK_BUT_NOT_BLACK: 0x2c2f33,
NOT_QUITE_BLACK: 0x23272a,
};```
here is a list of all supported colors with discord.js
ok thank you so much.
node_modules/discord.js/util/Constants.js
line 447
just edit this to add a new one
np
algun devolper español ?
it needs to be approved + in this server
is it kicked from this server
Ask a moderator
fix it and ask a mod to invite it back
yeah, but that means being a verified developer by discord
or bot invite
ah
u joins - bot dms you witn welcome message
u should have a system to turn it off tbh
and if you get verified by discord it is in their 10 things to do
yea
pretty sure no one is gonna give a damn about the bot after they get their verified
client.user.setAvatar()
client.user *?
yea
@golden condor thank god i didn't verify corynth
But i do think it is strange that DBL is doing things different then discord verified
XD
but I will adapt
@pale vessel why?
Oh good
@pale vessel it can be transfered during verification
no thanks
I can add u to the team if you want the badge tho
Why do I need to code for a webhook cant I just select the webhook and write with it?
Why do I need to code for a webhook cant I just select the webhook and write with it?
@tight plinthjust getting on my pv
Oh webhooks create bots?
I got my bot verification process to work
no they dont
Why do I need to code for a webhook cant I just select the webhook and write with it?
@rotund cobalt no you cant
Do I need to use this for a webhook?
erm no
what you're reading is an example of using webhooks to get notified for updates on a github repo
I have mee6
you need YOUR discord bot
you need to be able to code one
if you try to create a webhook and getting orking like that it will not work at all
Is there no pre maid bot i can use for webhooks?
no
Ok
yes
github tm
What, can I get that on the github page
btw why do you want to make a webhook
you don't have a bot so why are you making one
I want to be able to write down anoucements with my discord server logo
Can I just ask a mod or should I ask the mote who kicked the bot, since I have edited the part of the DM out?
mote = mod
ask a mod
..
Ight I have a question. Using Eris's <channel>.editPermission(), how would I set a permission for a role to
?
("Send Messages", specifically)
have anyone saw ChillCorner bot?
Why do table change their bacckground color when I hover over them on top.gg even if I set it with tr:hover {background-color: #33363d} What do I need to change?
background-color
Spell mistake in here
still not working
I can change the cell im hovering over atm but the other row cell si still changing its color wrong
Can I use this : https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.is_owner when having a bot in teams?
{
a: 'aaa',
b: 'bbb'
}
how would i map that into a string, ie: a=aaa,b=bbb
spoon food for beginners tony is hella good so i think u can
Why do table change their bacckground color when I hover over them on top.gg even if I set it with
tr:hover {background-color: #33363d}What do I need to change?
My problem is still there....
@finite bough then other ppl have that code
@sick cloud also thx for the idea I was actually looking for that solution to my problem lol
dms
forkfeed then 
for (const name of Object.keys(object))```
so you can do `${name}=${object[name]}`
push that into an array and join them by ,
might not be the most efficient way but it should work
Or a forEach()
yeah
If it's rly big then yeah loops but if it's a small enough thing to loop through forEach is just handy
i need help
How can I catch this error? (discord.js v12.1.1)
1|v3bot | (node:32684) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
1|v3bot | user_id: Value "test" is not snowflake.
1|v3bot | at RequestHandler.execute (/root/dbotv3/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
1|v3bot | at processTicksAndRejections (internal/process/task_queues.js:97:5)
1|v3bot | (node:32684) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 13)
from:
let id;
if (message.mentions.members.first()) {
id = message.mentions.members.first().id;
} else if (args[0] && message.guild.members.cache.find(member => member.user.username.toLowerCase() === args[0].toLowerCase())) {
id = message.guild.members.cache.find(member => member.user.username.toLowerCase() === args[0].toLowerCase()).user.id; // I don't know how to catch this error (when not typing a real username)
} else if (args[0] && await client.users.fetch(args[0])) {
id = args[0];
} else {
return client.throw(message, "Wrong Usage", `${config.wrongUsage} \`${guild.prefix}${this.help.usage}\``)
};
use try and catch
I did, and it wouldn't work
Yea
where does it get that "test" value
I tried using the cmd upvote test (being args[0])
then if it test couldnt be found it should have a catch
if it's a promise, you'd use .catch
Hmm
@agile orchid how to connect visual studio code to discord bot?

Download Visual Studio Code and Node.js
alaredy
run npm install --save discord.js
Make a folder, and put the bot's files there
k k
For all those people who find it more convenient to bother you with their question rather than search it for themselves.
@elder vine its this thing lol
} else if (args[0] && await client.users.fetch(args[0])) {
Why does the table change its background color when I hover over them on https://top.gg/bot/673545677791297566 ? Even if I set it with: tr:hover, th:hover, td:hover, table:hover {background-color: #33363d} Whats wrong and how do I change it?
Can someone give me welcome command discord.js please
I had it in twice but it still doesnt work and it only shows this whitesmoke
if the whitesmoke rule is not yours, then its top.gg's rule, and you need to replace it by creating a rule with equal or higher specificity
ie: more specific targeting
the original rule target has 3 levels of specificity
you mean abusing !important isn't an option?
nope
whats more specific targeting?
important is for n00bs
just a class?
for example
#id .class - more specific
.class - less specific
.content table tr - more specific
table tr - less specific
tr - much less specific
basically just make your rule the same as the original
if the original is .content table tr, yours should be equal or more specific, but equal is enough
but !important saves time and effort 
wdym important is for noobs, I'll let you know I use borders for padding
damn ur cool
Hey. Do you recommend me (and many others) to upgrade to Discord v12?
how do you even which discord to install?
@tight plinth but it contains less bugs, right?
some things are better yes, but most things are the same, just different
the .cache thing will be the most annoying part for me
you should upgrade to v12 if you're ready to do a full refactor/revision of your bot's code
regex replace gang
@earnest phoenix you can install v11 by doing npm install discord.js@11.6.4
oh discord.js
but I mean: now my bot is relatively small, so it'd be better to upgrade now
Good mindset
Yep
but didn’t he said Discord and not d.js? 🤔
yes he did, but he meant discord.js
exports.WSEvents = keyMirror([
'READY',
'RESUMED',
'GUILD_CREATE',
'GUILD_DELETE',
'GUILD_UPDATE',
'INVITE_CREATE',
'INVITE_DELETE',
'GUILD_MEMBER_ADD',
'GUILD_MEMBER_REMOVE',
'GUILD_MEMBER_UPDATE',
'GUILD_MEMBERS_CHUNK',
'GUILD_INTEGRATIONS_UPDATE',
'GUILD_ROLE_CREATE',
'GUILD_ROLE_DELETE',
'GUILD_ROLE_UPDATE',
'GUILD_BAN_ADD',
'GUILD_BAN_REMOVE',
'GUILD_EMOJIS_UPDATE',
'CHANNEL_CREATE',
'CHANNEL_DELETE',
'CHANNEL_UPDATE',
'CHANNEL_PINS_UPDATE',
'MESSAGE_CREATE',
'MESSAGE_DELETE',
'MESSAGE_UPDATE',
'MESSAGE_DELETE_BULK',
'MESSAGE_REACTION_ADD',
'MESSAGE_REACTION_REMOVE',
'MESSAGE_REACTION_REMOVE_ALL',
'MESSAGE_REACTION_REMOVE_EMOJI',
'USER_UPDATE',
'PRESENCE_UPDATE',
'TYPING_START',
'VOICE_STATE_UPDATE',
'VOICE_SERVER_UPDATE',
'WEBHOOKS_UPDATE',
]);```
I'm discovering things
oh ok thanks
Is this the new event names?
these are all client events
lol I wanted to ask that too ^
according to d.js v12 files
:o
well its nothing new but
these are discord API events, not discord.js events
so guildDelete is no more
oof
ohw
guildDelete is
GUILD_CREATE',
'GUILD_DELETE',
'GUILD_UPDATE',
discord.js takes these events, processes them for you, and gives you the discord.js version of them
its like the fourth event there
I wonder if I will get ratelimited if I played silence like every second in a VC 🤔
ohh okay interesting
I hate downloading these xD - they should find a better way of displaying "longer" messages.
^
view in browser gang
thanks though
What?
I can't find anything about guildDelete/guild_delete in the changelog. So the bug about random detecting a leave is not fixed?
I don't need no file
its when a guiod is unavailabe
the problem is, that when guilds become unavailable, the API sends you GUILD_DELETE events and then GUILD_CREATE events they they become available again, or when your bot reconnects
oh oof
afaik discord.js correctly processes these, so there shouldnt be a bug like that
if (client.guilds.get(guild.id)) return console.log('Stopped a fake guildDelete event');``` this doesn't fix 'the bug' I'm experiencing?
in the guildCreate event will the guild always be available?
that line is in the guildDelete event
u dont have to fix it
@pale vessel for loop isn't es6
nvm
just try to not get big big guilds
I had that once and that wasn't a big guild
not even 100 members
why did they choose to do it like this? I mean: people like me and I guess many others just want to detect a guild leave
they do
not a connection error or something
internal desicion I guess
and there's not an option to really detect a guild leave? Really weird in my opinion
discord.js should correctly detect it
Guild Delete
Sent when a guild becomes unavailable during a guild outage, or when the user leaves or is removed from a guild. The inner payload is an unavailable guild object. If the unavailable field is not set, the user was removed from the guild.
this is how discord.js v12 handles it
this is how v11 handles it
as you can see, both v11 and v12 correctly handle those cases, so i dont see how the guildDelete event would wrongly fire
what version of discord.js v11 were you running on?
%eval let a = message.guild.members.get('430964083160776705');
message.channel.send(a.username)
``` is this wrong?
something like that can't be caused by the hosting?
Hey
Whenever i restart my bot on glitch, some of the data isn't being saved (as usual, like channel updates etc)
Anyone know how can it be saved ?
json itay?
@finite bough hey. I don't recognise your whole code but what discord.js version are you using?
11v
what did you ask ?
like are u saving them in json files
I thought about using quick.db
Way better than json
@finite bough you should use a.user.username in the second line I see. a is a member object
@nocturne grove seems like the file that handles guildDelete in v11 hasnt been changed since 2018
so im really not sure
i think for logs 12v is the best
there are a lot of issues with logs in 11v
like random errors
but my js if (!client.guilds.get(guild.id)) return; does not work? @quartz kindle
in a 'fake' case
i mean, if the event is ever wrongfully fired, that will work yes
okay nice, great to hear!
I am logging that thing so if it's ever happening again I can look closer into it
Discord.js
will not set my bot to dnd or idle ever
no matter how many times i restart
is there a way I can make it so a role gets removed when receiving a different role?
You get role Test1
Role Test2 gets removed
I need help to do Autorole Script
@glad leaf yes definitely
It's the thing i can not do ; _ ;
@golden condor if im not wrong you need to make the bot offline first by making a mistake in the code until it shuts down and then start it again
it will change after that
Where are you stuck?
@earnest phoenix ok
Where are you stuck?
@elder vine me?
you need to make the bot offline first by making a mistake in the code
huh?
Yes
Show the code you got so far
@slender thistle making a mistake in the code will eventually make the bot go offline
wait
Can't you just... turn the bot off...
i use glitch ...
Alright
i used it and it worked so why not
is there any way with yt-search (the js lib) to get more than 100 songs per playlist?
Are you using python?
oof
nah
js?
@earnest phoenix I tried it
bot designer begging
Ehhh...
What is bot designer?
a app to make discord bots
Well I can't help you then...
Why
Not you.
Ik but why using an app on the phone
Is it writing a code or like an auto-bot builder?
yh
I don't understand this codin, so yea
Why does pm2 keep spawning two instances
Is it pm2
or my code
For handling events
I will send
My index.js
//do not execute
fs.readdir("./commands/", (err, files) => {
for (let i = 0; i < client.categories.length; i++) {
var commandFiles = fs
.readdirSync(`./commands/${client.categories[i]}`)
.filter(file => file.endsWith('.js'));
for (var file of commandFiles) {
var command = require(`./commands/${client.categories[i]}/${file}`);
client.commands.set(command.name, command);
if (command.aliases && Array.isArray(command.aliases)) command.aliases.forEach(alias => client.aliases.set(alias, command.name));
}
}
if (err) return console.log(err);
});
//Events "handler"
fs.readdir("./events/", (err, files) => {
if (err) console.log(err);
files.forEach(file => {
let eventFunc = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, (...args) => eventFunc.run(client, ...args));
});
});```
What does your package.json look like?
so, does someone have a java autorole script
do you use a config file for pm2
@elder vine I’ve used that app. You dont get unlimited hosting
Why use that app then?




