#development
1 messages ยท Page 1762 of 1
we only recently made this bot
I can guess that she found an old answer somewhere on the internet back from the async days
this is why we need to remove ctrl+c -> ctrl+v
i mean does it matter?
encouraging words
But bro, StackOverflow code work... 
when the answer is less than 9 years old yes
๐

Ah yes code that's almost as old as my daughter, that'll work for sure
lmfaooooo
old as your daughter..
ok then
Who's 10 year old.
I mean, if it's Python 2.7... maybe?
I would say send her my regards but thinking about it that seems weirdchamp
try finding a python 3.7+ answer on SO, I bet you won't (without specifically searching)
My point being if the code you're about to copy is about to hit puberty maybe you should reconsider copying it.
well that's one way to say it ๐
I could have phrased that much more awkwardly but I don't want to break your brains 
๐
wait what're those?
lmao I don't have much hope for SO unless a tag specifically mentions the Python version
can I find it on SO?
python answers tend to be trivial tbh, especially if it includes a traceback
Surprisingly though, it's been quite helpful with Sphinx, so I'd still give it credit ๐
changed it to wait_for. and now we get this:
reactionFire = await self.bot.wait_for.reaction('๐ฅ')
AttributeError: 'function' object has no attribute 'reaction'```
wait_for(event_name, check, timeout=float)
lol
wait_for is a method that takes multiple parameters
thats what I did doe
no it's not
you did wait_for.reaction
please, learn the language before the library
"I'm helping my friend with her restaurant"
"Do you know how to cook?"
"I know how to boil an egg."

Am I the only one here who doesn't understand the point of requesting a review from yourself?
oh god sphinx ๐คข
๐
incase you second-guess your pr
hold on hold on
reaction, user = await self.bot.wait_for("reaction_add", timeout=10.0, check=check)
see?
Ok that's not the code you sent before
That should work, assuming you defined check as a function
yes I did
the issues is doe idk how i'm doing that on line 22
since check isn't defined as a function there
this
I added it in the last one
not the first one
thats line 22
bear in mind i can't see line numbers here
ok lemme give you an idea of the code
Why is bot.wait_for.reaction still there lulw
so
python has iterables
namely lists, tuples and sets
and it has the in operator
ok
Poor generators not getting enough credit
good
LMAO
only thing gens are good for is memory usage smh
No, I'm not able to suggest 9 subreddits to add to your bot
im just not capable
They still deserve credit smh
is that.... the end?
well im not going to spoonfeed you, so
You're developing a bot, are you not?
with a moderately advanced library, are you not?
so you should be able to piece this one together
if not, you really need to learn lang before lib
Why lmao
Memory usage 
python: is animated emote part of payload.emoji?
anything else?
yes
was just asking cause i couldnt't ell if you were done
ty
i'm not good at picking up on stuff like that
eek@eek ~/W/toppy.docs> sudo service [bot] status
* [bot].service - [bot] Bot Daemon
Loaded: loaded (/etc/systemd/system/[bot].service; enabled; vendor preset:
Active: active (running) since Mon 2021-05-24 19:42:22 UTC; 21h ago
Main PID: 119 (python3)
Tasks: 6 (limit: 1041)
Memory: 1.1G
hahaha who needs memory
LMFAO
I can easily sustain 8gb ram after a week if I don't restart
this bot has just under 1000 servers
im not an expert but like
there may be a mem leak somewhere

Hello, i want to know how i can remove a specific permission on every role on my server
The documentation isn't clear on this
I know it's the #setPermissions method but how i can deny something
You cannot deny a permission on roles
you can deny them only on channel overrides
Though you can turn them to "off" on roles
are we all ready for BUTTONS DAY tomorrow?! ๐
in case youre wondering buttons day is the day theyre making THIS public: https://dpp.brainbox.cc/a00024.html (scroll to bottom for example)
anyone got any plans to use interaction components in their own bots?
as i see it, its going to completely remove the need for silly things like role reactions and reaction based pagers
Private bot so not that big of a deal
Exactly. Prettier interface for the user and that kind of crap
discord.js doesnt support it yet though does it, its a third party addon
i mean they dont even have slash commands except in their beta branch?
i know d.py has good support for it coming up
so python users get to use it immediately tomorrow
I use speedcord anyway. Wanna torture myself with direct API requests and manual caching
lol
button day monkaS
Interesting
Unfortunately I don't have a use case because even though they are good, I like the small ness of reactions
Buttons are a bit large and chunky
buttons are good for pagination but i think they are too big
yes
my handler and commands are already crying with registering slash command interactions as messages for compability
anyway for a bot to play audio in a stage channel with discord.js?
only in discord.js master
shame you havent got something like this ig https://dpp.brainbox.cc/a00022.html
universal command handler that makes prefixed commands and slash commands work the same from the same handler ๐
wow thats a cool idea actually by replying with command_handler.reply but idont know c++ ๐ฉ
yeah
you could learn ๐
but the same idea could be carried over to js
basically you have to unify the 'reply' function, and internally it routes it to the right place
based on the values in the command_source src parameter
thats why there is no guild id
wow maybe i need to revise my way of handling slash commands
a few months ago
What if we had 3 sizes that we could change anytime
Say, small (reaction-sized), medium, and large
sounds good
would be cool
Heh
native or js?
I already read it
is DashboardPage inside index.jsx?
tell me which
the one which contains this func
yeah the DashboardBoard/index.jsx
idk then, I don't see any issue
yeah
silly question, but did you save the files?
normaly u create react app with npx create-react-app or manually write files?
cause I wrote files manually
for the webpack.config.js
How do I get roles
in what context are you asking
with your bot? on a server? with someone else's bot? on this server???
why are you importing css when you have chakra ui lol
you should have 0 css files when you're using css-in-js
well ... the chakra ui styling is kinda shit
...then why use it?
chakra is absolutely amazing I have no idea why you'd use anything else but I guess it's down to taste at some point
we're adding it to top.gg this week hopefully ๐
Is there anyway to make it externaly?
cause It takes at lots of lines and I hate it
you're supposed to wrap the components you style around other components
it takes many lines in css too lol
you should still be able to import css with default CRA tho idk why you're having issues
oh you ejected?
cause the fucking MiniCssExtractPlugin
why are you even touching webpack
I can't think of any reason why you'd want to eject a modern CRA template
and <path>
how can I get emojis from a message using discord.js? do I have to use a regex or does any function exist for this
lol
you can still do that just put it inside a jsx file
nope, I think <path> won't work in normal .jsx?
some libs have message.emotes or whatever
looks like a regular html element to me
else yes, you'll need regex
dammit
<a?:\w+:\d+>
imma remove the fucking css-loader and move others components to external files and import them
importing svgs with paths working fine for us
is there a regex to only get the ids
bruh
I think i just got overthinked
:<
spent time for nothing
(?<=<a?:\w+:)\d+(?=>)
nvm, fuck webpack
me either. If I need something just go to stackoverflow and copy them
lmao
(?<=...) means "find stuff that suceeds this part, but keep this out of result"
(?=...) means "find stuff that preceeds this part, but keep this out of result"
(?<=...)\d+(?=...) means "find digits that are between X and Y, but keep X and Y out of the result"
or... you can just do
...(\d+)...
lookbehinds are pretty pointless
just use capture groups
btw when you import normal .css it will rename ur class and ids, I dunno why
learning regex is like learning to ride a bike
you'll fall and scrape your knee but get used to it
ah yes, forgot js has that stuff
are you using css modules?
this is why I didn't mention that
yeah... you're supposed to access the capture group lol
ik, that's why I forgot
it matches the correct thing
you can even name your capture groups which is p epic
nvm, I will just use the built-in css that came with chakra-ui
used to be a python exclusive feature
ecmascript 2018 iirc
yes sounds like the correct choice
chakra will also typecheck your css
and autocomplete.. and give you ez mobile-first media queries
easily the best css library I've ever used
damm
now i see chakra is a great choice
but still hate the inline css
I hope they make a external css
looks cleaner
Hi guys, how can I know, publish my bot in discord bots, but I don't know how long it will take for them to review it, someone can let me know how it is.
but css is a part of your components like there's not much reason for it to be separated into a different file
#support read the pins (2 weeks i guess)
yeah but for example you have 20 lines of css. . .
like this shit
there is a very good video on this topic if you wanna watch it https://youtu.be/0ZNIQOO2sfA
๐ Support the show by becoming a Patreon
https://www.patreon.com/funfunfunction
Separation of concerns is pretty misunderstood concept, in programming in general, no just JavaScript and web development. I talk about separation of concerns in the context of React and combining HTML, CSS and JavaScript in one place, but also in the more general p...
Xetera, dblstatistics is your website right ?
nope

luke and xignotic
yeah idk ping luke maybe
nah it's okay ty
you can easily share those styles between components by passing an object
oh cool, didn't know about named groups
idk why you have a fixed heading though I feel like you're definitely doing something wrong
that actually makes string extraction quite easy
giving text elements a set width is almost always a bad idea
unless you want to truncate with ellipsis
hmmm how
bruh, I just started React.js yesterday. How I can figure out what will help and other thingy
const styles = {
position: "fixed",
zIndex: 1031
}
<Spinner {...styles} />
I want to have a feature based on if the server owner votes for the bot it gives them a feature for that month of voting. So I have webhooks setup so I get a log when someone votes but I want to check if the user who voted is in any of the servers with the bot and if they are the owner.
yeah the whole top="calc(...)" thing looks wrong to me I think you need to read up on flexbox and what not
im trying to center it verticaly and horizontaly
yikes
make the parent a flexbox and align/justify center
don't use fixed positioning
you're probably looking at css questions from 10 years ago on stackoverflow
yes . . .
go learn flex and grid and then continue your website
you will be absolutely miserable trying to center shit with calculating offsets from random percentages
thanks
โจ flexbox โจ
yes
it's a shame so many people don't know about flexbox in 2021
most frontend devs flex with how much flex boxes they use
mostly because they copypaste old so answers
stackoverflow
all the good stuff start with flex~
flextape, flexglue, flexseal, flexbox
lmao, I never felt so happy then today
just centered my fucking DIV
OMGGGGG
btw Vertically too
@woeful pike sr for ping but you how I can set this height to max?
tried height="100%"
Anyone have any ideas?
yeah
I think you should make a server
that allows topgg make POST or GET request
so you can see who vote for your bot
I can already see who voted I have that setup that as for now it just console.logs when someone votes
and then simple get there Id and check does the server that the bot in has owner that the same id
did you pass the client variable to your server?
so you can get the guilds list
Ah so I would just have to for each guild check if the id matches the owner id
Ne dion dayฤฑ
Can u give an example
No
<Client>.guilds.filter(guild => guild.ownerID == userVoted.id)
i guess
Thanks
Getting This Error While Running Bot's Help Command,Can Anyone Help?
can you show message.js at line 46 ?
or previous lines too
ok
Ne
this is the way you can read the error
Napim
so you debug things easier
See
lol
Ne dionuz aw
lmao, it is message.channel
because Channel doesn't have message property and it doesn't exist
I Am Noob Coder
no problem bro
Thanks
everyone starts somewhere
yes
how do i get the bot to allow me to mute people
you mean make a bot?
or invite a bot?
nvm wrong server i guess

How Do I Make A Dashboard For My Bot?๐คฃ
you should make an API
that allows website to talk with the bot
#webdev #javascript #discordbot
In this series, we are going to build a Discord Bot Dashboard. We will be using React, Express, MongoDB, and Node.js, aka MERN stack.
Part 2: https://www.youtube.com/watch?v=DomtnrQ4f3Q&feature=youtu.be
Want to support me and the channel? Donations are not required but greatly appreciated!
Become a Patreon: h...
this playlist is kinda usefull
you should watch it
Thanks
but might be out-dated
I'll Watch It
I dunno
OK
how do i deny viewing channels and messages perms on a guild.roles.create
you dont
channel overrides are channel bound, not guild/role bound
hmm alright
make a role and then have that id excluded in the channels of that server or, downright remove the VIEW_MESSAGES permission
alrighty, will do that then. Thanks

Is it just me or is Patreon's API a shitshow?
it's a shitshow
i haven't used it for about 2 years now
but last time i did
it was horrible
don't nuke servers, it's against the tos
no it's not, you're just being an asshole
if you don't like whoever's in the server, leave it
as simple as that
shit can serve as tree food
patreon cant
so shit >>> patreon api

i tried integrating patreon with my bot and patreon was using both v1 and v2 of their apis
v2 provided data that wasn't in v1
but v1 provided data that wasn't in v2
I'm tempted to just move away from Patreon altogether and charge through PayPal
horrid
and v3 provided data that was in neither
then v4 provided no data at all
I've heard good things about chargebee
Yeah I'm looking at the data from v1 and v2 and I just can't get my head around how I'd even start to implement something
Never heard of chargebee
do you think it'd be easier to spin up a puppeteer instance and then grab elements via xpath
instead of using their api
lol
Probably lol
Sending a rocket to the moon to bring back paper copies of the Patreon data is easier at this point tbh
the issue with patreon is not the documentation or the lack thereof
but the payload is an absolute mess
like, I don't even know WHAT to look for
all values look the same, tbf the whole structure looks like a recursive json builder
"what you need is pledge" ok, but WHICH one
there are like 99 keys called pledge, all of them contain the same data
Yeah it's a nightmare
I think I'll just make my own subscription system using Discord and PayPal's APIs
I can't be bothered with Patreon's API and I'm tired of the fees and bad support
the only thing that worries me is the service's insistence in getting a 200 code
like, if someone ever donates while the bot is off
the service must retry after some time
Which? PayPal?
Hm yeah but it would be totally separate to my bot. Users would log in on my website (different host to the bot) using their Discord account then subscribe using PayPal and the response would add them to the db of subscribers
Bot can be offline wouldn't make a difference
I mean it's kind of your job to sync payment information before the bot starts up to make sure you haven't missed anything
Braintree looks simple enough. I see Dyno use it for their billing.
Chargebee also looks like a good alternative if you're using PayPal
if I was monetizing my own product today, I could not consider a solution that doesn't support paypal
every single person I know pays for online things through paypal and not a credit card
Yeah same here
Chargebee looks promising. Thanks for the suggestion @woeful pike I'm looking into it ๐
nice nice
Been working on this for the past few days: https://github.com/tim-smart/discord-api-docs-parser
Wanted to get v9 support in my discord client, so ended up building a code generator that reads the discord API docs lol.
The thought of writing type definitions manually is painful.
discord.js v12
command doesnt work
What are you even trying to do with this
Well youโre doing it incorrectly
see
let role = message.mentions.roles.first()
role.delete()
Could try something like that ๐ค
Ok
I already said message.guild.roles.delete is not a thing which is what youโre doing rn
Do rolero.delete()
k
doesnt work lol
Doesnโt really help with you saying โit doesnโt workโ. Thereโs some sort of stack trace with an error, no?
the console does not tell me anything, it is as if the bot ignored the command
the weird thing is that when I use the create role property, it works
How would the console not be logging anything
Unless the message event is not being emitted for whatever reason I donโt see how
fixed
ty
Nice
ah?
ah.
Something going with discord??
Shards keep dying and doesn't restart
But it shows the shards are alive
But the bot ded
seems fine to me https://scs.twilightgamez.net/m1A4X.png
oh wow, this cool, how'd you do this? is there a template i can refer or something
ik how to get the shard id and guilds
idk the different pings and vcs and users
mmmmmmmmm
One message removed from a suspended account.
for the ping and vc count?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
got it
i usually monitor on the server itself and saw that all shards were up but the bot was ded in some servers, and i see no error logs
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
yeah, thanks!
update discord_user_premium inner join discord_users on discord_user_premium.id = discord_users.id set discord_user_premium.discord_api_id = discord_users.user_id;
``` I'm trying to update my table to have discord_api_id be the value of the appropriate row in discord_users, however when I perform the update query I get duplicate entry for key discord_user_premium_discord_api_id_unique even tho the row itself is unique and not used again within the discord_user_premium table.
I'm really confused

