#development
1 messages · Page 1356 of 1
then why can i turn it on last time?
i have no idea, it should be greyed out only if your bot is verified and not whitelisted for the intent
yeah but it's funn
Is Python's threading module useful, considering GIL makes concurrency effectively useless.
there are also NaN and Array but ok
wait you can have "string smh" as the names of properties in normal JS objects (not JSON)?
That moment when you make a neural network in 90 lines of code
That's cool though
@hollow sedge thanks
yes you can have spaces in property names
but that's a string which is JSON syntax
you can use almost anything as a property name
and yet it's a normal JS object
JSON is a simplified version of a JS object designed to be transfered as a string to other processes or devices
why not?


what the fuck
All object keys are strings, so any value that can be turned into a string is accepted
now i see why Maps exists
Okay so I'm looking for an api which returns random subreddit images in json format
Okay so I'm looking for an api which returns random subreddit images in json format
@hexed wind you're looking forkamar tajreddit API
||ye ik weird doctor strange reference||
You can use the reddit api
let me style the vote page
ThATs UnPrOfeSsIoNaL
You could make a suggestion on their GitHub suggestions repo or something
but I doubt it'll happen
Expecting a website to cater to your special CSS needs is kinda weirdchamp
Imagine if everyone could custom-style their google search results.
imagine if it allowed JS tho
Or throw CSS at a youtube channel page.
that would be epicgames
tbh I don't like how the site even supports css. It brings a ton of inconsistency (and if anything changes)
the vote page has css already
you're expecting too much from what is supposed to be a simple voting system
you're the one who called it ugly
i mean its a joke? lmao
Hi, I would like to get the username of all the users that are in a json. I tried with that code :
exports.run = (client, message, args) => {
var Discord = require("discord.js");
let data = require("./giveaway.json").list;
data.forEach(element => {
let name = client.users.cache.get(element).username;
console.log(element +"~"+name)
})
}```
but it returns me :
```TypeError: Cannot read property 'username' of undefined```
Can someone help me ?
lib : discord.js 12.3
number of ID in the json : 70
if im right there was some way to see al the client users, right?
client.users.cache.get(...) couldn't find the user by its ID, so it returned undefined.
why
You should check if the user is cached beforehand.
how ? 🤔
Save the result of what I said above, check if it's not equal to undefined, and use .username if it's there.
Your cache may also depend on what intents you have enabled.
If you don't have guild member intents, you probably can't rely on the cache.
I don't have any intents
what intents do you need to see all users?
guild member list
@woven sundial name = (await client.users.fetch(element)).username
that also allows to see members from another servers of the one that the command was triggered?
SyntaxError: Unexpected identifier
Tim
var Discord = require("discord.js");
let data = require("./giveaway.json").list;
data.forEach(element => {
let name = (await client.users.fetch(element)).username;
console.log(element +"~"+name)
})
}```
could anyone point me to the different between a pointer to a slice (*[]T) vs a slice of pointers ([]*T) in le golang 
cant find anything on le interwebs
Tim stop spoon feeding everyone, we get fat
xD yeah, true
bruh
it works Tim, thanks a lot, you saved my life lol
is this a spoonfeeding channel?

