#development
1 messages · Page 1153 of 1
you got ratelimited
The user has sent too many requests in a given amount of time ("rate limiting"). The response representations SHOULD include details explaining the condition, and MAY include a Retry-After header indicating how long to wait before making a new request.
Also, right here
https://discord.com/developers/docs/topics/opcodes-and-status-codes
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
if you're scraping youtube you need to shuffle through proxies, youtube became much much more stricter with scraping
serverCount = client.guilds
len
serverCount = client.guilds
@drifting wedge You're missing len()
And I don't mean just append it
How could I resolve this error? Changing the vps to change the ip?
if you're scraping youtube you need to shuffle through proxies, youtube became much much more stricter with scraping
@earnest phoenix
How could I resolve this error? Changing the vps to change the ip?
@earnest phoenix Stop abusing an API lol
it's a youtube ratelimit
literally every single music bot out there abuses the youtube api lol
@faint prism Music Bot
rip youtube
Does yt rate limit selenium? Ik that's a slower solution
I never had this problem with blocks to something like
429 epic
rate limits are applied according to some internal algorithm they have
the block is usually per ip
some can bypass it
i only could find bot wide
guilds have a .memberCount property
I'll do a little thing here so to remove the block from this IP
which is a number of total members
rythm was broken for a good week because of this change, a work around is just to shuffle through a list of proxies whenever you get ratelimited
which is a number of total members
@quartz kindle but is there online offline?
no, only total
no
but there is bot wide?
cache thing has that
if you want to separate online and offline, you have to fetch all members
if you want to separate online and offline, you have to fetch all members
@quartz kindle Made a logic error once regarding that behavior lol. That was a painful mistake.
and im adding a stats command
In my lib it returns null for offline, which I thought meant they didn't exist
lmao
and how do i check the users in guilds with the bot and number of guilds with the bot?
i tried but it gives me server stats
not bot stats
"Oh yeah, I'll just delete them from the DB, since I must no longer share a common guild"
rip
len(client.guilds)
Or something right?
lgtm
bo
The user one is a bit different iirc
equivalent to client.guilds.Count or client.guilds.Length in other language
itll just say 1
once again, if you want a number of ALL users, including duplicates that share guilds and offlines and bots and everything, use guild.memberCount, its cheap and easy to use
if you want to separate offlines, onlines, bots, remove duplicates and all that stuff, the only way to do that is to fetch all members, which uses a lot of memory so its not recommended
so which one is it?
Client isn't guild specific btw
It's the bot's session
Unless your sharding every single guild?
client.guilds.Count this tells me guild count bot is in?
client.guilds.Count this tells me guild count bot is in?
@drifting wedge That's not python dude. len(array) is the length in python
len(list)
Is the python equivalent
ok
and client.guilds is a list
oh ok
and for users? is it len(client.users)
yes
but
refer to the message i posted before about the differences between ALL users and separated users
if you dont fetch all members, client.users will only contain online users, not offlines
its not per server
1 sed
sed
I think you can do
guilds = client.guilds
print("Servers including offline members")
for guild in guilds
if not guild.large:
members = guild.members
for member in members:
print(member)
but not sure about that tho
@drifting wedge
guild.members doesnt include offlines either
unless you explicitly fetch all members first
well it works
oh i thought if it wasnt a large guild it did
show code
1 sec
async def stats(ctx):
serverCount = len(list)
memberCount = len(users)
embed = discord.Embed(
colour = discord.Colour.blue()
)
embed.set_author(name='Arch | Stats', icon_url=f"{client.user.avatar_url}")
embed.add_field(name="Total Servers:", value=serverCount)
embed.add_field(name="Total Users:", value=memberCount)```
Can't you just map the client.guilds member_count
And then just add them
can you use undefined variables like that in py? or is list and users defined elsewhere?
should be len(client.guilds) and len(client.users)
Yo sup guys listen i need good bots (moderation,levels,stuff like that) for my server
i just want a nmber
ok ill try
but the server count works
so i dont see why change it
count = map(lambda c: c.member_count, client.guilds)
Total = sum(count, 0)
so this is gooood?
🤔
yes, but once again, it will not show offline users from large guilds
only for small guilds
but go ahead and try it
what Woo said, you have to get the member_count property from each guild and sum all of them
count = map(lambda c: c.member_count, client.guilds)
Total = sum(count, 0)
so add this?
It might not be copy paste. I tried my best, but not a python dev
im not a python dev either, i dont know the exact syntax, but thats the idea you have to follow
for each guild, get the member_count number and add it to a total
Iirc theres a more efficent way to do it aswell I just don't remember it
Hey. How could I remove smthg from an array mongoose.
I've been using the pull method.
const g = require('../../models/guilds');
g.updateOne({ id: message.channel.guild.id }, { $pull: { autoRole: '739887331796058162' } });
MongoError: '$set' is empty. You must specify a field like so: {$set: {<field>: ...}}
This is my current code.
I don't understand this issue though.
I don't think updateOne is the correct method to remove something from the collection?
I got an error lol
out of memory lol
hey, anyone know what might be causing a 'SHARDING_READY_TIMEOUT' issue whenever i start up my bot? it still starts up eventually, but if i try spawning multiple shards then only the first shard ever seems to spawn (idk if this is a related issue), anyone have any suggestions? (using discord.js-light)
that man above you can definitely help you 
You're the best in the business Tim
i dont even use it
oh what do u use lol
true
anyway did that issue start recently? out of nowhere or after some update?
it's been there for quite some time, it isn't new
it's just i started trying to add more shards but then the other shards didn't seem to spawn
So you manage your own sharded client threads from the host process?
not sure if the issue is related
i dont use threads
its all in the same process & thread
well i'll test if djslight has any issues with the sharding manager
I need to read up on shards then
ok thanks
I have a huge list of things I need to read up on
We all do lol. I think it's a dev thing
So I have an HTML website and a js bot.
I want to show the number of servers and the number of users that use my bot on my website.
Can anyone help me out in doing so?
(Basic dev, just started a while back)
you cannot do that without a backend server serving the data
Can you show me the way?
LIke any resources i can look at
to do so
well well he left the server
You could use an expressjs server with a route that responds with your server count, in your html webpage make a request to your server and show the results in your webpage
@dusty shale
^
Do you know any vid or site I can visit to learn more?
you need a way to communicate with your bot, either with REST requests or a WS server (which is just overcomplicated if you don't want realtime updates)
not really
this is in a scope of full stack development
this might help https://github.com/kamranahmedse/developer-roadmap
Could be a terrible tutorial.
But it covers some of the concepts
https://www.taniarascia.com/how-to-connect-to-an-api-with-javascript/
Really haven't read it
I would use a REST request, it is easier you could even set a timeout on your webpage to send a request every once in a while to keep updating the server count
hmm
Iirc eli does something like that
https://elibot.gg/
Well @dusty shale in a simple and primitive way you could manipulate a file everytime your bot is added or removed and track that file in your html
^ template engines
Would it work with a static website?
Yes
You just call the json when someones join and print the value
I mean, when someones join the web
not suggested
Honestly, theres more than just what we have listed here that you could do.
Expressjs
Install: https://expressjs.com/en/starter/installing.html
Basic server: https://expressjs.com/en/starter/hello-world.html
Basic routing: https://expressjs.com/en/starter/basic-routing.html
You could set up a request that responds with your server count
Such a wide range of options
@earnest phoenix i know, i said is primitive
I am ultra primitive
But it works
you shouldn't rely on serving a file due to browser level caching, router side caching and ISP side caching but it could work
granted you can always append a cache breaker
You can add the 3 events on the bot start, to get the actual guilds and write them, and then rewrite when some guild os added or removed 
How bad is my english
7/10 didn't notice
all my files are hosted on github
So?
Even your bot? 
Lol
website files
periodically hosting your bot with github actions :wesmart:

so the express js will be in the bot files right?
I make a dummy command yesterday, can I show?
Yeah discord doing discord things
so the express js will be in the bot files right?
@dusty shale anyone ^
isn't that just using that api for it
stinky
@dusty shale anyone ^
@dusty shale yes
I find 1 closed api and 2 deprecated npm rp
how will i call for it in website
yuh but there's apis that will literally just serve the image based on the url
Make a request to your server
this all will sound very stupid but i cant help it cuz I am a newbie sry
https://minecraftskinstealer.com/achievement/20/Achievement+Get%21/Text+goes+here
https://minecraftskinstealer.com/achievement/20/Achievement+Get!/Text+goes+here
Using javascript
@wary flame could you give me an example of usage
The tutorial I linked earlier covers it iirc
ok sir
Thats the thing that I use to generate them
But you cant use the link to give the image
It provides a php thingy that cant be send as a file, but you can download the image using fs(what i did)
@sinful belfry i tested with a barebones setup and it seems to work
@pale vessel it’s autoRole: []
what could be inside?
If you have jquery:
$.ajax({
method: 'request method',
host: 'your server ip',
url: 'request url'
}).done(count => console.log(count))
@dusty shale
Perhaps idk
@quartz kindle it could be the fetchAllMembers option, because that takes a couple minutes to complete
🤔 most mod bots ignore other bots dont they?
i do
let me test with it
Im sure they do
Also, if its in embed, mod bots probably won't check anyway
But I wanted to send a file
@pale vessel I’m tagging so the message doesn’t get lost. It’s just strings inside []

If you have jquery:
$.ajax({ method: 'request method', host: 'your server ip', url: 'request url' }).done(count => console.log(count))@dusty shale
@wary flame so i just have to replace them?
Pretty sure you can just use request anyway.
node-fetch
This isnt nodejs
You cant install modules in browser
webpack
@sinful belfry still works for me, but try increasing the spawn timeout: manager.spawn("auto",6000,60000) for example
ah ok lemme give that a go real quick
it's common practice to use node-fetch with SPA apps like react
SPA?
single page application
Ah
I knew that
facebook is shit
When’s a good number of server to share?
when?
7
idk around dinner time
What*
But since I am not much of a front end dev I havent really looked into react and other web frameworks
you really should
Discord is laggin jeez
it's amazing to work with
i would never ever go back to regular html + css + vanilla js
I have no need to though, I barely develop front end
Actually
I am working on a front end project atm, is it worth it to switch to react?
deep into the project? probably not, if you're still starting out i would suggest so
If I would switch to react would I be able to make use of react native?
Oh?
im getting this error when i put it on heroku discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'list'
ill send code 1 sec
react native is meant for android and ios apps but there has been some talk about react native working on windows and mac
how do i get membercount for ONE server
cuz im getting membercounbt for all servers
guild.membercount?
memberCount = len(client.users)
you can get the server with the <Client>.guilds.get function
this should be the command
If you have only an id
but its not working
just for one server
not all servers bot is in
and for server list?
serverCount = len(client.list)
client.guilds, not client.list
Or just ask here
Yo guys
Im making this bot
with a math command
can someone gimme the script?
codE*
We dont spoonfeed
That traceback doesn't look pythonic
How to use command?
@floral mulch what command
@fleet hornet npm i http-proxy-middleware
Like I have to use kiss command
Jo how can I give command to bot
@floral mulch we won't make you commands
Like
you give command to bot by making command
Might get bitten

Is it possible to await while doing an iteration? For example, iterating through an array that it's elements are IDs, fetch them one by one
Improve your english please
eval(MATHEXPRESSION) 733652228434296872 this works
@earnest phoenix Generally, evaling math expressions is just not a good idea
There's math expression packages for that
ik
Improve your english please
@wary flame can you plz tell me how to give command to your bot? Show me one example
We dont spoonfeed
They asked to make commands kinda
They're asking how to
@slender thistle exactly
They asked to make commands kinda
@wary flame no
what library 🤔
sometimes you have to understand what is meant, not what is said - woo
Me understanding it might say it's just you
Could you please elaborate though? Add a command to your bot through your code? @floral mulch
Or his english is just hard to understand correctly
@wary flame I'm asking how to give command so bot will react
Could you please elaborate though? Add a command to your bot through your code? @floral mulch
@slender thistle show me a example please
😒
<Client>.on('message', msg => {
if(msg.content === '!ping') {
msg.channel.send('pong')
}
})
@floral mulch simple ping cmd
In d.js
😐
What's the library your bot is written in?
Hmm? Are you asking for support on that bot?
You know prefix of this bot?
owo
You'll have to ask the bot's support server
@slender thistle Just pull the -wrongserver card
how can i do it for only 1 server
You'll have to ask the bot's support server
@slender thistle oh ok..
Thank you so much
0exe, tim and i gave you how to do for one guild and for all guilds earlier
shivaco, is memberserver = len(client.users) correct?
@drifting wedge Do you want to get all users cached or members of a server?
len(guild.members) where guild is a Guild object
wouldnt
guild.member_count be more correct?
... yup, I'm just too used to caching everything
ty
ok
depends on where you are at. if this is a command, you can use message.guild
https://discordpy.readthedocs.io/en/latest/api.html?highlight=message guild#discord.Message.guild
message.guild works yeah
if you're doing this for a command, then you should get the guild from the message, in order to get the guild where the command was used in
async def membercount(ctx):
memberserver = guild.member_count
embed = discord.Embed(
colour = discord.Colour.blue()
)
embed.set_author(name='Arch | Membercount', icon_url=f"{client.user.avatar_url}")
embed.add_field(name="Server Members:", value=memberserver)
embed.set_thumbnail(url=f"https://imgur.com/kmtYlLV.jpg")
embed.set_footer(text=f"{ctx.guild.name}", icon_url=f"{ctx.guild.icon_url}")
embed.timestamp = datetime.datetime.utcnow()
await ctx.send(embed=embed)```
where thp
ctx.message
unless you want to make a command that gets information from a different guild
:kittyNotLikeThis:
@slender thistle Can you send this emoji's url?
no
On phone, can't
you use ids
Thx
you can right click any emoji
@drifting wedge you're literally already doing it
and do "copy link"
I am on phone
ah
:ddd
Just get ctx.guild.member_count
@drifting wedge
you're literally already doing the right thing
thats your code
just do the same thing as that
but with member_count
instead of name or icon_url
in the messgage?
🤔
you want to get the member_count from a guild
ctx.guild is your guild
just use it, the same way you used it in the embed
you already used ctx.guild
his point was you probably should know how to get a guild since you already did it twice
^
this is what i have then ```@client.command(aliases=['members'])
async def membercount(ctx):
embed = discord.Embed(
colour = discord.Colour.blue()
)
embed.set_author(name='Arch | Membercount', icon_url=f"{client.user.avatar_url}")
embed.add_field(name="Server Members:", value=f'{ctx.guild.member_count}')
embed.set_thumbnail(url=f"https://imgur.com/kmtYlLV.jpg")
embed.set_footer(text=f"{ctx.guild.name}", icon_url=f"{ctx.guild.icon_url}")
embed.timestamp = datetime.datetime.utcnow()
await ctx.send(embed=embed)```
imma try it
f strings are like `${thingy}` in js?
yeah
is it const mongoose...... ?
?
you most likely didn't include that module in your package.json file
which what heroku relies on
i did
can you show the file?
{
"name": "code",
"version": "1.0.0",
"description": "",
"main": "server.js",
"dependencies": {
"common-tags": "^1.8.0",
"discord.js": "^12.2.0",
"fs": "^0.0.2",
"mongoose": "^5.9.29",
"i": "^0.3.6",
"moment": "^2.26.0",
"npm": "^6.14.7",
"quick.db": "^7.1.1",
"request": "^2.88.2",
"response": "^0.18.0",
"stream-browserify": "^3.0.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
did you redeploy
author: ""
?
nothing
"author": "", ?
show your build logs
`-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 12.x...
Downloading and installing node 12.18.3...
Using default npm version: 6.14.6
-----> Restoring cache
- node_modules
-----> Installing dependencies
Installing node modules
npm ERR! cipm can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with npm install before continuing.
npm ERR!
npm ERR!
npm ERR! Missing: mongoose@^5.9.29
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.LnjrR/_logs/2020-08-14T15_14_57_580Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version`
node prob ?
plus
should i remove package-lock.json ?
cipm can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with npm install before continuing.
looks like it just wants you to run npm install
so remove all packages?
like just delete your package-lock.json
how to make that if the red thing is not set then its going to be other specified vc [ 743655540047085578 ]
@pale vessel avatar_url returns an Attachment object but d.py implicitly stringifies everything in embeds
so yes it's possible but not as explicit
let pref = db.get(prefix.${message.guild.id}); I get this error? ReferenceError: message is not defined
let pref = db.get(prefix.${message.guild.id});I get this error? ReferenceError: message is not defined
@stable eagle you must put that code in a OnMessage event with 'message' defined on it
If a file is in the directory /hygenx/commands/general/help.js, How would I get the directory name, aka general? Ping me
@earnest phoenix __dirname
ok
is it possible to make it wen a member bans a certain amout of people it takes their roles or gives them roles?
how to fix this ?
is it heroku?
yea
u have required an npm package in ur code but not installed it
it cant find collection
{
"name": "code",
"version": "1.0.0",
"description": "",
"main": "server.js",
"dependencies": {
"common-tags": "^1.8.0",
"discord.js": "^12.2.0",
"fs": "^0.0.2",
"mongoose": "^5.9.29",
"collection": "^0.1.6",
"i": "^0.3.6",
"moment": "^2.26.0",
"npm": "^6.14.7",
"quick.db": "^7.1.1",
"request": "^2.88.2",
"response": "^0.18.0",
"stream-browserify": "^3.0.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
i didi
just do npm i collection again then
is it possible to make it wen a member bans a certain amout of people it takes their roles or gives them roles?
@still badge yes
any tips to make it?
how much ping will compressing and decompressing data add
You can fetch audit logs
As I store alot of things for a user and was thinking of maybe compressing it
@sterile thicket ban 5 ppl within a time limit
what library
or a certain amount of people in a certain time
library?
You can fetch audit logs
@sterile thicket 1sec
You need to fetch it from audit logs
im using discord.js
using express, can i reroute requests roughly, ie if my endpoint is on /v1/user but the request is just made to /user, can i reroute it without losing anything (data)
@coral lichen @earnest phoenix fake mee6s
you can listen to the guildBanAdd event
and store results in a database or something
will compressing and decompressing my data for my database slow down my stuff?
@sterile thicket https://hastebin.com/cosicuyisu.pl
there could be a different way
Oh I was trying to help Pickle here
yeah i need a different way
but there's not like a ban collector in d.js
I'm not sure about your error, sorry
@pale vessel can u help ?
do you guys add the bots here?
like if i make a bot and it gets added
does it stay here?
yes
@still badge you will need to fetch the executor from audit logs then set a timer I guess
thats helpful
its like free 100k members
lol
@still badge you will need to fetch the executor details from audit logs then set a timer I guess
@sterile thicket ok ty
what's the best language to use for bot coding, i use pyton but it be mean to me
the easiest
js then
o
but watch out for memory leaks and shite
...
idk how to use java at all
there is a difference
idk how to use it tho
ok
How can I do coding in a mobile?
hey so i made a dashboard (not completed yet) which is connected to my bot and i want the user who enters it to login with his/er discord acc
i searched and found that i need to do something with oAth or something
but idk how
can someone pls tell me?
ping me if u can
@sacred pewter with an app
Which one?
depends on the long ig
And what library it is....
lang*
First you are supposed to redirect the user to /api/oauth2/authorize with the required url parameters (client_id, redirect_uri, response_type, scope). redirect_uri must be a value which exists in your app's redirect uri list. If and when the authorization process is done it will redirect the user to your redirect url with a url parameter named code e.g https://domain.com?code=x.
In order to exchange for an access token you need to make a POST call to /api/oauth2/token with these values in the body; grant_type, client_id, client_secret, redirect_uri, code. They need to match the values that were used in /api/oauth2/authorize (first request you made) and for code you use the code you got in the url parameter (?code=).
If the request was successful, you'll get a JSON response which contains a access_token and a refresh_token field. You need to cache it. Cache the refresh_token too if you want to do automatic token refreshes. Access tokens usually last for a week so you can choose whether you want to make your sessions last a week or if you want to do automatic token refreshes.
Skip this paragraph if you don't want automatic token refreshes
When you've made your request to /api/oauth2/authorize (request above) the JSON response will also contain a expires_in field. It's saying how long until the token expires in seconds. You can cache it or put it in a database, however don't lose it. Once the token is expired, you want to exchange the expired token for a refreshed one. Repeat the process above and make a POST call to /api/oauth2/authorize except you're going to throw out code out of the body and replace it with refresh_token which you should have cached as said above.
Anyways, you use that access token in authorization headers now. For e.g to get info about your logged in user you call /api/users/@me with the Authorization header set to Bearer token
holy
Once you get a hang of it, it's not that complicated 
do the implicit grant flow, its easier
the only downside is that your users will need to login again every time it expires
Which library does Bot designer for discord in mobile uses?
Most likely discord.js
pretty sure its discord.js
Thx
That means the module collection is not installed (correctly)
but i did it in the package.json
{
"name": "code",
"version": "1.0.0",
"description": "",
"main": "server.js",
"dependencies": {
"common-tags": "^1.8.0",
"discord.js": "^12.2.0",
"fs": "^0.0.2",
"mongoose": "^5.9.29",
"collection": "^0.1.6",
"i": "^0.3.6",
"moment": "^2.26.0",
"npm": "^6.14.7",
"quick.db": "^7.1.1",
"request": "^2.88.2",
"response": "^0.18.0",
"stream-browserify": "^3.0.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
I saw it was installing, then my browser crashed (big hastebin on mobile dont work), I am guessing it failed to install,
Could you maybe upload the log to a txt file
Thx
i didn't do that cuz some of them don't download files thats why
Most of the time hastebin is better
Thx
@wary flame no thank u for help ❤️
Mobile just hates hastebin
It indeed failed at the collection install (compiling trough node-gyp)
so what to do ?
yes for the mongo.db
why does mongo.db need it?
to collect the files/ folders
bot.commands = new Collection();
bot.aliases = new Collection();
bot.mongoose = require('./utils/mongoose.js');
///
bot.commands = new Discord.Collection();
bot.aliases = new Discord.Collection();
@viral iris the package was last updated 6 years ago and already failed to build with node 4 (when looking tough issues on github),
I wouldnt expect it to build correctly on node 12 (your version) use collections (still developed)
How to do a auto delete a command after 5 seconds in Bit designer for discord (mobile)?
But why are you not using discord collections?
How to do a auto delete a command after 5 seconds in Bit designer for discord (mobile)?
@sacred pewter They have a support server ask there
But why are you not using discord collections?
@wary flame is it better ?
idk i got it from source code
dont copy paste, OK.
At least it installs...
@viral iris thats a completely different thing
dont copy paste, OK.
@restive furnace shut up
those have nothing to do with the collection.js module
idk i got it from source code
@viral iris source code probably was made for node 0.something (the version in wich the module did work)
why would I, and no. I am just helping you. 😂.
i not asking for help from u
Well, why you did ask a question in this channel then?? 🤔
@viral iris source code probably was made for node 0.something (the version in wich the module did work)
@wary flame so use discord collections or change node version ?
Use discord collections
you can literally use Map.
Or maps indeed
delete the collection.js package, you dont need it
its a completely different thing
.map()
oh woops,, sorry
let brandNewMap = new Map();
brandNewMap.set("hello", "bye");```
thats how do you use Maps.
Hello, just a question
@wary flame @discordjs/collection 0.1.6 this right ?
Just use Discord.Collection
what's the version ?
You already have d.js
you dont need package
discordjs/collection is included inside discord.js
you dont need to install it separately
^
only ```js
require("Discord.Collection");
i mena ```js
const Collection = require("Discord.Collection");
no
You already require discord.js somewhere right?
@wary flame yws
No
yes*
@viral iris nah
server.js
Just use Discord.Collection
No requiring it, you already required d.js
No requring it, you already required d.js
@wary flame or not who knows
I am now making a loop to show the command category and the list of it's commands, ```const categories = readdirSync("./commands/")
let embed = new Discord.MessageEmbed()
.setTitle('Attitude Help Center')
.setDescription(`These are the list of commands you could use! you can get more information about a specific command by using **\`!help <command>\`**. **(Example: \`!help donate\`)**.\n\nFor arguments in commands:\n\`<>\` means it's required\n\`()\` means it's optional\n\`[]\` means you have to choose one of the following\n**Do not actually include the <>, (), or {} symbols in the command.**`)
.setColor(colors.cyan)
.setFooter(`${message.guild.me.displayName} | Total Commandds: ${bot.commands.size}`, bot.user.displayAvatarURL())
categories.forEach(category => {
const dir = bot.commands.filter(c => c.config.category === category)
const capitalise = category.slice(0, 1).toUpperCase() + category.slice(1)
try {
embed.addField(`${capitalise} [${dir.size}]:`, dir.map(c => `\`${c.config.name}\``).join(" "), true)
} catch(e) {
console.log(e)
}
})
return message.channel.send(embed)```
Now it is made by a loop, and I dont want that tbh, I just want to make a field, show it's title, its description, now the question is. If I want to show the total number of commands in a SPECIFIC category, how can I do that? The loop on it is dir.size, how can I do it for specific
const Discord = require("discord.js");
const { Collection } = require("discord.js")
a = new Collection();
or
const Discord = require("discord.js")
a = new Discord.Collection();
thx ❤️
@wary flame or not who knows
@tight plinth I know (||#development message||)
o
any help for above, please?
@feral aspen you better store your bot commands somewhere in your client object when booting up the bot to be able to look at them more easily when executing commands
in a... file?
@tight plinth
you should make every command an object with properties like name, category, description, code... so you can easily filter them later
@feral aspen
This is the result
stop pinging for no reason im still here bud
@tight plinth Sorry
Now
That is the result, and it is pretty much not good for me,
if you just want to have the commands in a specific category, you can use .filter
I want it all to be seperate .addfield
you can only add up to 25 fields per embed
so that might not be a good idea
a Field for economy and its command
a field for information and its commands
a field
BUT
just make every category in a embed
@dreamy cedar no
no
api abuse
that is BORING
ratelimit
and api abuse
if you want to get commands from a category, you can do commands.filter(c => c.category === "category name").forEach(c => ...)
Ok one sec.
How do I fetch all emojis in discord.js
in this case we cant help u
Shut
.addfield(The category name, its description, the size of the commandsin that category)
Nah I'm not gonna shut
const categories = readdirSync("./commands/")
let embed = new Discord.MessageEmbed()
.setTitle('Attitude Help Center')
.setDescription(`These are the list of commands you could use! you can get more information about a specific command by using **\`!help <command>\`**. **(Example: \`!help donate\`)**.\n\nFor arguments in commands:\n\`<>\` means it's required\n\`()\` means it's optional\n\`[]\` means you have to choose one of the following\n**Do not actually include the <>, (), or {} symbols in the command.**`)
.setColor(colors.cyan)
.setFooter(`${message.guild.me.displayName} | Total Commandds: ${bot.commands.size}`, bot.user.displayAvatarURL())
categories.forEach(category => {
const dir = bot.commands.filter(c => c.config.category === "economy")
const capitalise = category.slice(0, 1).toUpperCase() + category.slice(1)
try {
embed.addField(`${capitalise} [${dir.size}]:`, dir.map(c => `\`${c.config.name}\``).join(" "), true)
} catch(e) {
console.log(e)
}
})
return message.channel.send(embed)```
@feral aspen learn hod addfield works k thx
how do i check audit log perms
if(!message.guild.me.actionType("MEMBER_BAN_ADD")) return('Sorry i dont have permissons!');
like that?
-_-
Do I go on about how people learn differently
and that if you don't feel like helping, why you should even say anything in the first place 
Possible answer?
I am making addfields, the field contains the category name, the category description (which is from my own), and the size of the category
const dir = bot.commands.filter(c => c.config.category === "economy")
const capitalise = category.slice(0, 1).toUpperCase() + category.slice(1)
try {
embed.addField(`${capitalise} [${dir.size}]:`, dir.map(c => `\`${c.config.name}\``).join(" "), true)
} catch(e) {
console.log(e)
}
})```
I did this
I made a SINGLE category ONLY for economy, but the above happened.. 😛
How can I make it only one time instead of a loop
Sorry, I'm mostly a Python person
You'll have to wait for someone who's more familiar with discord.js
You should get the commands in the category instead of all commands
^
https://oliy.is-just-a.dev/is28m_5643.png you're trying to do something like this yeah?
Yes.
Yes, and I want to prevent that
actually if you just remove the foreach loop and keep what's inside it, it should work
Because you're getting the same repeating category over and over again
you know what to do right? check for args, if args check if args = category name, if true send specific embed if no args send normal embed
like that
https://oliy.is-just-a.dev/6ma7ao_5644.png that should work I think
that should work
and?
category not defined
You'll have the category in the args
if there is args
https://oliy.is-just-a.dev/f1d18b_5645.png this is your category right?
Yup
you hard coded this one, that's why it works there
And I want to make a field, containing the category name, description, and total commands in that category
@fluid sonnet if youre using pm2 it does it automatically for u
Wait are you trying to get all commands or just economy commands
Wait are you trying to get all commands or just economy commands
@amber fractal just economy commands,
@fluid sonnet if youre using pm2 it does it automaticly for u
@tight plinth pm2 🤔
i search
then I will keep repeating it for the other categories..
thx @tight plinth
Well, you can generalize it...
,p
with different defenitions.
yes.
but @tight plinth y don't use pm2
?
https://oliy.is-just-a.dev/6eta5_5646.png like this handles all of my categories
I could use filter as well, but I didnt think about that at the time
what can I do in my case.
how save a console.log to a txt file?
a module don't exist for this ?
Well, economy is hard coded in at one point, so you'd have to hard code it at the other points if you want it to be defined when you remove the foreach
@feral aspen first thing first: do you know what each line of your code exactly does?
@feral aspen first thing first: do you know what each line of your code exactly does?
@tight plinth Yes man, wtf.
apparently it doesnt seems to
re analyze your code line per line you try to found the error
wdym
how to set the prefix in command handler ?
This is my current code
const categories = readdirSync("./commands/")
let embed = new Discord.MessageEmbed()
.setTitle('Attitude Help Center')
.setDescription(`These are the list of commands you could use! you can get more information about a specific command by using **\`!help <command>\`**. **(Example: \`!help donate\`)**.\n\nFor arguments in commands:\n\`<>\` means it's required\n\`()\` means it's optional\n\`[]\` means you have to choose one of the following\n**Do not actually include the <>, (), or {} symbols in the command.**`)
.setColor(colors.cyan)
.setFooter(`${message.guild.me.displayName} | Total Commandds: ${bot.commands.size}`, bot.user.displayAvatarURL())
const dir = bot.commands.filter(c => c.config.category === "economy")
const capitalise = category.slice(0, 1).toUpperCase() + category.slice(1)
try {
embed.addField(`${capitalise} [${dir.size}]:`, dir.map(c => `\`${c.config.name}\``).join(" "), true)
} catch(e) {
console.log(e)
}
return message.channel.send(embed)```
if(!message.guild.me.actionType("MEMBER_BAN_ADD")) return('Sorry i dont have permissons!');
is this how to check audit?
if there is no args
@viral iris depends whats ur command handler
@tight plinth wdym ?
your category in this case is always economy because of the previous hard coded statement.
@still badge ist there a view audit log perm?
@viral iris did you made your command handler
yes
i bet VIEW_AUDIT_LOGS is a thing
thats the actual perm
yes
@viral iris in this case you should kno whow it works
i need to view the actual logs
?
and a certain thing in the log
wdym
also having ban perms doesnt give you audit log perms, you need to have audit logs perms
@viral iris in this case you should kno whow it works
@tight plinth idk where
idk how to explain it
are you 100% sure you made your command handler @viral iris
my friend did
make your own
having someone else coding something for you is generally not a good idea unless you know what youre doing
ie. trustworthy and competent
internet escapist
const generaldir = bot.commands.filter(c => c.config.generalcategory === "general")
try {
embed.addField(`🎲 General [${generaldir.size}]:`, `*Attitude's general commands you could use to check out pings, and more.*`, true)
} catch(e) {
console.log(e)
}```
why does it say 0
it should count the number of commands in that specific category
because nothing passed the filter. You could log c.config.generalcategory to see what you're getting.
ok
By the way, since I assume you store the categories in memory such as a property, do you really need to read the ./commands/general directory?
wat u need help wit
Greetings,
I'm looking for some advice on how to send a Message via Bot to a specific Channel (via ID of the channel)
@client.command()
async def send(ctx, channel, *, content):
channel = client.get_channel(id)
await message.channel.send(content)
This is how my code looks right now - but obviously it's not working - Written in Discord Py by the way
get_channel accepts an ID in integer datatype
So the id in the () is useless?
You will need to replace it with an actual ID of a channel your bot has access to
Also, you do channel.send, not message.channel.send
I see - but my intentions are to send it to any channel it has access to
For example I will need to post it either in a suggestion channel or an announcement channel
get_channelaccepts an ID in integer datatype
@slender thistle isn't it a ulong?
or does JS python not specify that
py doesn't have a separate datatype for that
how convenient, ty lol
>>> 128**128
528294531135665246352339784916516606518847326036121522127960709026673902556724859474417255887657187894674394993257128678882347559502685537250538978462939576908386683999005084168731517676426441053024232908211188404148028292751561738838396898767036476489538580897737998336
>>> type(128**128)
<class 'int'>
l0l
For example I will need to post it either in a suggestion channel or an announcement channel
@acoustic bridge oh, user input
one number type to rule them all
You can do channel: int and then channel = client.get_channel(channel)
I'd suggest renaming the function parameter to channel_id to avoid confusion though
I see - I'll try that. And yes I often worked with channel_id
descriptive variable names are good practice
Got confused on some parts. Thanks a lot
boys i just switched servers for my discord bot, and when i uploaded it to top.gg i put a diffrent support server link, how do i update it?>????
>>> 128**128
528294531135665246352339784916516606518847326036121522127960709026673902556724859474417255887657187894674394993257128678882347559502685537250538978462939576908386683999005084168731517676426441053024232908211188404148028292751561738838396898767036476489538580897737998336
>>> type(128**128)
<class 'int'>
@slender thistle damn
I think you can still edit the bot (at least an edit button or something)
lol moment https://modeus.is-inside.me/e1Oq0i1y.png
javascript
u have to make it a bigint
Python handles numbers quite well for the most part
Float precision still being a small issue though
Because C# supports carots
^ happens to be power in C#?
thonk
Ah right
I really like how I can eval C# with my bot
Since there really isn't a quick way to interpret C#
use a lua interpreter 
Nah CSharpScript via Roslyn api is low-key sick af
async def send(ctx, channel, *, content):
channel: int
channel = channel.get_channel(channel_id)
await channel.send(content)
Still not working - although
Nah CSharpScript via Roslyn api is low-key sick af
i don't think there's another way afaik
"NameError: "name 'channel' is not defined"
i don't think there's another way afaik
@modest crane ?
Can you give me an example?
def myFunction(parameters) {}
myFunction(arguments);
I see
CSharpScript is the only way currently implemented to use interpreted code I think
So I guess the parameter channel is the issue
what is , *, is that just a generic object in python?
do I have to change the rest of the channel to channel_id too?
Nah, just the param
and any references within the function to the renamed variable
@faint prism in vanilla Python it's to make an arg only to be used as kwarg
local variable 'channel' referenced before assignment
Means I basically already defined channel somehere?
aka
def test(var, *, yeet):
print(yeet)
# will work
test(2, yeet=5)
# won't work
test(2, 5)```
No, that means the variable doesn't have a value at the time of usage
well, no
Optional param is a param with a default value (arg = 5)
That's just keyword-only argument
in C# we can do:
if (object obj1, object obj2 = null) // Second one has default value and is optionally specified when referenced
Yeah, same in Python
and chaining them is interesting
How come?
void Function(object obj1, object obj2 = null, object obj3 = null)
{
// code
}
Function("", obj3: "")
You can specify the third, and skip the second if you're explicit
assuming the last 2 are optional
Shiv, you gotta let me teach you C# some time
What are some good, free hosts to use?
good and free doesn't exist
i mean
good and for less than 5$ a month yeah that's possible
i used heroku
that was ok
any thing that works
and is easy to naviagter
is good for me
heroku isnt a good host. nor is it intended to be used for bots
make a map instead so that you can set a value
const talkedRecently = new Map();
// bunch of other code
talkedRecently.set(message.author.id, Date.now())
and then when you check for message.author.id in talkedRecently you can check if it's been 10 seconds or whatever
ok so you would do like
message.reply('You have to wait 10 seconds!')
return
}
sorry about the bad indenting
but anyway that would check if it has been 10 seconds, and if it hasnt, it returns the message
k
you're forgetting a bracket
oh also other way around
Date.now() - talkedRecently.get(message.author.id) >= 1000
ok here is what mine looks like that works
message.channel.send("This command has a 10 second cooldown!")
return;
}
message.delete()
talkedRecently.set(message.author.id, Date.now())
}```
did you make it a map
talkedRecently = new Map()
talkedRecently = new Set()
needs to be
talkedRecently = new Map()
np
also @earnest phoenix i see in your error message that you have Date.now() - talkedRecently.get(message.author.id) <= 10
the Date.now() function gives you the time in milliseconds, so you need to make that 10000, not 10
ok 👍
let randomvalue = test[Math.floor(Math.random() *test.length)], you can thank me later.
y do people use let when u aint reassigning it to smthing, use const
What does it matter tbh
it defies the point of const
linter would be pissed
i find it annnoying
const = single thing u dont reassign
let = movey thing that changes
var = ???
Python looks much cleaner though, agreed? @slender thistle
import random
list = ['shvaco', 'is', 'a', 'weeb']
print(random.choice(list))

who is shvaco

