#development
1 messages · Page 1362 of 1
How can I do it when someone uses the clear command and the messages are more than 2 weeks old, a message appears I cannot delete the message
@earnest phoenix I do not recommend saying command, because if someone puts a credit card, cpf, etc., your bot can be banned
wdym?
ohh
ty for the warning, imma delete the function
Message from - ${message.author}
put this
Any idea how to remove the prefix and my message?
@earnest phoenix message.content.slice(1).join(“ “)
ty guys
np
@agile lance u can help me?
How can I do it when someone uses the clear command and the messages are more than 2 weeks old, a message appears I cannot delete the message
@earnest phoenix message.channel.bulkDelete(messagesHere).catch(err => {
message.reply(“Messages are 2 weeks old, OR I can not find messages to delete.”)
})
its
wait
message.content.slice(1).join(“ “)
try this
@earnest phoenix message.channel.bulkDelete(messagesHere).catch(err => {
message.reply(“Messages are 2 weeks old, OR I can not find messages to delete.”)
})
@agile lance thanks
message.content.slice(client.prefix).split(“ “)
but what if you make another mistake
@agile lance thanks
@earnest phoenix np
So just spoonfeeding going on here?
So I'm making anti spam and not sure what is the best way of storing message amount of a user , like a map? But it can only store 50 keys i believe
So just spoonfeeding going on here?
@faint prism im just helping
Are you explaining what the JavaScript snippet does? It looks like you're just feeding the solution to them
So I'm making anti spam and not sure what is the best way of storing message amount of a user , like a map? But it can only store 50 keys i believe
@earnest phoenix database quick.db, mongo, etc
Weird
i don't think its a good idea to store in a db cuz if someone really spams its gonna be a lot of requests to the db
i don't think its a good idea to store in a db cuz if someone really spams its gonna be a lot of requests to the db
@earnest phoenix That is true, But it’s probably the best option
Look at those popular bots constantly having a Work command ran
what about set?
I was thinking of setting if (err === message.content.include(14 days)) { message.channel.send("14 days')}
@agile lance
that would work?
incorrect
.includes returns a boolean
r u comparing a boolean?
oh
no
That wouldn’t work because your checking the content of the message not the date it was created + it returns boolean
I was thinking if there is an error that contains 14 days he sends this message
.createdTimestamp exists 👀
Understood
something like that i don't remember the exact property name
^
How much space do I need for window 10 backup??
Look at those popular bots constantly having a Work command ran
Wdym "work command"?
Min. the amount of space you're using right now.
How much space do I need for window 10 backup??
@rocky hearth not discord bot development related
see djs docs if ur using it
ok
Ok sry
Any good place to ask these type of questions??
createdTimestamp > 14
Doesn't return a number of days, i believe you can check using ms
<timestamp> > (14 Days In ms)
Create a backup of your personal data, not Windows at all... It's always better to reinstall Windows if set up (again).
no dont do that
lmao
because it IS over 14
(current_timestamp - message.createdTimestamp > 14)
Doesn't return a number of days, i believe you can check using ms
<timestamp> > (14 Days In ms)
ok sir
@earnest phoenix you didn't slice say 👀
i did before
but it was sending each word every line
current_timestamp - message.createdTimestamp > 14
@boreal iron 14 milliseconds?
lol
what... createdTimestamp is in ms?
yeah
haha djs... is just trash
well than *1000 no big deal
How much space do I need for window 10 backup??
@rocky hearth This really depends on how much data you have. Usually takes at least a couple of gigabytes. If you have a pretty full hard drive, it'll take quite a bit more. The maximum would potentially be your current hard drive utilization. So I recommend backing it up on an external drive
huh thought 14 s
wait what
Are you talking to me?
tbh they don't understand much in js, i suggest learning it
#development message
U wanna check for 14s or 14d?
that still, doesn't make sense
later I decrease the number
It's always true
u need to calcuate the difference between current timestamp and message timestamp
and check if that's > 14 days
why storing the whole message? just store the message count of the user, per minute, hour, day, week etc.
I'm using mongodb, hope not too much requests
why storing the whole message? just store the message count of the user, per minute, hour, day, week etc.
I saidamount of messages
I see u changed that 1 min ago lmao
um instead of amount of message i changed to amount of messages
I see u changed that 1 min ago lmao
@boreal iron you misread
shhh... that's impossible 
it is
i have an edit snipe command lmfao
@pale vessel It's once more ur fault u didn't tell me
i wasnt paying attention 


so, yes a database is probably the best solution, depending how much users u manage
but for scaling, yes it is
Which database so you think is the best
I'm using mongo
I'm really getting my head around it for a while
idk, i have lots of maps and recently have been getting lots out of memory errors so I'm moving most stuff that i cache to db
don't ask me why i used maps
MongoDB can hold quite a load ryt?
Well just take a look out there and choose what's the best one for ur needs
not gonna recommend MySQL anymore, since Oracle doesn't give a fuck anyways
I heard bad reviews about it
well guess i gotta try and see what happens
just avoid mysql in modern day stack development
its not really that deep using mysql of smaller projects, its a decent database
not gonna recommend MySQL anymore, since Oracle doesn't give a fuck anyways
I'm not gonna switch to mysql anyway since the bot is written and setup to work with mongodb
I have a collection in mongoDB like this
{
"_id": {
"$oid": "5fa0186b686604af2886e09e"
},
"worldWhitelist": [{
"type": "712906491635695647"
}, {
"type": "737611247989686333"
}, {
"type": "282859044593598464"
}, {
"type": "565962204327968769"
}, {
"type": "735874386200100974"
}],
"ownerCode": "735874386200100974",
"__v": {
"$numberInt": "0"
}
}
How i can create a query or list for worldWhitelist in array
uwotm8
Hi! (: How could i obtain the collector instance inside the filter function?
- What library are you using?
- You may be able to access it by its variable since you're calling it within the function, which isn't evaluated until later.
May I ask why you need the collector instance? In most cases, you probably don't.
@earnest phoenix every db has its + and - there isnt somethint called the perfect db
i'm aware
mysql has more cons than pros lol
My perfect db, sql, instant, compresses everything perfectly as possible instantly.
The perfect db everyone.
Just make it someone 5head.
store data in light 
case 'p':
if (!message.content.includes('https://www.youtube.com/watch?v')) return message.channel.send('please put a URL link like so: `a!play https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=OfficialRickAstleyOfficialRickAstley` https://cdn.discordapp.com/attachments/765271029882683433/765277628981837844/ffffffffffffffffffffffffffffffffffffffff.png ')
if(!args[1]) return message.channel.send('please put a URL link like so: `a!play https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=OfficialRickAstleyOfficialRickAstley` https://cdn.discordapp.com/attachments/765271029882683433/765277628981837844/ffffffffffffffffffffffffffffffffffffffff.png ')
if(!message.member.voice.channel) return message.channel.send('please join a voice channel first.')
message.member.voice.channel.join().then(connection => {
connection.play(ytdl(`${args.slice(1).join(' ')}`, { quality: 'highestaudio' }));
message.channel.send(` now playing \`${args[1]}\` requested by **${message.author.tag}**`)
});
break;
``` why its not working?
Whats not working
its not playing the music
any errors?
no
wait
i know how
how do i download @discordjs/opus?
npm i @discordjs/opus
?
yes
k
also, use startsWith() instead of includes()
why in djs v12+ i can't get instagram account information but in djs v11 i can?
how in the literal fuck is djs related to instagram lol
🧠
idk, i get error when i upgrade djs to v12
cannot find that username
have you tried reading the error
no error detect in console
const { MessageEmbed } = require('discord.js')
const axios = require('axios')
exports.run = async (client, message, args) => {
try {
const username = args[0];
const response = await axios.get(`https://www.instagram.com/${username}/?__a=1`);
const { data } = response;
const get = data.graphql.user
const userig = get.username
const fullname = get.full_name
const bio = get.biography
let e = new MessageEmbed()
.setColor(0x0099ff)
.setTitle(`${fullname}`)
.setDescription(`${userig} \n ${bio}`)
await message.channel.send(e)
} catch (error) {
message.channel.send("Cannot find username");
}
};``` this is my code
Log the error
Makes things 10x easier to debug.
Your not getting an error because on error your just sending "cannot find username"
Effectively voiding it
so data.graphql.user returned undefined
maybe log data and see what shape it actually has.
Is it worth learning WebGL
ahh, the command not get error now, i have some typo, thankyou
👍
I would also restructure the command to look at the status code rather than voiding all the errors
Will make debugging 10x easier and is a lot cleaner
ok :)
is there a ways t know what perm someone have using this number 285240504
(this is a exemple of nubmer btw)
i would like a ways that work on any numbe
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Most bot libraries have a way to do it aswell.
well i tryed with a api request and its give me a streight number
Yeah, the api does it
Its just a bitwise operation
and its possible to recover permission with that operation?
Yep
like can a number have 2 permission combo?
or its 1 number per permission combo
ok let me see about bitwise operation thingy
or can you explain me how we recover,
&
On the permission numbers yeah
How can I take the dominant color of a photo
You could add up all the color values of the photo, then divide by the number of pixels @quick ridge
Is there a module to facilitate this or should we do it ourselves?
@earnest phoenix
Your defining messages after the code awaits.
@quick ridge could be, I dont know what language your developing in.
If you look around online theres probably one.
js
I found a module called color-thief. It says it captures the dominant color. It gives it by numbering it as r g b.
let msgs = await message.channel.awaitMessages(
// everything after await runs before the await
// so
let msgs
// is undefined while
message.channel.awaitMessages(...
// is running
@bot.command()
@commands.check(owner_ID)
async def blacklist(ctx, member: discord.Member):
sqlA = "INSERT INTO BlacklistedUser_IDs(User_IDs) VALUES(?);"
cursor.execute(sqlA, (member.id))
db.commit()
embed = discord.Embed(title="", description="", colour=discord.Color.red())
embed.set_author(name="Blacklisted!")
embed.add_field(name="Success", value=f"{member.name}#{member.discriminator} -- {member.id} Has been Blacklisted from Using commands!")
await ctx.send(embed=embed)```
does the SQL Look correct?
anyone know a way to get an Instagram feed to post on a discord channel?
If your table has a single non-null row User_IDs of type VARCHAR it should be correct
anyone know a way to get an Instagram feed to post on a discord channel?
@fervent goblet https://developers.facebook.com/docs/instagram-basic-display-api
"User_IDs" INTEGER,
PRIMARY KEY("User_IDs")
INTEGER is too small for a discord ID
You probably want to convert to a string and use VARCHAR
Finally! An asnwer !!! ILY ❤️
Np
From https://dev.mysql.com/doc/refman/8.0/en/integer-types.html - INTEGER max value is 2147483647 which is far too small for a Discord snowflake
Bonjour, j'aurait besoins d'aide sur quelque chose que je ne comprend pas, voilà j'ai un système de validation qui est fait par reaction, quand je met la reaction je reçois bien le role de validation mais si quelqu'un le fait il ne reçois pas le rôle et je ne reçois aucune erreur sur la commande esque qu'elqu'un peut m'aider ?
328/5000
Hello, I would need help on something that I do not understand, here I have a validation system which is done by reaction, when I put the reaction I do receive the validation role but if someone does did it not get the role and i get no error on the esque command that someone can help me?
client.on('messageReactionAdd', (reaction, user)=> {
if(user.bot) return;
const reactions = require("./bdd/reaction.json")
const message = reaction.message
const validationrole = message.guild.roles.cache.get(reactions.validationrole);
if(reaction.message.channel.id === "758772029892722738") {
if(reaction.emoji.name === "accepte") {
var member = reaction.message.guild.members.cache.find(member => member.id === user.id);
member.roles.add(validationrole).then(mbr => {
console.log(`${mbr.displayName} à accepté le réglement`)
}).catch(err => {
console.log(`Le rôle ${validationrole.name} n'a pu être attribué : ${err}`);
});
};
};
}
try replacing reaction.message.guild.members.cache.find(member => member.id === user.id); with reaction.message.guild.member(user)
@hardy ermine
I'm confused, are you putting in a url in a readfilesync?
try replacing
reaction.message.guild.members.cache.find(member => member.id === user.id);withreaction.message.guild.member(user)
@floral rune it didn't change anything
¯_(ツ)_/¯
They said that you can shoot this way on the internet and I took an example from them.
If you have the file locally.
I have never seen readfilesync used this way, 99% sure its only for files you have locally.
If you want to get a file online you'll have to request it via the proper method.
in https://discordapp.com/api/v8/users/@me/guildswhat permissions is?
@hereHi, I'm a new developer and need help with the command handler in discord.js. Can anyone help me?
like if a user have admin perm its would tell it there?
I'm not admin
hahhaha
@earnest phoenix
https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags
Admin perm is the third option.
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
4th*
this one?
@warm agate we can't help if you don't ask your question.
@warm agate we can't help if you don't ask your question.
@umbral zealot i need help with command handler. i write the script don't work
0x00000008 or 0x8?
Ok well we need to see the script, and for us to tell us what doesn't work with it.
ok
Pretty sure 0x000000008
Whatever its listed as
you can speek?
This is a primarily English channel
ik
.bot-img {
background: transparent;
background-color: rgba(0, 0, 0, 0);
border-radius: 50%;
animation: bounce 1s infinite alternate;
-webkit-animation: bounce 1s infinite alternate;}
For some reason
My border-radius
Is not changing it to a circle
but everything else is
@warm agate no, show your code here or paste it on https://hasteb.in/ , I don't do private support.
Oh... you're using a rando npm module. I See.
?
yeahhhh that thing's not going to work, it hasn't been updated in 2 years, it's broken.
i am new to programming, not some things
Ouch, feels bad ned

@blissful coral dev tools gang
yessa
@warm agate <#development message>
so can you give me a code that works?
See which rule overwrites yours
oh yeah
We don't spoonfeed here
smart
Abuse !important
anyone know why its not actually saving but its responding with successful etc?
if i had an extra ../ to the ../../config.json it works but saves to my desktop
Luv you @slender thistle
ly2
wait
I forgot
What was the border white line thing again
Gotta remove that shit
Shadow?
what white line
The one under the bots pfp
on the bots image? if so then ye its box-shadow
anyone know whats up? https://discordapp.com/channels/264445053596991498/272764566411149314/772877192224571473
theres no errors
@blissful coral box-shadow: none !important;
On #bot-img div
Yeah just forgot the name of it
@floral rune it didn't change anything
@hardy ermine from what I can find online you need to make sure you cache the message before you can get events on it. Did the message already exist before the bot was restarted?
You can cache a message with client.channels.get(CHANNELID).fetchMessage(MESSAGEID);
no the message it cache
you're getting the event, right?
anyone know about scraping fandom websites for data?
you're getting the event, right?
@floral rune yes
try switching out js const validationrole = message.guild.roles.cache.get(reactions.validationrole); for ```js
const validationrole = message.guild.roles.resolve(reactions.validationrole);
assuming reactions.validationrole is a RoleResolvable (an ID will do)
evening folks, just wondering how others go about this or any ideas.
I've recently updated one of my bots and would like to push out a notification to all servers it in or even to all server owners or something. is that possible?
yes but i do not know if it is allowed. my bot has that except it requires each server to configure which channel to send to. There is also the option of creating a server and making an announcements channel which will do something very similar
yes but i do not know if it is allowed. my bot has that except it requires each server to configure which channel to send to. There is also the option of creating a server and making an announcements channel which will do something very similar
@sturdy gazelle cheers, jojo yeah have the server set up but dont think there is many subscribed to the announcement channel as of yet.
what language r u working in?
i was using a bot a while ago that used to dm me directly as the server owner every time there was an update
node js
me too!
code => commands => misc => announce.js
appreciate that i'll check it out
i use server settings, but if you want you can forEach guilds in the cache and then send a message to guild.owner or u can send a message to guild.systemChannel
legend thank you
Is anyone able to help me with passport and discord-passport
ahaha I did a thing https://cdn.yxridev.com/u/9t5AD0HO.png
hey guys can i have a probleme my bot is on two server [bot test server] and another community server but the bot gets the 2 guild but no user only the one on bot test server.https://puu.sh/GJnfi.png
@hasty cloak discord intents
you need to have guild_member intents to be able to fetch guild list
is it new ?
depends on your lib
When I copy the widget code for status and paste it to my page it shows the complete (large widget)
uffff okay on the discord dev portal
@hasty cloak https://discordjs.guide/popular-topics/intents.html
i assume its discord.js
yea
then read that
but thx
When I copy the widget code for status and paste it to my page it shows the complete (large widget)
@stone meteor
Ping me if you know please
okay its works thx https://puu.sh/GJnyi.png ❤️
How do I make it cut corners softer
I using for cutting =
ctx.beginPath();
ctx.lineWidth = 7;
ctx.fill();
ctx.lineWidth = 7;
ctx.arc(150, 150, 180, 0, Math.PI * 2, true);
ctx.clip();
Hello, sorry to disturb but my bot is not working anymore. guild.presences.cache.array() is returning an empty array now. Do you know why ?
You won't get presences if you don't have the Presence privileged intent
No, it's in the bot portal on discord.com/developers
you have to enable the presence intent.
Oh ok I see
Note, however, that relying on this for a feature, you should make damn sure you actually need it, as it's not always given when you verify the bot (it must be an important or unique feature)
Read about intents on #discord-news
Thanks I'll check it
Is there a way to get the user object by their ID in d.py?
I know you can use get_user but it returns None sometimes
If it returns None, it means the user wasn't found in the cache.
that's what I thought but I'm not really sure how to fix it
fetch them rather than get
are they members or users?
if they are members, you can request them in groups
https://discordpy.readthedocs.io/en/latest/api.html?highlight=fetch#discord.Guild.fetch_members
np
on second thought
it probably wont work for my case lol
i dont have a specific guild to fetch members from
yeah, didnt think so
Hey, so I coded a ticket system and somehow my alias for "!ticket close" do not work but the ones for "!ticket open" do work. Does someone see what I did wrong in the "ticket close" aliases?
@earnest phoenix what api are you talking about
what kind of images do you need
The endpoints are either not maintained or you're using incorrect code
show us your code first and if that's ok then it would be good to look at different apis
in my experience https://github.com/public-apis/public-apis is a better list
client.command()
async def redpanda(ctx):
async with aiohttp.ClientSession() as cs:
async with cs.get("https://some-random-api.ml/img/red_panda") as r:
res = await r.json() # returns dict
await ctx.send(res["link"])
``` (this is correct)
the website is down
$ curl https://some-random-api.ml/img/red_panda
{"link":"https://i.imgur.com/5YN30zJ.png"}
``` oddly enough it seems to work for me
i guess it may have just been down
#starboard message actually, ive seen 0 command bots so idk why people starred this msg
Anyone know how to fix ? at FSReqCallback.oncomplete (fs.js:146:23)
thats not an error, its just the location of one
no idea, dont know what the error is
what does this erorr mean?
itemname = getlooter["item"]
TypeError: tuple indices must be integers or slices, not str```
py
ummm i have a dict in a func
and the func gets a random dict from the nested dict
try to print getlooter
and returns the stats
@drifting wedge the error means when trying to access a tuple element by index, it should be an int
You're giving is a str ("item")
i dont think so but i got it fixed
Hello, my bot, it works very slowly for a few hours and it is lagging and it gives this error, do you have any solution?
https://cdn.discordapp.com/attachments/761963655163019284/772941033881337886/unknown.png
help Me !
whats happening tho
what are you trying to do
Music is not played
@earnest phoenix help them !

can someone help me, I'm making an application bot, and now, I want to make sure that if there are no questions, the bot doesn't ask it at all, but I don't know how, that is, it won't work for me somehow, and there is no terror
when I put this if (question2 === null) return; It's not working
but when I remove it then it works normally, just ask a question that says null
pitanja means questions, otvoreno - opened
Shouldn't you be iterating over the questions anyway
Music is not played
@earnest phoenix im guessing this is because you reached the quota limit
https://developers.google.com/youtube/v3/getting-started
im just reading through the docs and im guessing youre using 100 quota points per search? if that's the case you've burned through the default quota allocation of 10,000 units per day.
I recommend getting familiarized with the api before going further
ahh
Shouldn't you be iterating over the questions anyway
@hollow sedge I want to make that if the question is not set, the bot does not ask it in the application at all
@hollow sedge I want to make that if the question is not set, the bot does not ask it in the application at all
@astral birch first of all, the way your DB is set up is flawed and second, with that flawed set up you could use a while loop and break it whenever the question returns none
sorry, no, you just need to find out the proper way to use a db
ok
Hello, I am new to making bots and I wanted to make my first one to invite to my server. When I used the link to try and invite it to my server, I got
500: Internal Server Error and it won't let me invite. Does anybody know how I can fix this?
Borders none?
If you trying to edit your top.gg bot page that shadow is tricky to remove
But you can simple put somethin above it, like z-index u know
anyway with a non modded client (or dev tools) to easily find a roles permissions on a channel
(assuming a non admin rank)
@blissful coral ```css
.columns .bot-img {
box-shadow: none !important;
}
Thx <3
Anyone know if their is a way to detect if a word you sent like in a set prefix command is over a certain number of letters?
You can use str.length to get the length of a string in js or len(str) to get it in Python @main trench
Aight thanks
so in theory this should work @hollow sedge? if(String.length > 6) return message.channel.send("Please set a perfix that is under 6 letters")
yes but the 6 letters would include the prefix to call the change prefix command
@main trench
hmm
has anyone had a issue w radix not publishing stuff when using its redis pub/sub client
and i verified the connection is there and booping
hmm aight
Does anyone has used Commando here?
remove the break lol
Looks like you broke the law. Tisk tisk
Jk, you probably put break outside a switch statement
Oh, you did
insert learnjs text block
guild is nto defined
bruh
fr
read what the error says lmao
how're we supposed to fix that
your switch syntax is a bit screwed up
switch (args[0]) {
case 'create':
guild.createChannel("Test", {type: "voice"}).then((channel) => {
//break;
channel.setParent("630240260965793798");
});
break;
}```
probably what you were going for
as for guild is not defined im going to need to see more code
What event are you calling this in
on('message'? Or something else?
well the error is pretty straightforward
from args[0] im guessing you're following the tut on discordjs.guide, no?
if you're using the guide then the event would be onMessage
you can get a guild object from message.guild
createChannel is probably djs v11, they changed it in v12
message.guild.channels.create('test', {
type: 'voice',
parent: '630240260965793798'
});
check if message.member.roles has the role you want
permissionOverwrites: [
{
id: '',
allow:['VIEW_CHANNEL']
},
{
id: message.guild.id,
deny:['VIEW_CHANNEL']
}
ig the question is are you trying to restrict the command or the channel
channel pretty sure
do you want it to be so that
- only Hosts can execute the command but anyone can join the channel
- anyone can execute the command but only Hosts may join
if(message.member.roles.cache.has(`id`))
brazil is a fucking joke
if(!message.member.roles.cache.has(`id`)) return message.channel.send(`You do not have permission to run this command!`) //Change if statement to this which will check if the member does not have roles and if they do not return a message```
lul
all .gov domains down when?
fuckkk
i just realized wrong server lmao
nah
meant to post that elsewhere xd
can we cancel brazil?
yes
@earnest phoenix then it is failing
if(!message.member.roles.cache.find(r => r.id === "id") return message.channel.send(`You do not have permission to run this command!`) //Change if statement to this which will check if the member does not have roles and if they do not return a message
@earnest phoenix
Reread what I said
forgot cache
edited it
omfg
website development at its finest
thats what you get for hiring whoever the fuck comes for the cheapest price
i MaKE WebSITe fOR CHeAP
@quartz kindle u brazilian?
more or less
naõ
One message removed from a suspended account.
@drifting wedge iirc he lives in Portugal
@sage bobcat its brazlian portugese i think
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Is it a rate limit?
Or something?
It isn't sharding
@sage bobcat
It is something with the dblapi
One message removed from a suspended account.
One message removed from a suspended account.
Time to look at my node modules
_startWebhook() {
this._server = createServer(this._handleRequest.bind(this));
this._server.listen(this.port, this._emitListening.bind(this));
}
Something to do with this
I changed the port to 6000
same error
Oh
Found it
@sage bobcat my bot just upped to 2 shards instead of the single shard
therefore it was trying to connect twice and send twice
noob
lmao
how do i manipulate a global variable in a local scope and keep that new value outside of the local scope? (javascript)
i know there's a way to do this but i can't figure it out for the life of me
your problem is likely not scopes, but timing
yeah i figured it had something to do with that
are you trying get a value from inside a promise or callback?
when code u wrote works first try 
first it cycles through the guild members asynchronously to get some database information on them, and is supposed to append some info to a string to put in a message
rn im running a 12k guild bot on 6mb heap
lmao nice
i've tried awaiting the loop but i think i'm doing it wrong
@dense patio show code
did you add voice?
voice gateways are an even bigger hell
yea
and zlib?
ye
I am redoing my bot cuz I went from 1 shard to 30 and fucked up the whole bot
This is fun
LOl
[--]
how many guilds?
you need to use a for loop
oh alright
I am redoing my bot cuz I went from 1 shard to 30 and fucked up the whole bot
@blissful coral lmaoooo
the reason is that a forEach creates a function on each iteration, which creates a separate scope, so when you await, you are awaiting inside this function, not outside
sadly for const/let loops are slower than forEach
#BlameNodeJS
Fucking discord
lmaoo rip
what
why?
good to know
for loops are faster than forEach wtf are you on
aren't they slower?
not rlly
eh
.foreach is more speed
x doubt
also depends what ur doing
forEach creates an anonymous/lamba function on every single iteration, thats a lot of overhead
ok it still doesn't work
i mean events not keys 
// this doesnt work
// because this is creating a function on every iteration, so you are awaiting inside the function only
bla.forEach(async x => {
await y();
})
// its the same as doing this
for(...) {
(async function() {
await y();
})()
}
// the entire loop will complete super fast, and create a gazilion functions that will only be resolved later
// while the outside code continues normally without waiting for these functions
// you have to do this instead
for(...) {
await y()
}
// this way the loop actually respects and awaits the promise before continuing to the next iteration
``` @dense patio
i'll give this a try
urg compiling rust is horrible
Someone link me to discord support for getting intents after verification
I am to lazy to look it up
uh i just emailed them
send it
literally just sent to their support address
@dense patio you will need to show more code then
well this is pretty much everything besides the message
[---]
i tried awaiting the contents in the for loop but that did nothing, then i tried awaiting this entire piece of code and that did nothing
@quartz kindle
what are you trying to access and where?
what do you mean
you said you were trying to get a variable outside of this
in this part
if(totalPlays > 0) {
songTxt += `${member.user.tag} - ${totalPlays} plays\n`;
}
i'm trying to add to the songTxt string to send as a message
but the string is empty when i try to send it
it sends it just below that chunk up there
the songTxt variable is created inside the members.fetch().then()
where is the message sending code?
if its outside this .then() it wont work
it is
i had it inside before but that didn't work so i moved it back outside
but that was also when something else was wrong
ok now it just does nothing
let reqArtist = args.join(` `);
let reqArtistCaps = [];
args.forEach(arg => reqArtistCaps.push(toCapitalString(arg)));
var songTxt = ``;
message.guild.members.fetch().then( async members => {
for(const member in members) {
let dbUser = await User.findOne({ discordID: member.user.id });
if(dbUser) {
let totalPlays = 0;
dbUser.songs.forEach(song => {
if(song.artist.toLowerCase() == reqArtist.toLowerCase()) {
totalPlays += song.plays;
}
});
if(totalPlays > 0) {
songTxt += `${member.user.tag} - ${totalPlays} plays\n`;
}
}
}
console.log(songTxt.length)
let embed = new Discord.MessageEmbed()
.setAuthor(songTxt.length > 0 ? `Who Knows ${reqArtistCaps.join(` `)}` : `---`, message.guild.iconURL({ dynamic: true }))
.setDescription(songTxt.length > 0 ? songTxt : `No record of this artist.`)
.setColor(config.colors.primary)
.setTimestamp(new Date());
message.channel.send(embed);
})
ok this is the entire command lol
does console.log(songTxt.length) show anything?
it logs 0
ah, the for loop is wrong
for(const member of members.values())
since members is a collection which is basically a Map
put a console.log inside it then
yeah it works there
doing this
if(totalPlays > 0) {
songTxt += `${member.user.tag} - ${totalPlays} plays\n`;
console.log(songTxt.length)
}
logs the correct length after each iteration
and the other console.log still shows 0?
yep
well the code looks correct
i dont see how that would be possible, unless its not updated or not saved correctly
yeah these weird little quirks pop up every once in a while and it's infuriating
i just can't understand why it's not working
you are... literally logging the line just after? there's nothing between?
that's exactly what the code is in the command
i can't tell if you're being serious
oh I get it
No I'm sorry I was actually not reading the entire code correctly just your tidbit
hold up one sec, lemme be less of an asshole here and read the code
lol ok

Can you.. uhm... just for the fuck of it, because I'm genuinely curious... can you try to do let songTxt = ""; instead of var? The chances of this working are slim to none but.. I'm... just humor me, please?
that's what i had before but i've changed a bunch of stuff so i'll try it
no dice
same result
hmm.
this is driving me crazy
i was expecting to make this command in like 10 minutes and call it a night
it just doesn't make sense!
No you're right. My brain can see ways to make this code better, but not to... fix it. I don't see what's wrong either.
I threw it at a beautifier to make sure the indent wasn't messing with my brain, it wasn't, your indent is fine, everything is inside the promise, you're not trying to use await inside a forEach, there's nothing else that needs to be awaited....
I mean if it's any comfort, I've been coding for 20 years and I'm as stumped as you are.
jeez
is this passing at all?
yes
cuz otherwise it'd be an empty string
if i log songTxt inside of that, it works fine for each iteration
apologies beforehand since i absolutely did not read the whole thing
yeah they did this #development message
hmmm
And to be clear when you say "logs the correct length after each iteration" you mean, "the lenght of the current iteration" or "the length of all the iterations put together"?
the length of all of the iterations put together
I...
but the log after the loop is wrong?
yep
And it's showing that after all the loops have ended, right?
according to what Tim said, yeah
before it was forEach which apparently works on a different timeline than the rest of the code so the rest ran before it finished looping
i would run that but idk what you got
my recommendation is, well, user a debugger
do step debugging rather than randomly checkinbg everywhere
Could you... try this just for the hell of it? ```js
let reqArtist = args.join( );
let reqArtistCaps = [];
args.forEach((arg) => reqArtistCaps.push(toCapitalString(arg)));
message.guild.members.fetch().then(async (members) => {
let songTxt = "";
for (const member in members) {
let dbUser = await User.findOne({ discordID: member.user.id });
if (dbUser) {
let totalPlays = 0;
dbUser.songs.forEach((song) => {
if (song.artist.toLowerCase() == reqArtist.toLowerCase()) {
totalPlays += song.plays;
}
});
if (totalPlays > 0) {
songTxt += `${member.user.tag} - ${totalPlays} plays\n`;
console.log(`Current length after ${member.user.tag}: ${songTxt.length}`);
}
}
}
console.log(Total length after loop: ${songTxt.length});
let embed = new Discord.MessageEmbed()
.setAuthor(
songTxt.length > 0 ? Who Knows ${reqArtistCaps.join( )} : ---,
message.guild.iconURL({ dynamic: true })
)
.setDescription(songTxt.length > 0 ? songTxt : No record of this artist.)
.setColor(config.colors.primary)
.setTimestamp(new Date());
message.channel.send(embed);
});
yeah true, perhaps.
I've done one little change here though, that shouldn't matter but... eh. just in case. (moved the songTxt var)
@dense patio assuming you are using VSC, check this https://code.visualstudio.com/docs/editor/debugging
alright
that log is outside of the loop
yo
what about the log inside the loop
u got one insde too
no
@grave sonnet no, fuck off
against TOS
nobody's going to help you spam.
if i do this:
if(totalPlays > 0) {
songTxt += `${member.user.tag} - ${totalPlays} plays\n`;
console.log(songTxt.length)
}
wait a second
rather than randomly picking somewhere and trying to figure this out
F5, add a breakpoint, and step in, thats it
yeah go with that 😄
reminding of what i said before, for in doesnt work on collections, so the loop is being entirely skipped
you have to use for of .values() as members is a collection
show code
@quartz kindle Regarding the inquiry yesterday:
it looks with Discord v8 gateway, there's a concurrency of N (max_concurrency) per 5 seconds identify limit. Each N is split into buckets, and buckets must be identified in order (0-15 prior to 16-32).
rate_limit_key = shard_id % max_concurrency
This change made the decision for me, for the across machine coordination.
@gilded plank
Hey, leave Luca alone!
There should be a method to create an invite using your library
idk how
if you tell us what library you're using maybe we can direct you to the right documentation
discord.js
Note that it's not recommended to create invites on guilds that have not specifically requested the bot to do so.
ty
.
Dot
how to do a ping command in javascript?
if (message.content === '+ping') {
message.channel.send(`🏓Latency is ${m.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(client.ws.ping)}ms`);
}
});```
Here
Thank you

how can i invite my bot in my server
so lemme explain it to you real quick
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
choose your bot
go here
press this
click on all the permissions you want your bot to have
and click here
then put the link in browser
hope this was helpful ^^
@tribal siren it doesn't work
let role = message.guild.roles.cache.get('ROLE_ID_HERE');
const member = message.mentions.members.first();
member.roles.add(role);
message.channel.send('Role Added');
}
module.exports.config = {
name: "addrole",
description: "",
usage: "!addrole",
accessableby: "Members",
aliases: []
}```
what's an error here?
well what's an error here
ok
let role = message.guild.roles.cache.get('ROLE_ID_HERE');
const member = message.mentions.members.first();
member.roles.add(role);
message.channel.send('Role Added');
}
module.exports.config = {
name: "addrole",
description: "",
usage: "!addrole",
accessableby: "Members",
aliases: []
}```
so what's wrong in this?
okay
@sturdy star heres one way
var role= member.guild.roles.cache.find(role => role.name === "role name");
kk but still he could google that
i tried it
got this error
code looks like this
var role= member.guild.roles.cache.find(role => role.name === "role name");
const member = message.mentions.members.first();
member.roles.add(role);
message.channel.send('Role Added');
}
module.exports.config = {
name: "addrole",
description: "",
usage: "!addrole",
accessableby: "Members",
aliases: []
}```
because
you need to put const member above role
like this
module.exports.run = async (bot, message, args) => {
const member = message.mentions.members.first();
var role= member.guild.roles.cache.find(role => role.id === "ROLE-ID-HERE");
member.roles.add(role);
message.channel.send('Role Added');
}
module.exports.config = {
name: "addrole",
description: "",
usage: "!addrole",
accessableby: "Members",
aliases: []
}
yea
How do I get work around with it?
or be like !addrole @young flame admin
@rocky hearth reachall isnt a thing
wait what are you coding in?
c# js py ts
!addrole @sturdy star 740980085099724952
ruby rustt
ik, that's y im structuring it
hmm
that's how i want it to do
@sturdy star you gotta retrieve the role id from the arguments
The msg is of type Message. That's y its originating this. And I want to return this either
i don't know much about classes
so what do i have to do now
replace "ROLE-ID-HERE" with args[1]
The
msgis of typeMessage. That's y its originating this. And I want to returnthiseither
@rocky hearth show the code again
the member would be the first argument
^
its still there
replace
"ROLE-ID-HERE"withargs[1]
@crisp fable ok
not you
wait
hh
sorry
wrong person
sorry i don't usual help out with coding lmao
So any luck for me?
what are you coding it in
to me??
yes
looks like nodejs
i can't tell if it's nodejs or c#

no i have homework
for the button method I want to send a message and then react the same message
hhh
for the
buttonmethod I want to send a message and then react the same message
@rocky hearth hm
i lied, i just finished it but you handle it 
i have school :^)
But <Channel>.send() returns a Message, which I'm structuring here
so Message is the parent of this here
mhm
so I can't access reactAll from Message
I can't code
Yes, that's y I'm asking for work around for it
reactAll takes an array of emojies and react them to the message asynchronously/insequence
Have you worked with Structures?
Structures lets the dev to extend the built in classes of djs. And djs will use the extended classes
is it else if or elif on JavaScript?
else if
I maded a kick and ban command but everyone can use it.
How to fix this?
show your script
Who do You want to restrict it to?
did you set up the permissions?
@pale sapphire please show your script
okay, so my script for banning members looks like this
if(!message.member.hasPermission('BAN_MEMBERS'))
message.channel.send("You don't have following permissions: ``BAN_MEMBERS``");
else {
let bannedMember = await message.guild.members.ban(args);
if(bannedMember){
try {
console.log(bannedMember.tag + " is banned.");
message.channel.send (`${bannedMember} has been banned!`)
}
catch(err) {
console.log(err);
}
}
}
}
module.exports.config = {
name: "ban",
description: "Bans a Users",
usage: "!ban",
accessableby: "Admins",
aliases: []
}```
Okie
Wait i am showing
if (!message.guild) return;
if (message.content.startsWith('>kick')) {
const user = message.mentions.users.first();
if (user) {
const member = message.guild.member(user);
if (member) {
member
.kick({
reason: 'They were bad!',
})
.then(() => {
message.reply(`Successfully kicked ${user.tag}`);
console.error(err);
});
} else {
message.reply("That user isn't in this guild!");
}
} else {
message.reply("you didn't mentioned user to kick");
}
}
}); ```
@sturdy star mine looks this
I am figuring
Where to add
message.member.hasPermission('KICK_MEMBERS')
This one
Can i get the right one code pls
await member.ban({ days: 7, reason: `${(reason)}` })
.catch(error => message.reply({ embed: { color: ('RANDOM'), description: (`Sorry ${message.author} I couldn't kban because of : ${error}`) } }));
they did a mini update
but thats mines
you can take reason out
if you want
@young flame thanks moon
np
hey Moon-Chan, I fixed my problem
@young flame hey can you just do a small favour
Just write
And in end of code```
For future references for code errors or problems moon's dev help hours are all the time so just dm me lmao
before code
and in of code
Lol
???
Yes like this
wait my code
Send me code like this
@young flame dont spoonfeed btw
Well eh
when instead of letting them develop it on there own you just give them what there needing
I made the btw