you'll see
eventually
hmm okay
just search this channel for "spoonfeeding"
477 result
- Be especially courteous and respectful to new members and beginners with regards to Discord or development overall. We’re here to help and support them.
a. Do not spoon-feed developers
Help explain, don't send solutions
up to you to cook it
@quartz kindle cook the spaghetti
what permissions does the client need to use Channel#startTyping()?
send messages, i guess
is there a way to change all embeds sent by my bot have the color changed to a certain color?
would that be api abuse aswell: bot posts in all possible channels in all of his guilds a comment at the same time?
Yes.
Rule of thumb: if you need to spam to get something done, it's likely API abuse.
Use other workarounds, such as only posting in one channel, or having a command to post what should be said.
can't you tell that discord wants you to abuse their api 
with the intents change and slash command integration they want to remove gateway out of the picture and make bots REST only
remember when discord updated their rate limits and introduced the 1 hour ban?
they said there was a bot sending them 300k invalid requests per hour
or something like that
yeah
that's correct
some weeb bot and its users were spamming the shit out of it
wasnt it stuck in a loop?
then the users stormed DAPI complaining how discord broke their sweet hentai bot
general had to be locked
lol
lmao
but yeah with recent changes discord's implying that you should use REST only (slash commands) over gateway
you get information from the slash command and you can fill out the rest with a couple of api calls
they're trying way too hard to be slack
Bruh removing gateway would be small brain
well they aren't going to remove it
they're cutting features from it so that you get more benefits from being REST only
they always wanted to make the gateway for sending and rest for receiving, but some things are difficult to achieve by rest only
their plans are hot garbage
every article discord pushes out has contradicting information with the previous one 
Should I learn react or C#?
uh
those are two entirely different things
"hey there, we just implemented some hot new tech that will make the platform blazing fast"
"hey there, we just implemented some hot new tech thats much faster than the previous one and fixes a lot of issues the previous one had"
dpy
pretty much tim lol
they keep misinforming people about intents and the guild limit for privileged intents (without being whitelisted)
those are two entirely different things
@earnest phoenix both are pretty interesting so what do i go for first
whatever you want
react is an SPA framework
c# is a language
making games in unity using C# or grinding out sometime with react
well
game developing requires good knowledge of trig and trig functions
but those are two entirely different paths so pick what you enjoy more
game developing requires good knowledge of trig and trig functions
@earnest phoenix trick and treat functions?
trigonometry 
you dont really need trig for the games you would (probably) make
you dont really need trig for the games you would (probably) make
@hollow sedge tic tac toe AI
movement, hitboxes, collisions
a lot of that stuff is already handled by unity
owner isn't in cache
or discord sent you garbage data
or discord sent you garbage data
@earnest phoenix tell me smth new
lmao
How can I get online members on the server with Discord.js?
just explained it in #topgg-api
Hi. I wrote a code to get Bot Statistics but this is not working code
bot.guilds.cache.reduce
With Discord.js, I can no longer register the number of members online.
@gleaming dove please learn javascript before trying to make a bot
that looks like copy pasted code ngl
With Discord.js, I can no longer register the number of members online.
@earnest phoenix do you have intents?
And you can
Just use <Guild>.memberCount
It's more reliable than relying on a cache.
oh the number of users online
${message.guild.members.cache.filter(el => el.presence.status == "online" && el.user.bot == false).size}
The only way to get online vs offline members is to request both privileged intents, then fetchAllMembers in discord.js
that looks like copy pasted code ngl
@earnest phoenixconst db = require('quick.db');
Dude, Shouldn't It Be Hard To Say This?
@gleaming dove it is very hard because not one knows wtf db is supposed to be.
But good for you to figure it out 👍
Screenshot Throwed But
Your screenshot didn't show it was supposed to be quick.db and no one would know it was quick.db.
There are other ways too. Like, if you have an invite object, I think there's a property for getting the number of users online, but that:
- Includes all statuses except offline (online, idle, dnd).
- Doesn't filter out bots.
It's not the only db out there that has a fetch method.
I'm saying your problem couldn't be solved by someone else guessing what db you were using, friend.
So being angry at people for not reading your mind serves no purpose.
I understood: D
Is anyone else having this issue?
@thin bison Looks like it tries to fetch a message which doesn't exist anymore.
Every bot that I have that displays a member in an embed just comes up with the id's
and some messages that have to get certain information from the guild just don't send
intents are now enforced so you wont have all users by default anymore.
intents
Thank you
intents are just the things you get
@thin bison Looks like it tries to fetch a message which doesn't exist anymore.
@boreal iron thanks i figure out wat was the problem
what's a good time to message ration for an anti spam
Alright
Is a rasberry pi worth it, I dont like pm2 runtime as im having issues with it
depends on what you're going to use the rpi for and pm2 is unrelated to an rpi
Is a rasberry pi worth it
The pi itself it not necessary needed, u're good to go with pi OS, too
if u have the possibility to host a VM in your LAN
however, network wide ad blocking is just a must have in 2020, but probably it's the wrong discord and channel to discuss about this
lmao
imo raspberry pis are not worth it unless you are working with hardware too
i have one and i never use it
how i can get this with bot
Hello, I want the Invoice code to be added to my bat. Can anyone help me?
@swift umbra nvm
how can I add a role to someone? member.roles.add(role); doesn't work (discord.js v12)
Sorry trying to find some code... All I can find from my phone...bit sketchy but works for me.
does anyone know if a user reacted to a message it would just remove it right after?
Code??@earnest phoenix
const dbl = new DBL('my topgg token', client);
dbl.on('posted', () => {
console.log('Server count posted!');
})
@rancid dove you mean the code to invite your bot to a server?
@swift umbra
I do not want the code to count the number of people who are added to the server Like a plasma bot
@haughty mirage ^
@earnest phoenix #topgg-api probably
ah ok
@rancid dove the server count for your bot is public.
@swift umbra
Yes, I want a bot that can count inside the server Sorry poor English
how can i add a reaction to a message
and run code if the AUTHOR reacted to it
dpy
what do you mean count inside the server?
@swift umbra
Count those who become new members of the server
js
Thanks
Hi, I tried to install canvas but I get that error, can someone help me please ?
https://hastebin.com/voliqaciku.swift
Manage Channels