wait im a dumbass
im trying to update the unique row with an already used id

lol
How can I do commands in bot's private message?
depending on the language / lib you use you can just send a message to the message author or fetch the user and send a message to the user object
I'm using discord.js
I want to send directly a message to the bot
and get the command done inside a server
Discord.py https://stackoverflow.com/questions/67700698/this-frequent-error-got-me-global-rate-limited-from-discord-api-discord-py Can someone please answer this question??
What if I want stuff to my top.gg page?
Like icons
Change the colour of some stuff
Make it better
u can use css and html
H A H A
H A H A x2
ahh btw can u help me i posted a ques above
Okies is it mainly html ?
for webpage changes, mainly html, and for looks css
whats the question
Ahh okies
its long cant post here, https://stackoverflow.com/questions/67700698/this-frequent-error-got-me-global-rate-limited-from-discord-api-discord-py this is the link
u indian
yes
noice
i live in saudi arabia
ohh
MP
module.exports = {
name: 'warn',
description: 'warn a member',
async run (client, message, args) {
if(!message.member.hasPermission('MANAGE_MESSAGES')){
const embed = new MessageEmbed()
.setColor('RED')
.setTitle('Insufficient Permission')
.setDescription('You much have the permission of MANAGE_MESSAGES')
return message.channel.send(embed);
}
let member =
message.mentions.members.first()
if(!member) return message.reply("Ping a valid user!");
const reason = args.slice(1).join(" ")
if(!reason) {
return message.channel.send("Please provide reason to warn - warn @mention <reason>")
}
const channel = message.guild.channels.cache.find(c => c.name === 'logs');
if(!channel) return message.channel.send('please create channel named `logs`!')
const embed = new MessageEmbed()
.setColor("#0e2b82")
.addField("Warned User", `${message.mentions.members.first()}`)
.addField("Warned By", `<@${message.author.id}>`)
.addField("Warned In", message.channel)
.setFooter("warn")
.setTimestamp()
.addField("Reason", `${reason}`);
return message.channel.send(embed)
}
}```
how can i improve this
let the user configure the channel name, store it in a database or config file per guild by id, storing the channel id
a lot of people wont use a bot that forces people to have specific channel names (for example, what about other languages)
module.exports = {
name: 'warn',
description: 'warn a member',
async run (client, message, args) {
if(!message.member.hasPermission('MANAGE_MESSAGES')){
const embed = new MessageEmbed()
.setColor('RED')
.setTitle('Insufficient Permission')
.setDescription('You much have the permission of MANAGE_MESSAGES')
return message.channel.send(embed);
}
let member = message.mentions.members.first()
if(!member) return message.reply("Ping a valid user!");
let reason = args.slice(1).join(" ")
if(reason === null) reason = "N/A"
const channel = message.guild.channels.cache.find(c => c.name === 'logs');
if(!channel) return message.channel.send('please create channel named `logs`!')
let member = message.mentions.members.first()
const embed = new MessageEmbed()
.setColor("#0e2b82")
.addField("Warned User", `${member}`)
.addField("Warned By", `<@${message.author.id}>`)
.addField("Warned In", message.channel)
.setFooter("warn")
.setTimestamp()
.addField("Reason", `${reason}`);
return message.channel.send(embed)
member.send(new Discord.MessageEmbed()
.setTitle('You have been warned')
.addField("Warned User", `${member}`)
.addField("Warned By", `<@${message.author.id}>`)
.addField("Warned In", message.channel)
.setColor("RED"))
}
}
how do make it log in the channel like modlogs
What
Custom Logging channel?
use enmap db or quick.db
if u want to make easily
if not then use mongodb or sql or something else
i am use mongodb on my test bot
i am currently learning mongo
cool
any1 knows how i can make a pro version for my bot with patreon? i mean how with patreon i can automatically add a guild id as pro
patreon has webhooks you can listen for, but you need to manage the linking between patreon and discord youself bcs the API doesnt provide you the discord ID of each patreon
i would use a template Embed and just edit it according the case, so you have 1 embed constructor for all 3 messages.
ok, ty, does patreon let me ask a question at the buying? so i can have the guild id
nope
oh ok
patreon is not a billing software
do you have any alternative?
build your own shop and use something like chargebee
ok, ty
then you can ask for discord ids and such on checkout
ok, tysm
this is not the channel for that my g
can someone help me
define voice
Your message parameter is not a real message instance
Probably because you're passing the parameters in an incorrect order
what should i do now?
Show us how you're passing the parameters in your main file to execute the commands
command.execute(...)
how do make warned like this const Warned = args.slice(2).join(" ")
if(!Warned) {
return message.channel.send("you have be warned");
}
Like this?
Already
alright, what discord.js version are you using
"discord.js": "^12.5.3",
Try logging message.constructor.name in your play command file
And see what it logs
is there a way to get access to the top.gg code?
so i can edit my bots page?
const voice_channel = message.constructor.name,
You can just edit the bot page by using HTML and CSS in your bot's long description
Like this?
How can you merge multiple ReadableStream's from VoiceReceiver.createStream()?
no, console.log(message.constructor.name)
huh where?
Wdym where? "Long description"
do i need to click the edit button again?
where?
yes, to edit your bot page; click on the "Edit" button and modify the long description with html/css to give it a nice look
Yes there
You can use <style></style> tags for CSS
what if i want to change the profile picture?
With CSS?
yea
like move it around
You can do that, just apply the CSS animations on it with keyframes
but where though?
@earnest phoenix This happent
If you don't know what div the profile picture of the bot is attached to, you can use inspect element to see it
ahh okies
How can you merge multiple ReadableStream's from VoiceReceiver.createStream() in Discord.js?
I didn't tell you to put it there
wheres the inspect element?
Umm, you never did inspect element before?
no
What browser do you use?
Browser, not search engine
Like Chrome, Firefox, Brave
chrome
Use the PassThrough class from the built-in stream module and pipe all the streams to it
am i allowed to change the way this image looks here?
// Deconstruct `PassThrough` class from built-in module `stream`.
const { PassThrough } = require('stream');
// Declare function for later use.
function mergeStreams(...streams) {
// Construct a new `PassThrough` instance.
let pt = new PassThrough(),
// Get the amount of streams passed through.
l = streams.length;
// Iterate through the streams.
for (const stream of streams) {
// Pipe the current stream to the PassThrough instance without ending.
pt = stream.pipe(pt, { end: false });
// Once the stream is finished and there are no more streams, emit the end event of the PassThrough instance.
stream.once('end', () => {
if (--l === 0) pass.emit('end');
});
}
// Return PassThrough
return pt;
}```
@earnest phoenix ?
Why not, go ahead
like make it a circle?
Sure
That's what I was looking for, thank you!
you can do whatever you want with the page
as long as it doesnt hide or remove top.gg content
like top.gg links and ads
okies
So i'm using css grid to align items like so:
/-------\ /--------\ /-----------\
| first | [space] | second | [space] | [nothing] |
\-------/ \--------/ \-----------/
The second item is centered horizontally, but not vertically. How do I alignit vertically for that grid cell only?
PS align-items: "center" on the container doesn't work
the grid element itself needs to be wrapped in a div that wraps the text second
Discord mobile Bismillah
when in doubt, add more wrapping elements
looks like a spaceship
Aliens have arrived
then make the div align it correctly?
Is there any case when a grid isn't appropriate as opposed to a flexbox and vice versa?
landscape mode 
Looks almost like those tie fighters in star wars
yeah i tried flexbox before
i like flexbox much better than grids
but i needed to align the first item to the left and the second in the center
if you need to stack elements with dynamic widths/heights like we do with tags in the beta bot pages grid doesn't work very well. When you need to display images in a gallery with fixed height/width and spacing flex isn't as good
flex also doesn't universally support the gap property yet
safari just released support for it like last week
Aaah, I see. Thanks
also grid elements are easier to resize based on screen width if you look at auto-fill and auto-fit
how do you vertically align in a div....
flexbox the parent
that's why you wrap the thing you want to align in another element
token: prcess...
That's not how auto property construction works
>pypy3
ModuleNotFoundError: No module named 'encodings'
debug: OperationError:
debug: operror-type: ModuleNotFoundError
debug: operror-value: No module named 'encodings'
I've tried installing pypy3 but I get this error no matter what I try to do with the binary. What can cause the issue? I don't use any virtual environments.
@client.event async def on_dsl_vote(data): votes = json.load(open(f"votes.json")) if not data[user] in votes: votes[user] = {"votes":"1"} json.dump(votes, open (f"votes.json", "w")) if data[user] in votes: votes[user]["votes"] = str(int(votes[user]["votes"] + 1)) json.dump(votes, open (f"votes.json", "w"))
can this be right?
if not x in votes -> if x not in votes
user must be a string
Starting from topggpy v1.1 you can also use data.user
Why do you stringify the amount of votes also
int(votes[user]["votes"] + 1) this is a pointless typecast
for data is that right to use data[user] ?
usermust be a string
i mean to get the id of who voted
It's half-correct
user = "user" troll
data[user] would imply that you are getting a key that references a variable user
If you want to access the key user itself, you need to wrap it in quotation marks/apostrophes
Pypy uses a seperate pip installation?
data[user] mostly means you are trying to access a property which's name is stored as a value of the user variable.
and if i use data.user is same thing?
If your topggpy version is v1.1.0, yes
ok
Yes, but the issue is that PyPy refuses to do anything because of the ModuleNotFoundError
Let's see if copying the encodings package from the lib_python folder will do anything lol
Oh right lol. Sounds like the environment is messed up.
๐ Finally got code generation working from the discord API docs.
Can track discord API changes way easier now :)
Not that many people here implement their own clients lol.
Did I do something wrong?
I'm getting a console log of Shard #0 instead of Shard #1.
require("dotenv").config();
const { ShardingManager } = require("discord.js");
const manager = new ShardingManager("./src/index.js", {
token: process.env.TOKEN,
totalShards: "auto"
});
manager.on("shardCreate", shard => {
console.log(`Shard #${shard.id} is online.`);
});
manager.spawn();
module.exports = async bot => {
if (bot.shard.ids[0] === 0) console.log(`Attitude is now online serving ${bot.guilds.cache.size} servers, ${bot.users.cache.size} members & ${bot.channels.cache.size} channels.`)
};
In the ready event, all bot.users.cache.size will be changed to the new sharding one, I believe.
Shard IDs start from 0
.. and I get this error. ๐ (node:5948) UnhandledPromiseRejectionWarning: TypeError: bot.shard.fetchClientValues(...).reduce is not a function
module.exports = async bot => {
if (bot.shard.ids[0] === 0) console.log(`Attitude is now online serving ${bot.shard.fetchClientValues("guilds.cache.size").reduce((a, b) => b + a)} servers, ${bot.shard.fetchClientValues("users.cache.size").reduce((a, b) => b + a)} members & ${bot.shard.fetchClientValues("channels.cache.size").reduce((a, b) => b + a)} channels.`)
};
Looks like you need to resolve the promise first.
I normally go to CMD and use the node command
node index.js, in the directory of your application/bot
I'm confused, according to the documentation, if I put that line, there should be no error that should be caused. *guide
Ah.. Attitude is now online serving [object Promise] servers, [object Promise] members & [object Promise] channels.
fetchClientValues returns a promise
I got it! ๐
ok so i must run it from cmd?
how do i do it ?
i usually do from vscode
cd to your directory
I should be awaiting it?
Windows key, type cmd, press enter. cd to your directory, once in your directory do node index.js
.. and even if I did so, it yet says that it is not a function. ๐
Yes.
(await bot.shard.fetchClientValues("channels.cache.size")).reduce
k ty
This is assuming an array is returned.
(node:14300) UnhandledPromiseRejectionWarning: TypeError: bot.shard.fetchClientValues(...).reduce is not a function
Hm..
Let me see what it returns without the reduce
You have to do it for all of those function calls.
Wot.. it didn't even return an array.
Try and do npm init, and follow through what it says, you might have a broke package.json now that I think about it
yes maybe since i updated the version
Oh lol, you are doing it within a string interpolation. You will need to move the function calls to the top of the function.
const manager = new ShardingManager("./src/index.js", {
token: process.env.TOKEN,
totalShards: "auto"
});
I think since I putted this on "auto" meaning it just generated 1 shard therefore NOT returning an array, I think if I putted this on 2, it would work?
Is your main your js file name?
Awesome, now try and do node bot.js and see if that works
One weird error
ok i can try uninstalling npm init
then reinstall
it will ask for a file directory
but still not work
hmm
lmao again same error
something has changed it seems
it was working fine yesterday
Yeah 
npm discord.js -v
amog sus
6.14.13
I'm running 6.14.12
According to the npm page, its on 12.5.3
You do yes
ye
hmm
reinstalled 2 times yet no
sa
sad
i never shared code with any one
not even github
or ig i have to make new file
folder
u don't have specified a true path
in your package.json
u have this
{
"name": "saboyana",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Sopow",
"license": "ISC",
"dependencies": {
"canvacord": "^5.2.0",
"canvas": "^2.7.0",
"discord-giveaways": "^4.5.1",
"discord-xp": "^1.1.14",
"discord.js": "^12.5.3",
"dotenv": "^8.2.0",
"got": "^11.8.2",
"humanize-duration": "^3.25.2",
"moment": "^2.29.1",
"node-gyp": "^8.0.0",
"nodemon": "^2.0.7",
"opusscript": "0.0.8",
"parse-duration": "^1.0.0",
"quick.db": "^7.1.3",
"yt-search": "^2.8.0",
"ytdl-core": "^4.5.0"
},
"devDependencies": {
"ms": "^2.1.3"
}
}
verify if ur main is "index.js"
@earnest phoenix
He said his main is bot.js, which he's changed in the package.json
ok
I'm having troubles with sharding.
(node:10592) UnhandledPromiseRejectionWarning: Error [SHARDING_IN_PROCESS]: Shards are still being spawned.
This error occures on my ready event.. therefore I did manager.spawn(10000); but yet still gives another error of ```js
(node:4568) UnhandledPromiseRejectionWarning: Error [SHARDING_READY_TIMEOUT]: Shard 1's Client took too long to become ready.
Well...
This is my ready.js file.
module.exports = async bot => {
if (bot.shard.ids[0] === 0) console.log(`Attitude is now online serving ${await bot.shard.fetchClientValues("guilds.cache.size")} servers, ${await bot.shard.fetchClientValues("users.cache.size")} members & ${await bot.shard.fetchClientValues("channels.cache.size")} channels.`)
};
You are using bot.shard.fetchClientValues when shard 0 becomes ready
The rest of the shards aren't ready yet
you should probably do this in another event
What do you mean do this in another event?
๐
The function's not named bot
Maybe do this in an event in which all shards are guaranteed to be ready
My node.js runs shard.js which runs index.js which runs ready.js
I can't.. that's how the order of my bot goes...
okay but you can't get information like guild size when only one of your shards is ready
I did this... manager.spawn(10000);
.. isn't there some way to await it to make all shards ready then execute the ready.js?
Wait... doesn't that mean that you're spawning 10k shards
Here...
require("dotenv").config();
const { ShardingManager } = require("discord.js");
const manager = new ShardingManager("./src/index.js", {
token: process.env.TOKEN,
totalShards: 2
});
manager.on("shardCreate", shard => {
console.log(`Shard #${shard.id} is online.`);
});
manager.spawn(10000);
I usually do this...
The method you mentioned.
doesn't look like you're looking at the right thing
Oh sh-
I looked at the Shard not Sharding Manager
Let me make some changes real quick.
Well... I still get the error.
Ok
If you know the amount of shards you want to spawn then you can execute the code at the last shard spawn
if bot.shard.ids[0] === totalShards
also
Is that code inside the shard's ready event?
you can directly put it inside the shard manager's shardCreate event
if shard.id === manager.totalShards - 1 { ... }
Yes, but === 0.
if (bot.shard.ids[0] === 0) console.log(`...`);
put it inside the shardCreate event instead and check for the last shard, not the first
Do I remove the ready.js file?
I mean if you don't need it...
Wait.. let me keep it as console.log("Hi") for now.
Bruh...
async
One moment...
bot is not defined, where should I pass bot now?
use manager instead of bot.shard
(node:12364) UnhandledPromiseRejectionWarning: Error [SHARDING_NO_CHILD_EXISTS]: Shard 1 has no active process or worker.
show code...
require("dotenv").config();
const { ShardingManager } = require("discord.js");
const manager = new ShardingManager("./src/index.js", {
token: process.env.TOKEN,
totalShards: 2
});
manager.on("shardCreate", async shard => {
console.log(`Shard #${shard.id} is online.`);
if (shard.id === manager.totalShards - 1) {
console.log(`Attitude is now online serving ${await manager.fetchClientValues("guilds.cache.size")} servers, ${await manager.fetchClientValues("users.cache.size")} members & ${await manager.fetchClientValues("channels.cache.size")} channels.`)
}
});
manager.spawn(manager.totalShards, 10000);
hmmm...
maybe try...
if (shard.id === manager.totalShards - 1) {
console.log(`Attitude is now online serving ${await manager.fetchClientValues("guilds.cache.size")} servers, ${await manager.fetchClientValues("users.cache.size")} members & ${await manager.fetchClientValues("channels.cache.size")} channels.`)
}
});```
Shard didn't operate.
My bot is in 4 servers and I'm trying this, does that affect?
Since I'm trying to test.
if (shard.id === manager.totalShards - 1) {
shard.on("ready", async () => {
console.log(`Attitude is now online serving ${await manager.fetchClientValues("guilds.cache.size")} servers, ${await manager.fetchClientValues("users.cache.size")} members & ${await manager.fetchClientValues("channels.cache.size")} channels.`)
});
}
I don't understand why that wouldn't work 
RIP shard.. didn't work as well.
can you use pseudo classes in css in js
im using inline styles on my react component so i can dynamically modify it
Well... still didn't work.
@cinder patio I realised something...
Shit nevermind.
Shard #0 is ready but so as Shard #1 logs that it is ready but 10 seconds after that, comes this error. (node:17544) UnhandledPromiseRejectionWarning: Error [SHARDING_READY_TIMEOUT]: Shard 1's Client took too long to become ready.
Is there a way to execute mongo queries from a string? Im using js mongoose, i googled and found eval but its deprecated..
I realised that if I put this in the ready.js if (bot.shard.ids[0] === 0), it errors (node:17324) UnhandledPromiseRejectionWarning: Error [SHARDING_IN_PROCESS]: Shards are still being spawned. but if it was === 1 then it doesn't.
Not other then eval iirc but why would you want to? There's are reason it is deprecated.
I know the reason for deprecation, i would like to make a command like !mongo that accepts a query. Easier to do then going to mongo compass -> shell for example
eval() was never deprecated, its just not recommended to be used for a few reasons listed in MDN
Im talking about mongo eval...
Which you could still use for something like this, I don't think there are other options
You can still use the eval itself to query things through mongo, without mongo's own eval
I could probably define db as mongoose.connection.db in the eval and execute functions of it
Okay, ill try that, thanks!
Reminder that db.eval() is just a wrapper of eval()
i assume there is a eval function in mongo shell since its based on js
Be carefull the command (assuming it's a discord bot) is only available to you because when using eval like this you can still execute other code
yea ofc
Heyo.
const manager = new ShardingManager("./src/index.js", {
token: process.env.TOKEN,
totalShards: "auto"
});
I want to use the amount of totalShards as the if (bot.shard.ids[0] === GOES_HERE)
Is that possible?
How To Make This Code Box?
Use ``` before and after the code.
```langshort
Code
```
Anyone knows how to fix this? I'm on windows and these are my start scripts:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"electron-react": "concurrently \"SET BROWSER=none && npm start\" \"wait-on http://localhost:3005 && electron .\""
},
let member = !args[0] ? await client.tools.resolveMember(message.author.id, message.guild) : await client.tools.resolveMember(args[0], message.guild)```
```Error:
TypeError: Cannot read property 'resolveMember' of undefined```
discord.js btw
client.tools is undefined, that doesn't exist in discord.js
client.tools.resolveMember(message.author.id, message.guild) = message.member
not sure that that's how it works
um k
What does this mean?
still waiting to see code in another server
is there legit no one who knows how to solve this issue? Google doesn't even know how
Honestly seeing that you've been asking for at least 24 hours, you should consider asking in a react-related server, or an electron-related server maybe?
I don't know any
discord.gg/reactiflux for react-based. https://discord.gg/H6uTh7m for electron.
development on windows lol
?
"the bot"?
we can't really help you make a random bot you found on github, to run on an external service.
What happens if I update an npm package I already modified myself?
I'm sending gifs through Imgur links on pc it loads fast but on phone its very slow when I checked the gif size was increased 4times on phone. why is this change of size happening ?
Nothing?
You mean someone else`s npm package?
Unless the package is yours
ye
nothing happens
You can't republish someone else's npm package so... you cannot.
oh, so it doesnt like remove my modified stuff?
If you're trying to change code in node_modules, that's... not gonna work
no idea, ask imgur? lol
yeah
I've unironically had a coworker spend a week at work doing this blaming all the issues on a random dependency in one of our dependencies lol
Only when I send it through the bot its size increases I tried sending direct links those are working fine
lol
ok well we aren't imgur, we have no idea how it works or why it would be larger one way or another.
does the size increase really matter?
I wish I could explain the amount of pain I felt when I learned he wasted all that time.
I mean it does do the job well, doesn't it?
Alright
I haven't had that exact situation but I fully and utterly understand the pain.
but does the issue matter lmfao
It loads very slowing
I mean you're not saving the gif are you? You could use a optimizer to decrease the size of the gif
No just links
ยฏ_(ใ)_/ยฏ
using d.js how would I get a unicode string to send as an emoji? ex. I want \U0001F95A to send as ๐ฅ
\u1F95A doesn't work either
try sending it as \๐ฅ
yep, that works
just curious if there's a way to send it as the unicode string
since i'm parsing it
for thing that i just do this \:egg:
I've been having some latency issues for a while and I finally started to debug today. Every 10s it there's a spike as to how long it took for the msg to be send to us. (Simply Date.now() - msg.createdTimestamp)
I did some debugging in various places and even from the msg event the delay is there, so I decided to dig into my lib instead (Discord.js)
From what I can tell, https://github.com/discordjs/discord.js/blob/master/src/client/websocket/WebSocketShard.js#L277 is where they handle the RAW data
So i added a simple check to see if it's delayed here as well
And yup, perfect on every 10 seconds it increases
[2:20:43 PM] Took 1029ms
[2:20:43 PM] Took 900ms
[2:20:43 PM] Took 958ms
[2:20:43 PM] Took 875ms
[2:20:48 PM] Took 1205ms
[2:20:48 PM] Took 1099ms
[2:20:48 PM] Took 782ms
[2:20:48 PM] Took 1175ms
[2:20:48 PM] Took 772ms
[2:20:53 PM] Took 974ms
[2:20:53 PM] Took 906ms
[2:20:53 PM] Took 958ms
[2:20:58 PM] Took 1051ms
[2:20:58 PM] Took 806ms
[2:20:58 PM] Took 1084ms
[2:20:58 PM] Took 921ms
[2:21:03 PM] Took 921ms
[2:21:03 PM] Took 835ms
[2:21:03 PM] Took 1147ms
[2:21:08 PM] Took 752ms
[2:21:08 PM] Took 822ms
Now this could mean Discord is being wack but i doubt that, so it has to be an issue with networking on my machine
But I have no idea how to debug this
does your bot do anything on an interval?




