#development
1 messages ยท Page 1828 of 1
not to fetch one
oh ok
you can fetch up to 100 members without the intent
either by ids, or by query name
๐
like:
let guild = await client.guilds.resolve(a.guildID)
let member = await guild.members.fetch(a.userID)
await memberToUnmute.roles.remove(roleID).catch(console.error)
help me with this plz?
members.cache
why resolve?
how then?
just do .cache.get()
like:
let guild = client.guilds.cache.get(a.guildID)
let member = await guild.members.fetch(a.userID)
member.roles.remove(roleID).catch(console.error)
and you dont need await for that
and fetch or cache.fetch??
thats good?
dont you have to define fillwith as T?
function generate2DArray<T = null>(row: number, col: number, fillWith: T) {
return Array.from(Array(row), () => Array<T>(col).fill(T))
}
yes
thank you
setTimeout(() => {....}, 10000) message.channel.send('time up')```
When i do this, it directly sends time up before 10s can get over
Put your msg.send method inside the timeout or await the timeout.
The script will always continue if you don't await a function
How can I detect spam from a user? Thats a short question but I cant find sth in the internet for this
to get a image on .setAuthor is it .setAuthor("AUTHOR NAME", Link To Image")
or am i wrong
Because that depends on what YOU call as spam
x messages in x seconds
That's a very basic method, yeah
thanks
How can I detect spam from a user?
Like for example:"
s
s
s
s
s
s"
Here you are sending much messages behind each other in a short time span. And I want to detect that when you are sending messages too much
@signal estuary
?
I want to check the time between the last message from the user to the next message from the user
i would have a unique message counter for a user that resets every x seconds or whatever and if they surpass that before it resets they're clearly spamming
Let is the best JS variable type. Prove me wrong
there is no such thing as "best"
Check if the message contents are equal to the prompt.
lol
no
(typeof global === "object" ? global : window)["variable"] = value;
is better
Lmao
Bit excessive XD
Ight imma make it better
let object = value ftw
quick question, how would i get this event https://discord.com/developers/docs/topics/gateway#reconnect
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
like, uh. what would happen for this event to be dispatched
i think thats worded better
When discord sends you a invalid session error
What lib are you using
None
It would be dispatched when you disconnect from discord and then reconnect your websocket with the last s key you received
What lib
none
Why will they use a lib if they're asking for pure discord api documentation
im trying to ask, how would i do this
just to clarify, when i mention a role in an embed, they wont see a ping on the channel will they?
like
No they wont
I believe not
ok good
Unless you put it anywhere outside the embed, pings wont trigger anything
Anything meaning notifications and users
- how would i not initialise a session
- how can i make the gateway not resume previous session
- how would i invalidate an active session
?
is my question
oh? i must've got this event mixed with another then
Umm
The s key which you receive on every event must be sent back to reconnect
Otherwise discord wont be able to know which events you missed
wut
"every event must be sent back to reconnect" "discord wont be able to know which events you missed" ?
discord will send you the reconnect event at least once every 4 hours
it can be much faster tho, for example within 15 minutes
it depends on when their servers need load balancing
this is a wild guess now
thats why eris sometimes disconnects you, because the data they r sending is wrong or something like that?
Let your computer running for 7 hours, you should get the event at least 2 times
wdym the data is wrong?
im not sure, maybe the opcode or d is wrong
well, that seems too simple of a mistake to make for a library with that many people using it to make, but maybe something like this?
i doubt they have something wrong in their websocket code
yeah. ๐คท
could you explain what you mean better? im not sure i understand exactly what your question is
oh its fine, its already been answered
alright then
idk whats goin on with my english today tbh
xD
Tim do you know why connected shards will sometimes randomly time out and reconnect using discord.js for no apparent reason?
not sure if anyone has any experience with discord.js-commando module for node js but im having the following issue.
Code with issue
hasPermission(message) {
roleList.find({Guild_id: message.guild.id}).then(roles => {
console.log(roles[0].Roles) //first line output
const b = (message.member.roles.cache.some(role => roles[0].Roles.includes(role.name)))
console.log("Has permission?", b) //second line output
return b
})
}
OUTPUT
["canban","bot"]
Has permission? true
yet when i run the command i get:
You do not have permission to use the <command> command.
my roles that i have for testing are "canban" so it should be allowed, the code thats running has worked previously.
any suggestions
you mean resume, or hard disconnect?
reconnect resume is normal
Like that
ah
that happens if your shard takes too long to start
you can increase the timeout in the manager
to wait longer
Yeah but they're already started
discord.ext.commands.errors.ExtensionNotFound: Extension 'TopGG' could not be loaded.
does this happen to only one shard? or to many?
is there any mass disconnection event?
like bot restart?
Yeah just one shard, randomly. I get the error for one shard, 30s later it reconnects and all clear.
are you using child process or worker thread?
regular sharding manager or something like kurasuta?
Regular sharding with sharding manager
so it looks like something is causing the shard process to die
and then its respawned by the manager
and for some reason it takes too long to respawn
I have timeout set to -1
where? in the manager?
djs v12 or v13?
i was having a problem like this too, it was about database
I console logged an unknown variable.. it's not erroring in VSC.
huge of data moment
What was the problem?
huge of data
Any help on this, please.
ok so according to the source, the timeout parameter is ignored for respawns
its only used for the initial spawns
Ah
so its a respawn that is timing out
are multiple shards respawning at the same time?
It's weird though. It times out once and reconnects on the second try
do you have anything that runs process.exit() on broadcastEval or something?
so nothing that restarts multiple shards at once?
Nope
But in this scenario, it's only one shard that shows that timeout error, then reconnects immediately
Just randomly for no reason in the middle of the day / night
No other shards affected
yes, the reason im asking is that when respawning, the shards are not aware of other shards. so if two respawn at once, one will fail, then wait 5 seconds before it retries
unknown variable? wym?
Or this... No errors.
That's how js works
If you try to access a member on that variable it will error
hmm, you'd need to enable debug logs to figure out whats going on
I perform a command. It's not working.. and usually because an error should show.. but it didn't show.. meaning VSC is not showing errors.
That would really flood my logs ๐
you can filter some of them out, for example heartbeats
Why don't you show us what's actually happening instead of just telling us random things?
It rarely happens too so I'd be sitting around all day waiting for it to happen, but I guess it's the only way to start looking
you can also silently collect them, then log the last 10-20 of them with process.on("exit")
another thing you can do
if all you want is hide the problem
is override shard._handleError
and add -1 to the timeout there too
xD
Hello. ๐
message.channel.send(meow);
I didn't define meow but it's not erroring.
In summary.. my VSC isn't showing any errors no matter what I did.
Why don't you show us what's actually happening instead of just telling us random things?
What am I supposed to show, dude?
I stated my issue.. but you're asking for more.
any1 know any open source stuff for select commands i want to see because i dont really understand them
.<
do you have error lens installed?
do you have eslint?
vsc by default doesnt do that kind of checks
it does some, but many things are missing
which log?
The terminal.
when it runs?
Yes.
then its not vsc's fault lol
If I run this...
message.channel.send(meow);
It is supposed to say in terminal "meow" is not defined, since I didn't define it.
depending on the context, it can simply turn into undefined
it will error if you use strict context
Yes.. but it's not erroring.
The VSC itself won't show errors.
I'm not able to fix it.
Doesn't work. ๐
then your code is not even running
It is.
how do you know?
They want an undefined variable to throw an error
It's not my command handler problem.
It started yesterday.. and I didn't touch VSC for 2 days.
do you use child process? sharding manager?
No.
i'd need to see your code then
I'm legit searching for the solution..
The code is legit 2 lines..
This.
Are you sure you're not catching the error somewhere
No.
so you're not sure?
const { MessageEmbed } = require("discord.js");
const { black } = require("../../other/texts/colors.json");
module.exports = {
config: {
name: "customcommand",
aliases: [],
usage: "!customcommand",
category: "owner",
description: "Custom command by the Founder of the bot!",
noalias: "No Aliases",
accessableby: "Developers"
},
run: async (bot, message, args) => {
if (!message.channel.permissionsFor(message.guild.me).has(['VIEW_CHANNEL', 'SEND_MESSAGES', 'EMBED_LINKS'])) return;
if (message.author.id != "528256079101034506") return;
console.log("test");
throw "lol";
},
};
.. errors? NOPE.
Idk why. ๐ญ
show where you run command.run()
It's not the command handler.
just show it
It's the same for other projects outside Discord.
For python
.. and other stuff.
It's my VSC.
What if you use the terminal instead of the VSC one
I'm 100% positive it's my VSC.
I tried..
It's not showing.
then it's not VSC?
if running it in cmd does the same thing, then its not vsc
No.. it's probably VSC disabling terminal logging or something..
I'm trying to find the setting.
Can't seem to do so.
I'll just do that now.
and run there
I prefer to develop my bots entirely within windows powershell of course
ok
.. but no error.
now can you show the command handler?
then it's your code
const { MessageEmbed } = require("discord.js");
const { red } = require("../../other/texts/colors.json");
module.exports = async (bot, message) => {
if (message.author.bot || message.channel.type === "dm") return;
if (!message.content.startsWith(prefix)) return;
let args = message.content.slice(prefix.length).trim().split(/ +/g);
let cmd = args.shift().toLowerCase();
let commandfile = bot.commands.get(cmd) || bot.commands.get(bot.aliases.get(cmd));
if (commandfile) try {
await commandfile.run(bot, message, args);
} catch (error) {
return;
// console.log(err);
};
};
๐ฉ
I think it's discord formatting it like this
could be, looks fine on my screen
mobile seems to have gotten syntax highlighting for most languages now
.. what should I put instead.
at least on android
you should understand what try-catch does
do you know what a try catch does?
const {MessageEmbed} = require("discord.js");const {red} = require("../../other/texts/colors.json");module.exports = async (bot, message) => {if(message.author.bot || message.channel.type === "dm") return;if(!message.content.startsWith(prefix)) return;let args =message.content.slice(prefix.length).trim().split(/ +/g);let cmd =args.shift().toLowerCase();let commandfile =bot.commands.get(cmd) || bot.commands.get(bot.aliases.get(cmd));if(commandfile)try{await commandfile.run(bot, message, args);}catch(error){return;;};};
Lol
Yes.. but I'm confused why it decided to not show the error now even though I did it 5 months ago and still shows error.

beautiful ๐คค
because you made it not do anything with the error
Let me see.
best readability on the planet
catch() {} gives you the error
then yuo have to do something with it
you put a return there and nothing else
so it does nothing
It used to show the error a long time ago.
you have a console.log there, but you commented it out
and put return in front of it
Anything below that return won't be run
neither stuff in comments
I've never been more confused.. but this is fixed.
What are you confused about?
try {
// Code
} catch(e) {
// do stuff with e (your error) here
}
I used to make it return only and it would error either way. ๐
.. why not now.
.. not it errors.
Nope..
I haven't touched this file for 5 months. ๐
and you removed the console.log at some point
sigh
.. and between those 5 months were legit errors showing..
what kind of errors
there are other ways errors can happen
give an example
.. and for some reason.. this error is SO SHORT than the errors it used to show last time.
Previous errors were like 14 lines while this is 3.
they were probably unhandled rejections
and unhandled rejection wont be caught by that try catch
Hm.
unhandled rejection happens when you dont await a promise, and also dont put .catch() on it
Gotta love how this person here is asking for help but denying every solution they're given
How to delete a message by using id
Discord.Boats, successfully posted your server count.
(node:10824) UnhandledPromiseRejectionWarning: TypeError: this.clean is not a function
at Object.run (C:\Users\hajji\Desktop\Attitude Database\src\commands\owner\eval.js:61:66)
at module.exports (C:\Users\hajji\Desktop\Attitude Database\src\events\guild\message.js:35:33)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:10824) 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: 1)
(node:10824) [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.
Previous errors be like.
um, doesn't try-catch catch unhandled rejections? At least when the method is awaited
Oh.
yes, unhandled promise rejection
when its awaited yes
they await it
If I want to make this show.. I used to add just return.. now it doesn't show anymore.. so I logged the error and now it shows referenceerror instead.
yes
a promise rejection is converted to an actual error when you await it
then you can catch the real error
promise rejection is basically an "unknown error"
wait
so when you await the promise, you have access to the real error
what is better, to show the unhandledrejection error or the referenceerror?
the reference error
Ohhh...
.. wait, so from the unhandled rejection error is where you can get the reference error?
async function something() { throw "lol"; }
throw "lol" // error and will crash the process
try {
throw "lol"; // normal error
await something() // normal error
something().catch(console.log) // normal error caught in the catch() instead of the try/catch
something() // unhandled rejection, we dont know where, what, when this error came from. can crash the process.
} catch(e) {
console.log(e) // no crash because the errors are caught
}
I need to put this in my notes.. this is so helpful. ๐
So new question for whoevers got a sec. is there anything special i need to to with the discord.js-commando module to capture and do something with the client.on('guildMemberAdd') event?
Thank you so much..
no idea sorry, not a lot of people use commando
you can try asking in the discord.js server
damn.. thanks for this
if only i could get a response.
what do most people use then?
most people make their own command handlers
makes sense
since its not a hard thing to do
no
its not
and i had one but i was following along with a tutorial and it said "Scrap the perfectly fine command handler we used to have and try out this module".
and its been nothing but headaches :(
lel
๐ฅฒ
rip
good thing ive can go back through my git commits and recover the old one
good thing you are prepared xd
yeah well i do it compulsively for work using git for everything. so its just kinda a habit
using proper git commits, staging, etc. helps out in the long run
oh everytime i had a working version i would save a copy on my hard drive of that specific working version. so like a simple project would have like 20 folders everytime i accomplished a task without it crashing
and they were all copies of what i was working on so i could go back and see what changed
lmao
Tim quick question.
throw "lol";
something()
Both those in the try {} will be handled by the catch, right?
if something is sync, yes
if something is async, then only if its awaited
if you're asking about the order/number or errors, only the first error is caught
if you have multiple errors, only the first error is shown
if... my messages start with too many ifs
.. so the lines that are handled with catch(e) are.. ?
throw lol and await something
Sweet.
the third one is handled by the .catch()
Yup.
the fourth is not handled by anything
.. but doesn't it get handled by catch(e)?
.. or since it's a function that creates an error?
It's called unhandled for a reason
OH.. yes. ๐คฆโโ๏ธ
Yup yup.. makes sense.
Async functions must be awaited to be handled, or else, we won't know where it came from.
yes
Yes.. makes sense.. thank you. ๐
if they are not awaited, they can still be handled with a .catch()
but if they have neither one nor the other, then its an unhandled rejection
basically
async functions are something that happen "later"
not right now
so if you await, you tell the code to wait until it finishes, so it can handle the result here and now
if you dont await, then the code will deal with it later
.catch() handles it later
if its not awaited, then it checks later, and if later it doesnt see a .catch() it has nowhere to go and explodes
Yes.. this does make sense..
how do i make this into a circle using canvas in discord.js javascirpeijgnls trs gjngstr jn
๐
const avatar = await Canvas.loadImage(member.user.displayAvatarURL({ format: 'jpg' }));
context.drawImage(avatar, 25, 25, 200, 200);```
imgage
its not circling
Thanks, once again, for this.. I understood it more deeply and took it seriously to understand.
.. and this is only .catch() not catch(e), right?
should the port be speccified in the redirects oauth2 tab?
so for example: http://localhost:3000
yes, that is for promise.catch()
Sweet.
wdym circling? you want to cut the black background into a circle?
so its transparent background with a black circle, with the discord logo in the center?
depends on your backend
if no port is specified, port 80 will be used for http, and port 443 will be used for https
so if your backend is running on port 80, you dont need to specify
picture circle
the white discord logo thing, its the persons avatar but its square
how do i make it into a circle
im trying to make a discord login method for my site but whenever i login it takes me back to the login page again
its something to do here, it thinks im not authenticated
can anyone help me?
what is isAuthenticated?
its ok i fixed it
Why does discord show embeds like this on iPhone?
how else would it show?
how does it show on desktop?
does it for all embeds like this
showing my help commands
kinda off putting when most of my users are mobile users
I don't think it is lmao
try it
I can show u my other embed messages, they do the same
sure
can you show the code for the embed?
Yuh
if(["economy", "eco"].includes(args[0].toLowerCase())) {
var embed = new Discord.MessageEmbed()
.setTitle("HentaiCord ใป Command List [Economy]")
.setDescription(`
Each command you use will earn you a random amount of cash from $1 to $5 (or $5 to $10 if you're [premium](${settings.links.premium})).
You can use this cash to purchase items from our store, or save up and become the richest user in the world.
\`balance\` - Check the balance of a user on the server
\`withdraw\` - Withdraw cash from your bank account
\`deposit\` - Deposit cash into your bank account
\`inventory\` - View your owned inventory items
\`shop\` - View inventory items you can purchase
\`buy-premium\` - Buy premium for one million hentaibux
`)
.addField("Fun", `
\`rob\` - Attempt to rob a user on the server
\`bankrob\` - Become an accomplice of a bank robbery
\`slots\` - Try your luck on the slot machines
\`coinflip\` - Flip a coin and win easy cash
`)
.setColor(settings.bot.embed_color)
.setImage(`http://${settings.server.host}:${settings.server.port}/assets/hentaicord-banner.jpg`)
return message.channel.send(embed).catch(console.error);
}
kinda weird cos it's discord
i can pastebin it?
or just zoom out :P
it's not an issue with code, it's a bug with discord lmao
it's always done it for iphone
well for me at least
try this
.setDescription(`
Each command you use will earn you a random amount of cash from $1 to $5 (or $5 to $10 if you're [premium](${settings.links.premium})).
You can use this cash to purchase items from our store, or save up and become the richest user in the world.
\`balance\` - Check the balance of a user on the server
\`withdraw\` - Withdraw cash from your bank account
\`deposit\` - Deposit cash into your bank account
\`inventory\` - View your owned inventory items
\`shop\` - View inventory items you can purchase
\`buy-premium\` - Buy premium for one million hentaibux
`)
remove the indentation from the text itself
๐ค
OH MY GOD
I ACTUALLY THINK THATS IT
BRO IM SO STUPID
i think anyway
lol
xD
worked, your an actual legend
i really didn't think that it would matter for those indentations.
clearly it does lmao
damn
discord is supposed to ignore those, but for some reason it doesnt on iphone
if(message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const packmode = db.fetch(`pack_${message.guild.id}`)
const packmode2 = db.fetch(`pack_${message.guild.id}`)
const responses = ["test", "test3", "test", "test3", "test", "test3", "test", "test3", "test", "test3", "test", "test3", "test", "test3", "test", "test3", "test", "test3", "test", "test3", "test", "test3", "test", "test3", "test", "test3", "test", "test3", "test", "test3", "test", "test3", "test", "test3"]
if(packmode2 == false) return console.log("Packmode off")
if (packmode == true && message.mentions.has(client.user.id))
var response = responses[Math.floor(Math.random() * responses.length)];
message.channel.send(response)
it spam when someone say smth in chat
are you checking for prefix?
that code is not checking if the message starts with the prefix
lel comrninuty
but I wanted to make fillWith as optional
post the full error
https://sourceb.in/bUtAKeNEHE
How can I make it like after the 10s the message collecter stops and says timeup?
there is an option setting for that, called idle
if it collects nothing for 10s, it will stop
A settimeout function should work
um.. but if the msg.contnet === text then i want it to stop, only if they dont get the correct thing i want it to say time up
Do that in a if else statement, if (msg.contents === whatever) {success code} else {return}
i want them to have many tries... not like once if they give wrong it returns... only if the time is up then i want to return
[Hyperlink text](Hyperlink URL), although you can't make field names appear as a hyperlink as they don't accept markdown, you can however make the embed title appear as one, and the one you showed on the screenshot uses them in the description of the embed
If (msg === thing && tries < max tries)
I don't think that's what he's trying to say
collector.on('end', collected => {
// Do stuff with collected messages after it ends
});
You can specify time when creating the collector, ex:
const collector = message.channel.createMessageCollector(filter, { time: 15000 });
Not sure if this changes going more readable or burn someone eyes seeing it
for selectmenu, how many max options can I make?
25
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
Here some documentation on it
@lyric mountain hit my dms when u are online I need to ask something ๐ณ
hello, I ask myself a question a bot can edit a message anytime? even in a year if I have to as long as I have the message id ??
No idea really
I think so
As long as the message is still in the channel you should be able to edit it 
hello!
i have a doubt...
How to add the guild_count attribute in an event in my dpy bot?
This is my code for main.py
import os
import discord
from discord.ext import commands
intents = discord.Intents.all()
bot = commands.Bot(command_prefix='?',
help_command=None,
activity=discord.Game("?help"),
intents = intents)
#HANDLING COGS
#Loading all cogs at the start
for i in os.listdir('./cogs'):
if i.endswith('.py'):
bot.load_extension(f"cogs.{i[:-3]}")
#RUN
TOKEN = os.getenv('DISCORD_MYBOT_TOKEN')
bot.run(TOKEN)
what do i have to import, what do i have to add?
There's no way to limit who can run slash commands right? lol
I guess I could do stupid shit like fetching the member object and checking with that but so much work >:(((
There is permissions, but only avail for guild command.
const brainy = client.guilds.cache.get('838360776212611103')
var category = brainy.channels.cache.get("838360776694562836");
brainy.channels.create(message.author.id, { parent_id: category })
it creates the channel but not in the parent category
just make it bold
itll look like its a field 

thats what i do with titles and fields

any possible fix?
its bc parent_id isnt an option
do parent instead
wait did they change it?
isn't it always like that?
m touching djs after like 4 months
either way just replace parent_id with parent
thx worked
Yeah I just realized what you meant. Same here.
How can this be an issue ๐ฉ
It's hard to spam $wa with Mudae now ๐
Have to press enter like 5 times
message.channel.parentID ==="838360776694562836"
when i pull this to a if statement, it doesnt works
but if i eval same it works
also parentid is returning null
but in eval it works fine
what version u using?
12.5.3
no matter what i do i can't increase the size of the text
(I print the variable with fillText, make it an image, add it to the main canvas and adjust its size, but it doesn't change at all) Please don't ask fontStyle to increase the size of the font, I want to enlarge it according to the data I have (x, y, scaleX, scaleY, width, height)
Ugh why do slash commands take so long to load
lmao
Guild commands update instantly tho
Hey! I apologize for the tag, but when we print a text on canvas and upload it as an image on another canvas, we can't adjust its size.
^^
Hi, I'm currently developing a bot and beta testing it with a DO droplet. The bot itself is deployed using docker-compose. Dev image has OK-ish latency, however Prod image has about 3-4x latency compared to Dev image, even though dev machine has much worse network and Prod image is much smaller.
How should I diagnose the latency problem?
is it possible to get the ip of an ngrok host?
I got a phishing sms and I wanted to track the ip.... it is using ngrok
No? You can resize images
but i do it like in the code i posted and I am not getting any results
it keeps giving me a 36px bold calibri text
While I was wondering if I had the problem elsewhere, I did this
var canvas = Canvas.createCanvas(1020, 306);
var ctx = canvas.getContext('2d');
The 2 values โโat the end of the drawImage give no response
What can I do ?
Is this Wrong;
message.channel.send(` ${message.guild.iconURL( dynamic:true )}`)```
?
Maybe I am out of date lol, haven't coded a bot in a month...
yea
idk about the dynamic parameter but you can do ```js
message.channel.send(message.guild.iconURL({ dynamic: true}));
I knew I needed another {} somewhere LOL
Ty
pls help
How can I fetch the entire member list (including offline people) and execute a command on them like add a certain role to everyone?
await message.guild.members.fetch()
This is what I have right now but I can't figure out how to make it give people roles.
@pale vessel
Are you trying to give a role to all the members on the server?
Yeah
You're gonna get ratelimited if you try giving role to each member of a big server
Like 20k requests in a minute
that's api abuse
use Interval
The server isn't big and I can space them out
then it'll take forever
Better than rate limit.
๐
I think 5 second interval is enough. (I'm not sure exactly)
well if you don't care about ratelimit
const role = guild.roles.cache.find(role => role.name === "role name")
if(!role){ return }
guild.members.fetch().then(m => {
m.forEach(member => {
member.roles.add(role)
})
}).catch(console.error)
Akio Do you know canvas?
Nah I'm scared of it to be exact
Well how long do I have to wait after rate limit has been reached?
For it to like cool down
I need help
they say if you send more that 2 request per second you are qualified for rate limit
they don't do it immediately
but when you get ratelimited it could take around a few weeks to get back to normal
By "to get back to normal" you mean the bot will be very limited on sending requests?
No idea
Hopefully someone else might help you
No
not "very limited"
It'll be flagged and stop working
Yes
Guess I'll have to go for interval then
How to get the size of announcement channels in a guild? Below is channels in total.
const amount = message.guild.channels.cache;
hi
so i wanted to add dropdowns to my bot
i found a package which does it something like this
await ctx.send(
"This message has a select menu!",
components=[
SelectMenu(
custom_id="test",
placeholder="Choose up to 2 options",
max_values=2,
options=[
SelectOption("Option 1", "value 1"),
SelectOption("Option 2", "value 2"),
SelectOption("Option 3", "value 3")
]
)
]
)
but on using it i got this error
TypeError: send() got an unexpected keyword argument 'components'
Filter them by the news type
๐
Where did you get the type list, from?
Sweet.
discord.js ?
<guild>.iconURL({ dynamic: true, size: 4096, format: 'png' })
yes
isnt this for thumbnail?
As mentioned here, it also works as a link, like in !eval.
๐ ๐
How to use iframes in my long description?
By using HTML
You can see an example here https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
Is it like
<iframe src="link"></iframe>```
TIAS
i was gonna ask if anyone tried iframing a WASM site
but then i remember you need js to load the WASM in the first place
oof the save button is not working
You can technically have event handlers in JS that just call underlying WASM, can't you? That way you could have some dumb stuff like button.addEventListener(() => MY_WASM.button_click())
Which then does everything
yes but that's again, js
you can't run any js at all in the desc
even from an iframe
const userInfoEmbed = new Discord.MessageEmbed()
.setColor(color)
.setTitle('Voici tes informations !')
.addFields(
{ name: 'Pseudo', value: `${message.author.tag}` },
{ name: 'ID', value: `${message.author.id}` },
{ name: 'Crรฉation du compte', value: `${moment(message.author.createdTimestamp).format('LT')} ${moment(message.author.createdTimestamp).format('LL')} (${moment(message.author.createdTimestamp).fromNow()})` },
{ name: 'Badges de Synapse', value: `${dataperso}` },
{ name: 'Nombre de commandes exรฉcutรฉes', value: db.get(`commandenombre_${message.author.id}`) },
{ name: 'Arrivรฉe sur le serveur', value: `${moment(message.member.joinedTimestamp).format('LT')} ${moment(message.member.joinedTimestamp).format('LL')} (${moment(message.member.joinedTimestamp).fromNow()})` },
{ name: 'Rรดles', value: `${roles}` }
)
.setThumbnail(message.author.displayAvatarURL({ dynamic: true }))
.setTimestamp();
axios.get(`https://discord.com/api/users/${message.author.id}`, {
headers: {
Authorization: `Bot ${message.client.token}`,
},
}).then((res) => {
console.log(res.data)
const { banner } = res.data;
console.log(banner)
if (banner) {
const url = `https://cdn.discordapp.com/banners/${message.author.id}/${banner}`;
userInfoEmbed.setImage(url)
}
})
message.channel.send(userInfoEmbed);
When I have a banner, the bot needs to add the image to the embed, but not works without errors
Discord doesn't expose about me/banners in the bot's user endpoint
Ah
They do now
Only banner
Add the extension e.g. .png
Embeds require it even though you don't actually need it Nah it works even without the extension so something else is wrong
okay
@pale vessel not works oof and no error
the embed is here but not the image
Try logging the URL
Guys please guide me
what should I use for Machine learning in NodeJS
I tried BrainJS and it didnt work
Tensorflow too difficult for me
no brain and tensorflow?
In my bot website I want to open a window for users to login and then once they do get them back on the main window. What is the usual way of doing this?
uh so
redirect
?
have a redirect script in html file
no
or url (but idk for sure lemme check)
that doesn't explain how to get back to the previous window
/ tab
uh yes
the same website
you go to the place, requesting for login/sign up
you get to the site
That will require JS and can be blocked by browser or client as popups are trash these days.
Just donโt open a separate window aka. as popup.
k
Create a neat login form and redirect the client to whatever site he should go after a successful login.
yeah
hello ?
it is not very important so if it no still ok with me =))
ok
Reading the docs can be that easyโฆ
It will begin to post your server count, and shard count every 30 minutes.
This even work on individual Discord.JS shards that are process separated.
ok
soo.. uhh, I got this:
const serverLog = client.channels.cache.get(modLog);
By the way mod log is defined as an id (string too btw)
and when I use it like serverLog.send() it.... does not recognize the property.
(Exact error: Cannot read property 'send' of undefined)
Channel is not in the cache ig
it is not.. I litilery copy paste the id few minutes ago
and I can talk in it rn too
try fetching it first and then send a message
are you sharding?
no
56 guilds
you are not setting the relevant arguments
ctx.drawImage(image, sourceX, sourceY, sourceWidth, sourceHeight, destinationX, destinationY, destionationWidth, desttinationHeight);
if the text is 50x50 and you want to resize to 100x100, then it should be image, 0, 0, 50, 50, 0, 0, 100, 100
indeed...
Where can I find the size of the text?
copy/download it and then put it in some kind image editor maybe, or photoshop, they usally tell teh sie @rigid maple
wdym? dont you already have the size?
how tf ik whr it is coming from?
The command you initiate
Log command uses ๐ช
as someone said in general, console.trace
Use console.trace instead of console.log
but I hvnt logged anything
also youre using slash commands?
yes
then... catch the error and log it
no the error already said whats wrong
I hv, name gameName as one of my option
Nope it not allowed
not allowed
make it non capital
use kebab-case instead of camelCase
thx
try checking the docs
Yes, since it's part of \w
If someone has any idea about why that's happening I'm glad to hear it
font size ?
Option and command names use the same regex for validation
I suppose so
also i thought characters inside [] get escaped automatically?
so how does \w work
you can use the canvas size
you can also use ctx.measureText
aaaaaa ok thx
Backend
// this is inside the /auth/id/code route
println(userData.id) // prints my correct ID: 256851887502917633
// Send the user ID to frontend to use to retrieve the needed data
call.respond(userData.id) // note: userData.id is of type String
Frontend
this.$astroAPI.get(`/auth/id/${this.$route.query.code}`)
.then(res => {
console.log(res.data) // prints my ID but with an incorrect number at the end: 256851887502917630
localStorage.setItem('userID', res.data)
this.$router.push(sessionStorage.getItem('callback')) // not important
})
.catch(console.error)
Why is js changing my string?
Maybe the respond method parses it to a number?
What library are you using?
just to see
I did as you said but still no change in size
dataCTX = dataCanvas.getContext()
hello
hello
hello
What is it and how do like this
the box
selectmenu
magic
discord dropdowns
ctx.drawImage(dataCanvas, 0, 0, 18, 18, 0, 0, 100, 100);
```There is no problem with this code, right?
Bootstrap
see documentation
it will get an 18x18 box from dataCanvas and stretch it to 100x100 box in ctx
yes but it doesn't send, only the background remains
I think it's small because it's a single digit.
oh again nothing has changed
Could it be because of the size of the dataCanvas?
ooh one has no top
this is top
:D
yes i solved
As you said 18px seems too little.
I guess I can't do that :/
whats the best way to test ur bot without multiple people 
also without needing an alt 
Why not?
wdym?
eh i kinda lose my favorite emojis and i have to re-fav them again 
now i said it its kinda a dumb reason 
you could emulate messages
i got the best results with these values:
ctx.drawImage(dataCanvas, DATA X, DATA Y, ctx.measureText(TEXT).width, FONT SIZE, DATA X, DATA Y, NEW SIZE X, NEW SIZE Y);
wdym emulate?
nothing's stopping you from client.emit("message", { content: "Hi" });
except, you know, if your command needs message.author then you're gonna get an error so you have to make sure to pass the data the command needs
hmmm ok ill try that thx
I'm trying right away
ill probably just build a message with the message class
it doesn't happen unfortunately
dataCTX.measureText
Would be tough emulating for slash command I think
didn't happen again
I don't think so
you didnt add dataCTX.textBaseline = "top";
๐
sorry i bothered you too
@round cove
Is it allowed to make ads bot like when ppl use !ads command bot will send this server's invite link to another server with much ppl
@small plume
tyty
no problem overtime man
I'm making a bot that creates a whole server for one of my fiverr clients.
I'm having issues with getting the roles in the correct order.
So the server is built from a pre-existing template server (don't ask why my client won't just use discord templates, idk.).
I'm using a forEach method to go through the roles and add them to the new server one by one, however, they don't seem to be being placed in the correct order.
Any reason for this?
discord.js btw
What's in for us?
mhm
_no cash no help _ 
You may wanna provide the code to order the roles.
Not anyone has a magical glass ball, you know.
aight chill yer beans lad
module.exports = (Discord, client, settings, guild, template_server) => {
template_server.roles.cache.forEach((template_role, i) => {
setTimeout(function() {
guild.roles.create({
data: {
name: template_role.name,
color: template_role.color,
hoist: template_role.hoist,
position: template_role.position,
permissions: template_role.permissions,
mentionable: template_role.mentionable
}
})
.then(created => { console.log(`[Role] Created '${template_role.name}' role in the server.`) })
.catch(error => { console.error(`[Role] '${template_role.name}': ${JSON.stringify(error, null, 2)}`) });
}, i * 5000)
})
}
I'm using setTimeout to stop rate limits
The issue is obvious, also you do know that you can just provide an array of roles when you're creating the guilds right?
mhm
If I were your client I would've given you 2 stars

lol
same
no need to be rood dooooooooooooooooooooooooooooooooooooo
gonna stop asking for help in here if ppl continue being like this lmao
anyways
ranting aside
truth can be devastating jokingโฆ
You need to know thereโs always a touch of sarcasm in the air in this channel.
I can tell
Why is your client in need of thisโฆ is he doing something that can get his server banned?
meh not bad as a server i joined where ppl just wanting copy pasting and gets spoonfeed 
lol no
Heโs just passing the arguments when calling the functionโฆ
he meant the bot
he is a fiverr creator and people buy servers off of him. He doesn't want to use templates, rather a bot to join the server and create the server for him.
Pretty stupid I know, but I get paid so idrc ๐
wait wait wait, created new or edit existing one
No, It joins a server and starts to build the server.
Ive never used fiverr, how much
I'm not really willing to say, not a lot, but still.
Get's me another review ๐
so basically editing a existing server
nice
Yes but the server won't have anything to start with
They create a new server, the bot joins, sets up the server, then leaves
Sounds like an ass ton of for each statements
yea ik what u meant by tht
It be like dat
but issues are discord rate limits
give me rate limit errors in console but still create the roles anyway
just not in the right order
which is the issue
May flag u for api abuse too
Async await
Nah, GoogleFued said you can specify an array of the roles to create them all at once
Have fun with that :)
ty
Are you keeping all of the role data in one array?

lol
yea
trying to turn the roles.cache into an array
Look at the docs, its in there
โฆ
cough .array
not .toArray() ?
ayy alixy ๐
hi mate
do anyone know how to make 2 prefix for bot 
ive tried using array and or statement
since when im ur m8
idk
damn
Array.
bunch paster
but if you're turning the roles into an array just to iterate over it I'd advise to use .values() instead because its much more efficient@shadow frigate
kk, lemme re-try it
Parse the message and separate the prefix from the rest of the message. Then check if the prefix exists in the array (e.g. prefixes.includes(prefix))
noice

lemme try usin tht
you all have similar contrast profiles and it's confusing me
mine looks the best
guild.roles.create(template_server.roles.cache.array())
.then(() => { console.log("created") })
.catch(err => { console.error(err) });
Only creates one role called "new role"
lmao
Gaha furry go brrr

Im on mobile and my internet is trash so i cant see the emojis XD
it looked bad anyway
Are you trying to copy all the roles in one server to another server
Yes
You can't do that efficiently.
.roles.create will create 1 role.
So if a server has 50 roles, get to work
I believe someone said you can specify an array of roles to create them all at once
I don't think that's possible.
I was talking about when creating a guild you can specify an array of roles
Oh well the bot doesn't create a guild, it joins it, then sets it up
I think forEach would probably be the best bet, but it's still creating them too fast
giving me rate limit errors
rate limit errors? discord js should back off automatically
It successfully creates all of the roles, but just doesn't put them in the right order
you shouldn't be getting any rate limit errors
sure
but if it doesn't automatically do it you should add a delay between role additions yourself
You also can just create them in any order and sort them after.
imagine wasting an api call
Its only being done once
Is there a Promise method for this actually? Promise.all but it waits for one to resolve to go to the next
I thought promise all runs everything concurrently
function lockLoop(channel,members,i) {
setTimeout(()=>{
console.log(i)
if (i<=members.length) {
channel.permissionOverwrites.edit(members[i-1],{
"SEND_MESSAGES": false
})
lockLoop(channel,members,i++)
}
},1000*2)
}
i doesn't increase?
i++ increments the number and returns the previous value
oh 
++i increments the number and returns the new value
ull do i+1 then
or use ++i
or I'll import a math library and then do math.add(i, 1)
though in this particular case doing i + 1 is the best option
either one doesn't make a difference
++i increments the i variable
i++++--++--
Is my preferred choice here.
Ok I'll go ๐
i + 1 doesn't
the mutation won't make a difference
it's unnecessary
who says?
me
ive been busting head trying to figure this out so can somebody help me with this
the result is supposed to be a 1 or 0
this is how the table is supposed to be
Here's the logs from earlier, went AFK, sorry about that
Timeout duration was set to 1.
(node:11132) TimeoutOverflowWarning: 4.348615221335307e+21 does not fit into a 32-bit signed integer.
Timeout duration was set to 1.
(node:11132) TimeoutOverflowWarning: 4.348615221607896e+21 does not fit into a 32-bit signed integer.
Timeout duration was set to 1.
(node:11132) TimeoutOverflowWarning: 4.348615221335307e+21 does not fit into a 32-bit signed integer.
Timeout duration was set to 1.
(node:11132) TimeoutOverflowWarning: 4.348615221419049e+21 does not fit into a 32-bit signed integer.
Timeout duration was set to 1.
[Role] Created '@everyone' role in the server.
[Role] Created 'โจโนCyan' role in the server.
[Role] 'Level 25': {
"name": "DiscordAPIError",
"message": "Missing Permissions",
"method": "patch",
"path": "/guilds/869704137946857472/roles",
"code": 50013,
"httpStatus": 400
}
[Role] '๐ฎ Game 02': {
"name": "DiscordAPIError",
"message": "Missing Permissions",
"method": "patch",
"path": "/guilds/869704137946857472/roles",
"code": 50013,
"httpStatus": 400
}
[Role] 'โโโโ Colors โโโโ': {
"name": "DiscordAPIError",
"message": "Missing Permissions",
"method": "patch",
"path": "/guilds/869704137946857472/roles",
"code": 50013,
"httpStatus": 400
}