you are the only one that can answer that question. it is your bot, its how you want to do it.
your doing a switch case for your commands
nevermind
^^^^^^^^
Is it possible to make aliases to a command without having to duplicate the file and rename?
aliases = ['alias here']
Where do I add this, at the beginning of the code?
show your code
On it
put it in a pastebin or something
Kk
hey guys
uh
i'm gonna ask one thing
it's non discord related
but rather
twitter bot
trends_result = api.trends_place(23424975)
trends = trends_result[0]['trends']
print(trends)
trends = filter(itemgetter("tweet_volume"), trends)
sorted_trends = sorted(trends, key=itemgetter("tweet_volume"), reverse=True)
trend_names = '\n'.join(trend['name'] for trend in sorted_trends[:4])
print(trend_names)
currentrends = trend_names
this code only gives me the trends after number 10 or 11
Not sure if this is the right place to ask for development with non discord bots
👍
it's development of anyhing
is it possible to like get ratelimited from mongo?
mongo atlas
and what about mongo that you host?
if you install mongo on the same machine as your code then there will be no rate limit
i dont think atlas is going to rate limit you though
how do i check if a message is in dms?
@drifting wedgejs if(message.channel.type === "dm") { //something }
that moment when your default user is changed because you didnt use a deepcopy 😦
you do that?
do what?
nvm
you can just rewrite your code to update the existing user's data
based on the object
you can get every user's data then check if it matches the format of the default object
but i dont have any data for that user. I'll elaborate:
- user calls command
- checks if user exists in db
- if user doesn't exist, insert
default_user, else get their data from the db - change user object based on what the command is supposed to do
- update user data based on that user object
so you overwrited previous data?
you should create a function that checks the data before setting for undefined and impossible values or decreasing values
well, yes i overwrote previous data, but i never set undefined or impossible values
you should check if the value of something that only increases is smaller than previous data
or make a value that increments every time you update data
I could, but that would be harder than making a deepcopy of it
or actually use a test database
this happened in my real database with real users
i didnt find it in my test database cause i have no friends to test with
you should test it before publishing code
or actually use a test database
@tired nimbus like in memory db
i always test, I just didn't find this bug because it only happens when there is more than one person using the bot
Just make a sqlite db or even a dictionary object in memory to test with
eh
ill probably just add a testdb to mongodb atlas
makes it easier to visualize the data
Or that I suppose
for a test database you could just use a json or use a variable
Although quite slow
atlas isnt slow in my experience
No to json,
Yes to variable/in memory object
atlas isnt slow in my experience
@hollow sedge it'd be slow in terms of unit tests
ah ok
Since those are typically only 1ms or so per test. A network call would add a ton of relative test time
speaking of unit tests
i should probably add those in 🥴
Yeah lol definitely
And couple that with a ci/cd pipeline, gating master branch, and you're set
It's a property of the message
Or check if guild property is null ig
Idk how py does it's objects
i guess..i would have to write custom unittest functions
hmm
prob would do if guild == none
also should commands be accessible thrud,s?
like non guild related commands
i guess..i would have to write custom unittest functions 😦
@hollow sedge that's how it works, yeah
Idk how js unit tests go, but I've heard Jest is a good framework
im actually using python
yeah they have a standard unittest module
I'm coding a discord bot in python how can I change my bots status??
Using python code
Well Grayson, you'll use the change presence
Check your connected accounts

Oops

Sleepy Joe told me
yo guys
-Oop
can someone help me test a gibeaway bot
No
No
N0
why would you need help testing a giveaway bot of all things
Just do unit tests or test on your own server
that certainly can be done with only one person
why would you need help testing a giveaway bot of all things
@hollow sedge Believe it or not, you cant test a random selector with 1 person
😂
It's a bait bot* ftfy
writing unit tests for commands is one thing I'll never understand how to do
Grayson here isn't very technically proficient

@bright bane guess what
What?
you can make a second discord account
😮
as soon as i make one
with my ip atleast
it says i need to verify
as soon as i make one
No?
yes?
Mutant Pls stop
Grayson here isn't very technically proficient :qlaugh: :qlaugh:
@waxen tinsel Actually, I am.. I am a web designer etc
@bright bane stop please
Speaking of people who are not technically proficient..
please
@bright bane
how about this @bright bane ill give you my vpn so you can make another account
Css designer
I feel like you're baiting by asking people to test some thing apparently enticing like a giveaway bot
It's sus
Lol
@waxen tinsel Actually, I am.. I am a web designer etc
@earnest phoenix https://www.youtube.com/watch?v=VDRK0MyuuIM
O
Joe Biden, come on man
@earnest phoenix was just harassing you for the username
That username is 2 hood
Still right tho
-I
No
I watch the video. And Biden says if you dig in a mine you can program..

https://lolis-should.be-leg.al/ ok wtf
what is that website
wrong channel sorry
why that website
I kinda want to help him just for entertainment tbh
Why would he do any of that
@bright bane I'll help 🙂
When he can just
@earnest phoenix Joe Biden also says you arent black if you dont vote for him
Make another account
hes helping you in return for your vote
By discord or..
O
Joe Biden said coal miners should “learn how to program” during a campaign speech in New Hampshire on Monday.
@earnest phoenix Ovpn can contain credentials btw. Be careful sharing those
Here
mine doesnt
Well thats incorrect
its a pritunl setup
@earnest phoenix can you maybe type faster, like why are just saying "O" or "-I"
Unless this only happens in certain countries
its a public vpn i give to people
Ive made 3 accounts from same IP no vpn and no issues
@earnest phoenix can you maybe type faster, like why are just saying "O" or "-I"
@hollow sedge Because, Why not
I've made 2
Bruh
@hollow sedge Because, Why not
@earnest phoenix classic biden, the troll
Biden Bingo words essentially
🙂
@earnest phoenix do you know how to code? or go mining for coal?
Both
Mining for coal is more complicated than coding
Yes, both
at the same time
For sure
True
at the same time
@waxen tinsel joe biden the chad
Is this still development?
Lol
No clue
blame it on @earnest phoenix

Wow
this guy with the one word responses
sometimes one letter
Well, let's just bring Joe Biden on starboard
a => ah => ahh => ahhh => ...
I can't react to my own message 🙂
Not w/ stars
none of you will even be able to talk if you continue like this
move to #general for conversation smh
This TBH
#development message
why are you continuing
i keep getting this error (discord.js v12):
UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message
only started happening after that new change the other day, and i don't know what is causing it
Yeah, those errors can be hard to debug as the stacktrace isn't useful.
You should try experimenting, stepping in and out of your code until you can reach what block of code is causing it to throw that error message.
The error is self-explanatory though: Discord couldn't find the message. That usually occurs when you do something like message.channel.messages.fetch(...)
yeah that's what i was thinking, but there's only 1 place where it ever fetches messages and no one has ran that command recently
i'll play with it and see what happens
Hello, my bot's page has problems with the page's CSS
And the truth looks pretty bad ..
Does anyone know how to fix it?
well what's wrong with it
check your position properties?
Friend I think you misunderstand me, in the PREVIEW it looks like this, in my c:/ it also looks like this, when I give submit the page it looks horrible
t/hack seems legit
What was the problem @weak grotto
I put 2 articles to make a CSS GRID, so I only put it in 1 article, it already looks better but I won't be able to do CSS GRID
Why am I making a paragraph?
img { max-width: 50%; }<p>h1:hover {text-shadow: 0px 2px 1px #333333, 0px 0px 4px #70b231;}</p><p>.contenedor-tyra {width: 95%;max-width: 1200px;margin: 0 auto;text-align: center;</p><p>}</p><p>.entrada-blog a {display: inline-block;background-color: #2196F3;color: white;padding: 10px 20px;text-decoration: none;font-weight: bold;text-transform: uppercase;}</p><p>@media (min-width:480px) {.dos-columnas {display: flex;justify-content: space-between;}.entrada-blog {flex-basis: calc(50% - 1rem);}}```
Oops
You get the point though
const client = new Discord.Client()
const config = require('./config.json')
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
client.on('ready', () => {
console.log('The client is ready!')
client.login(config.token)```
is that correct
No
<@&304313580025544704> this guy is trolling
lol
it works tho right?
Bye
-atmods @hollow sedge
@hollow sedge
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
why
Is nto trolling ❤️
im not trolling..
who trolls
I'm talking about Table
don't care, keep the beef outta here
whats beef
can i change const commandFiles to const commands
-atm- 3fast5me
😫
Excuse me i can't eat beef
😩 drama
I guess table stays here
chill
GUYS WRONG CHANNEL
I'm vegan
@modern latch now you're just being a clown
@modern latch now you're just being a clown
@sinful belfry No am not am vegan
ok
if you continue, you will be muted, ok?
?
He's talking to table
^
guys
feel free to chat development here lol
can i change const commandFiles to const commands
@indigo flax name of variable does not matter
Change it to whatever you like
ok
What's the question?
const client = new Discord.Client() const config = require('./config.json') const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); client.on('ready', () => { console.log('The client is ready!') client.login(config.token)```
@indigo flax
Oh ok
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
works
right?
or did i type it wrong
Is fs require in the file?
Then yes
ok
hi, im having an issue i dont understand..
What's your issue?
i have an object which is the guild in my database, and when i do guild.purgeLogs it says undefied, when i do guild it has purgeLogs inside.. any ideas?
this is only on the website btw, on the bot for some reason it works as intended
Is the property undefined or the guild object undefined?
but every other thing inside the object returns the correct value, but purgeLogs is undefined
property is undefined
Is this d.js?
no
question
its got nothing to with discord lol
const ban = require('./ban.js')
does that
mean
it reads
commands/ban.js
or do i need something else
only unless it has a module.exports inside ban.js, austin
Oh, then your not passing it into object lost
i am, lemme show u
@spare goblet i fixed it

Lmao. Tbh if I didn't see that there, then he did a good job at hiding it
if i do guild.logs it returns the stuff i need, guild.prefix the stuff i need etc
but guild.purgeLogs no worky
Are you treating the purgeLogs as an array?
no, its an object
const command = require('./command')
That's not an object
[] is an array
Check that image you sent here
@vernal rivet ```const command = require('./command')
command/command
or
just
command
so yeah. i am 🤦 lol
if i want to do command/command
Yes it can be a dir or a file
then would it be
its been a while since i've touched this
./command/command?
./command/command
thx
wdym?
Technically you can't treat the array like an object. So when you said it's undefined then that could mean you didn't declare it, you didn't pass it in correctly, or your treating it like an object, which is not allowed. Try accessing the first item in the array
One message removed from a suspended account.
Yes what's up?
i can still access the variable though, its a property
One message removed from a suspended account.
From my knowledge I think your artifact I'd might be an invalid form of an I'd.
i just added something to commands and that returns an array
with the data inside and as expected
Oh wait do console.debug(guild) lost.
Oofers
One message removed from a suspended account.
One message removed from a suspended account.
so I was partly right
just
And it says purgeLogs is undefined?
Can you show the error please?
it just logs undefined
What does your code look like for that?
guild.purgeLogs
Are you logging it after the declaration, or later on?
after what declaration?
Guild declaration
im doing that on a different process
when messages gets purged it adds the data to that
even if theres nothing in that, it should still return something
Where's tim. He is the J's wizard. 
If tim left this server it would be an apocalypse but a smart strategy for him as hundreds of js devs would swarm his server
do you need an intent to DM?
you're more than likely filtering them out from your message handler
or if it's sharded, dms go to shard 0
well i havent done anything on_message so idk
it's because I was getting the guild prefix on message, but obviously that's not possible for DMs
makes sense
is anyone here has a music bot that supports spotify urls?
i have a question
(language be javascript would be a lot better)
best practice is to just ignore dms altogether
yeah, that's my plan
A lot of bots that have Spotify support just take the name and search for it on YouTube.
You can't stream songs from Spotify as it's against their ToS, but I believe it's also against YouTube's ToS, but who cares.
spotify actually takes legal action
i know it's impossilbe from spotify
youtube doesn't care but it's also against their tos too
i'm getting spotify data with a package and im searching it like this:
spData.title + ' - ' + spData.artist
but some songs would be wrong, so i was thinking maybe someone knows a better format search,
Note: im using simple-youtube-api package to search in youtube, if u have a better one, i would be happy to hear it
there's no "perfect format" per se
you'll always get an estimated song
in case you haven't noticed pretty much all bots sometimes get spotify songs wrong
There's no perfect format like cry said, but it's more common to do Artist Name - Song Name
or remove the dash altogether
yeah that too
that package is probably scraping youtube searches which means the queries are tuned to be humanized
i.e. just search it in a format that a human would
well we have a lot of diffrent humans, like the one who search lyrics and ..... XDDD
but thanks about that @sudden geyser!
thank u too @earnest phoenix
anyone know a good website for listing my bot's commands?
alright thanks
Hi
Does anyone have a logging code I can have for a bot ? kinda like carl-bot logs ?
<Client>.users I've found no longer caches all users the bot has a mutual server with, and only like 50-100? I've found it only caches users if they do something like join a server or send a message somewhere, it used to be that it cached all users regardless - is there any way to return to this?
This is discord.js Version 12 btw, ping me if you reply
Does anyone have a logging code I can have for a bot ? kinda like carl-bot logs ?
@earnest phoenix listen for events and log them to their destined channel. We're here to help you with issues you have, but not give you the answer to everything (such as "pre-made" commands).
@earnest phoenix are you looking to cache all users on startup (fetchAllMembers option)? Do you have the correct intents enabled?
ah the fetchAllMembers option is probably what I need
I'll try it
Tried the fetchAllMembers option, bot took longer to login but it's still only adding users to <Client>.users when they send a message
this only started happening today though, did something with discord.js change?
or the Discord API?
you need to enable the GUILD_MEMBERS toggle in your dev portal
Which affects the state of your bot by what events you'll receive.
oh. Is that the Server Members intent?
Assuming it is, I'll have to recode everything to fetch users individually that aren't in the cache, which isn't really too much of a problem I guess
in order to be able to fetch all members, you need the server members intent
in order to receive online users at login, you need the presence intent
are there actually any bots that don't need that information?
how would I go about going through lots of users the bot has a mutual guild with without that?
the fetchUser() function is kinda slow
you want to see how many guilds the same user is in? or what?
No, I've just been using the <Client>.users collection assuming it has all the users the bot knows about in a lot
that was never the case, even before this change
the collection only contained online users
How do I use emojis from a different shard
unless you use fetchAllMembers of course
@obtuse jolt what do you want to do with them?
just use their ids
yeah I use fetchAllMembers - is there any way for me to achieve a similar effect without the Guild members intent?
just use their ids
@quartz kindle I tried this it just said unknown emojis
@earnest phoenix you...
@obtuse jolt hi
@earnest phoenix nope
@obtuse jolt hi
@earnest phoenix it’s... been quite a while
welp, guess I'm leaving bot development
Like it means you can't have autoroles, member join/leave logs
I have commands wherein I need to fetch a lot of users based on IDs I have too
them not being in the cache makes them take way too long to be usable
o shit I need to make all my logs support sharding crap that’s not good
well, there are workarounds probably, depending on your exact use case
is your bot verified? and you didnt apply for the guild members intent when you verified?
hi
ah
I'm 17 and I've never needed it
Anyone know if there is a way to do this more efficiently?
const png = async (_pngPath) => {
if (Math.floor(Math.random() * 100) !== 69) return;
_pngPath = path.resolve(__dirname + '../../../' + _pngPath);
if (!existsSync(_pngPath)) return;
let image = await Canvas.loadImage(_pngPath);
let canvas = Canvas.createCanvas(image.width, image.height);
let ctx = canvas.getContext('2d');
ctx.translate(image.width, 0);
ctx.rotate(Math.PI / 2);
ctx.drawImage(image, 0, 0, image.width, image.height);
writeFileSync(_pngPath, canvas.toBuffer());
return;
};```
really? I'll try something I have then
take a .png and rotate it
if you want to save the image back to disk, thats pretty much how you do it
ok
@quartz kindle how can I download a file sent in chat into a directory
With a certain name
nodejs djs
check message.attachments and download it from the url
Yeah how do I do the downloading part
then just use fs and write the file right
you can also stream it directly to the file instead of buffering it in memory
oh how do you do that?
does anyone know how would one make a effective command cooldown? (d.js)
fs.createWriteStream
hey boomers
just a question
how does break/continue work in js?
it seems to be "odd"
break = cancel loop
continue = skip current iteration
wait
so
why doesnt it work inside of functions, even if the functions are in a loop
and why does it take something similar to a paramater?
something similar to a parameter?
Tim do you know if it is possible or how to load a pfd into canvas
for( ... )
{
if(true) break;
doSomethingElse();
}
something similar to a parameter?
@quartz kindle Yeah you can do like break smth; Just like how you can do return smth;
im not sure what the "smth" for break is tho
ah
you can create labels for loops
although nobody uses that
for example if you have a loop inside a loop, you can create a label for the outer loop, so you can chose which one you want to break
for example if you have a loop inside a loop, you can create a label for the outer loop, so you can chose which one you want to break
@quartz kindle How does one make a label, because I bet that way I can break inside a function thats inside of the loop
@crimson vapor pfd? you mean pdf? lul
Etc
looks to be what you are looking for
oh
wait
oh level
ah
oh u just label with colon
ok
hold up
gotta try this lol
wait
events.js:287
throw er; // Unhandled 'error' event
^
SyntaxError: Undefined label 'loop'
it could be
coolLoop:
when I do this
are you trying to break it from outside?
you can only break it from inside the loop
is anyone else having problems with this not working? client.users.cache.size
@quartz kindle haha JS is just real bullshit doesn’t even support levels for break and continue
@fast trench read #discord-news
are you trying to break it from outside?
@quartz kindle no the inside
I assumed it would... embarrassing
ahhh forgot about that lol @quartz kindle thank you 🙂
you cant do it from inside functions
is the function defined inside of the loop?
functions create a separate scope
anything inside the function is not aware the function is inside of a loop
could you use the label as an argument?
So what is the fix for it?
anything inside the function is not aware the function is inside of a loop
@quartz kindle So even breaking with a label can't solve this
thats hella gae
¯_(ツ)_/¯
there are a million other ways to do it tho
thats why nobody uses labels for loops
any idea on a fix?
Don’t use JS lmao
bruh'
yes...but it has a solution in there and idk what to do
I just said idk what to do...
because you didnt read

yes...I did read it...
so it has a solution
but you dont know what to do
not attacking you just pointing out a flaw in the reasoning I see
@fast trench TLDR:
you need the server members intent to be able to request guild members and use fetchAllMembers
and you need the presences intent to get online users at login
both of those can be enabled in your bot's developer portal
Fixed thank you.
i keep getting this error while trying to load a json file:
Help pls!
Ignoring exception in on_ready
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/discord/client.py", line 333, in _run_event
await coro(*args, **kwargs)
File "main.py", line 141, in on_ready
data= json.load(f)
File "/usr/lib64/python3.7/json/__init__.py", line 296, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/usr/lib64/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
line of code where the error occurs, data=json.load(f)
i defined in this format:
with open('potd.json', 'r') as f
Does anyone here have experience with using node-gyp before? I ran node-gyp rebuild and this error appeared saying bindings.gyp is not found and I have no idea about what is that.
user.setNickname(args.slice(1).join(" "))
.catch((err) => message.channel.send("I do not have permission to change this user's nickname"))
.then(message.channel.send(`:white_check_mark: | Successfully changed **${user.user.tag}'s** nickname to **${args.slice(1).join(" ")}**`));
```
both of them are sending, how do i make only one sends
.then() first, and then .catch()
https://discordbots.org/api/widget/servers/731219163317534740.svg
why this is not counting
@mint thicket what should i need to do?
@earnest phoenix what's inside the json file
omg tysm flazepe
how to make folders for difrent types of commands like admin commands fun commands on discord.js?
@earnest phoenix it means your json is empty
does anyone know how to stop a bot from doing @everyone
but it still does @everyone
Okay
how tf do u update node in heroku
@slender wagon you specify the version in package.json
"engines": { "node": "12.x" } for example
size, pointers, cons/nil, segmentation fault
const premium = await client.shard.broadcastEval(`this.guilds.cache.get("692021327283879957").members.cache.get("${msg.author.id}")`);
if(!premium){
const pembed = new Discord.MessageEmbed();
pembed.setTitle("This is a premium feature.🌟");
pembed.setDescription("Join **[this]()** server to unlock premium tier")
pembed.setFooter(`Stay in the server, to have premium ;)`);
pembed.setColor(`#FAA61A`)
return msg.channel.send({embed: pembed,});
}
why it does not work? Any idea?
no error
it should get the user from that guild
.broadcastEval returns an array to my knowledge.
That also returns an array.
So I have to irritate through the object?
That's one way, yes.
and the other other one ? xD
wot
@tired panther map or reduce
okay
@restive furnace How do i reduce , I just know it when I add something, but remove anything , how does thet work?
[array]#reduce(params)
how would you have a bot remove a users reaction, but have the bots reaction stay?
what library
js
awesome
there are like 4 js libs
Use <Message>.reactions.cache.get(...).users.remove(...) to remove a single user reaction. For example, if there are 5 reactions for 🎉 and I use that expression, there will be four. See https://discord.js.org/#/docs/main/stable/class/Message?scrollTo=reactions for more info.
@earnest phoenix python count = 0 for guild in client.guilds: count += len(guild.members)
try this
That's not very reliable, as you'll have to manage a cache which may not contain every member.
You should be able to add up guild.member_count
not working
What isn't working about it
That's not very reliable, as you'll have to manage a cache which may not contain every member.
@sudden geyser I see thanks for the info

