#development
1 messages · Page 1740 of 1
i doubt discord's response time to process a request in that endpoint would change much at all in that
the same answer as to can you change the time you were born
Hmm I need the time in asia/calcutta
how do i make the text start at the left?
i mean idk how to explain it too well
but baically i want the icon on the left
the text at top right
How can I
and the value in bottom right
text-align: left?
doesnt work
get the timezone of asia/calcutta, get your original timestamp in unix, then just convert it
ah
flexbox, the answer to everything is flexbox
shhh move on with your magical modern stuff
Witch!
.addField("Created At", guild.createdAt)
or use something like moment or some other time manipulation package to do the convertsion for you
make a variable, convert it, put the variable there in the adField, thats it
all timestamps you get from discord are unix, inheritely that means they're in UTC
aka
+0000

if you have no idea what i said you need to learn the basics of JS
and how functions work
so you can manipulate the date to get it in a specific timezone by just adding/removing hours and minutes
Ok
there's also minute corrections but rare
hmmm thats interesting, was unaware of that
iirc there's quarters and halves
yeah they exist
might wanna use a package to deal with that then so you dont have to worry about the specifics @lavish bramble
i fucking hate when you mention someone and the mention goes in the middle of the text
i almost failed geography that is the only thing that i remember from that class
discord
fixing
lol
isn't the right answer _stack overflow _
that's a very good point
the right answer to everything is learning first

or the right answer, thats also the right answer

100% looks like an error caused by the user - yes YOU!
the answer is below
the answer is above
nono, this would be labeled as we dont care, only major bugs need fixing
ihy what
it's your fault, accept it and everything is fine
yarrak
that message disappeared with the speed of light
a smart person would conclude that the answer is actually "above" and exit the function :smart:
im going to buy nitro just so i can use that emoji
nevermind my money is on pp and discord on android forces me to go through google pay
buying fortnite skins
don't force me to ask what fortnite is
tell that to the 1 mill nitro users
no I'm not that old... calm
I've got no words for them...
that took a while just for that "one" element lol
wdym?
make the icons a little bit larger
at least the first two
well just increase the size on hover only, looks a little more special
yea
brighter
.server_stats_items:hover .server_stats_items { is this correct?
shi
1 sec
it works
how do we know the elements and their names, lmao
making it bigger
wtf
it affects the entire box
.server_stats_items .server_stats_items
why is server_stats_items element being there 2x?
TYPO
The first time i call await msg.guild.members.fetch({user: allPlayerIds}); i get a Collection, but the second time this same code returns an array.
i am invoking the same bot command twice
i am using discord.js-light
is this a bug or expected behavior?
might be a bug
why does it go under?
i have the z-index of the dropdown set to like 9999999999999999
copy - pasted from #general
you can use "size" in collection ? [...collection.values()] : collection to make sure it's an array
lower = on top?
nope
versa
higher = on top
Does your menu actually have a lower z-index assigned?
thanks, i'm going to do this, but turn the array back into a collection
ah, use data instanceof Collection ? data : new Collection(data.map(member => [member.id, member]));
thanks
u got it?
.addField('Member Count', `Total Members :- ${message.guild.memberCount}\nUsers :- ${members.filter(m => !m.user.bot).size}\nBots :- ${members.filter(m => m.user.bot).size}`)
Its showing 1 bot and 1 user
But my guild have 3 bots
there's a dropdown limit
u just have to turn the other thing down
async findOne(get, table, isQuery, message: Message){
let a = await this.db.query('SELECT '+ get + ' FROM '+ table + ' WHERE guildId = '+ message.guild.id +' ', async (err, rows) => {
return rows
})
console.log(a)
}
It's returning the query and not the rows, how can i make it return rows outside the function
Assign it to a variable as its called with a callback
async fn(...) {
let a;
await this.db.query(..., (_, rows) => {
a = rows;
});
return a;
}```
okay ty
It always return undefined
Heya!
Have you tried logging what the rows returns in the callback?
What's good approach, iterating through a list or making request to the mongodb database everytime a person sends the message
In on_message() function
I use python which is apparently not good with speed
Depends on how many documents there are, if not too many, lists are good, if there are too many documents however, making a request to the database is the better approach since it can retrieve the document faster than iterating through a list
It's returning
[ RowDataPacket { language: 'fr-FR' } ]
Yeah that's what I thought but then again few said we should optimise the requests to database and use lower bandwidth
And all
Most of the times the request I send to db returns none as it doesn't match the criteria or filter I pass, can this be considered as optimization of bandwidth
fn(...) {
return new Promise(async res => {
await this.db.query(..., (_, rows) => res(rows));
});
}```
yea, the optimization of the database requests should be considered but if shouldn't be that big of a problem tbh
Oh oke
Since I just started using a server based db I was kinda worried about requests I make and all thanks for answering
The smarter thing to do is to batch queries together if possible. The volume of packets at scale can overwhelm a database
batching inserts for example
Went over my head
Thanks, it work fine
Or fetching the info
Oh. Then not much you can do there
At first I thought I'll just get all the info at once in initialization
And loop through it
Which will decrease the requests to db drastically
how large is the data set and how often do you expect to make requests
Dataset can be varied as over time
I make request everytime someone send message on Discord
If it's stuff like prefix data or the language of the user, it's safe to just request that data each time
it's also more convenient to not worry about desyncs at scale to request the latest data
considering shards can be on different clusters
Oh oke thanks mate
message.guild.fetchBans()
.then(banned => {
let list = banned.map(user => user.tag).join('\n');
// Make sure if the list is too long to fit in one message, you cut it off appropriately.
if (list.length >= 1950) list = `${list.slice(0, 1948)}...`;
const embed = new MessageEmbed()
.setTitle("Ban List")
.setColor("RANDOM")
.setDescription(`Total Bans :- ${banned.size}\nUsers :- ${list}` || "None")
.setTimestamp()
message.channel.send(embed)
})
.catch(console.error);
Its not showing the users tags
fetchBans returns a Collection<string, { reason?: string; user: User; }>;
need to map(entry => entry.user.tag)
does anyone have a recommendation on the place to host a discord bot at exept Glitch Heroku and github?
Okay but GitHub hosting?
whats that?
Idk bro, I was asking you that
AWS, Google
😐
raspi do wonder too
Imagine hosting bot on github
hey I host mine on GitHub 
How can you add commands with a command in 14.4.0?
Yes
Unless you're using a framework with that capability, you'll need to store, parse, and process the subcommand yourself.
Though I'm confused.
Discord.js has no 14.4.0 version
That my node version
Alright, but that's not your Discord.js version.
My discord version is 12.5.1
i have a question for people that use python
ask away
is it possible to a discord-rpc on a discord bot (python)
@lucid prawn in that case,
Unless you're using a framework with that capability, you'll need to store, parse, and process the subcommand yourself.
If you'd like to implement it yourself, you'll need to parse the message as <prefix><command> <subcommand> [...arg].
You'll need to see if a subcommand argument was supplied. If there was one supplied, look through your subcommands collection (aka where you store subcommands, such as directly to a command) and see if a match was found. If so, run a function specialized for the subcommand. Else, run the command that was associated with the invalid subcommand (including the subcommand argument since it's just an argument now). But that's up to you to decide how to implement it.
oh ok
i was only asking bc i have a discord rpc that adds button to my profile and i was wondering if i can do that to a bot
I was answering Mika's question. I don't have experience with RPC myself.
ohhhh
RPC, on a bot?
yes
I don't think that works.
i found a discord-rpc on pypibut i dont know about it
you think you can send me the link?
Bots are just allowed LISTENING, WATCHING, STREAMING .
Thxs
whoops its pypi
And Playing
those rpcs are for user accounts.
that's the default.
Mika in here...
Hi Mika
Anyways.... So I hear it's possible to do any coding with a phone. I got my bot online but it goes offline if not used for a long time. Which is concerning so.... The commands for moderation should work as well for the bot without a computer?
I use the uptimerobot website to keep it online
So it works without a computer like this yes?
I guess it should.
is this ok to do this in react?
speacially at line 136.... update other state in some state
Hi
any errors?
nope, but its behaving weirdly.
randomly both of the state is changing
sometimes A and somtimes B
and you want one state to change to the other state
I just want to update the state of isAllSelected to be true, when all the elements of selectedUsers have truthy value
when id is undefined, I'm just toggling the isAllSelected
Since your fetching data and then changing a state https://www.pluralsight.com/guides/fetching-data-updating-state-react-class maybe read this, could help.
Pluralsight Guides
but im not using class components
what?
Hello, Im new to bot developing and stuff, I made a bot using Repl.it, But It's impossible to make it online forever, I don't know how to do it. Help please.
replit too
u need to host the bot to some where
google how to host a bot repl.it
to start the bot
use this code
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(Logged in as ${client.user.tag}!);
});
client.on('message', msg => {
if (msg.content === 'ping') {
msg.reply('Pong!');
}
});
client.login('your-token');
Every returns boolean
not the array
do [...array] or arrwy.slice() to clone it
ik, that's why isAllSelected is a boolean
Oh nvm I miaread the function name
or all the users have been selected
Looks fine to me, how are you calling it
what I dont understand is, Is it good to update two states at a time?
Yeah as long as the first state won't change again if you update the second one
Im just calling the funciton selectUser(false, <id>), if id is undefined, I want to toggle all the users
and is it possible to update a state, and not rerender the component
mmm why are you using an array to store the selected users, this may not be the problem, but you should use a Record for thay
Nope, if you want that consider using a Ref
which stays persistent over state changes
but doesn't change the state when updated
yes, i also realised that id's can also be strings thats y, i did this.
hv u used immer
You need to return a new object in the update functions
Updating the current one will almost always cause bugs
in immer, we can directly mutate the state. And now its works fine
return { ...draft} trust me, React relies on immutability
If you were to use a useEffect hook on it it wouldn't work
I've been there
returns are not required, see this doc
https://github.com/immerjs/use-immer#readme
That's not a function though...
The first one
Are you using immerjs? I don't know then
Maybe it's doing it under the hood cause in React you have to return a new object
I asked u, at first place 😅
I didn't see that oop
lol, np
Yeh that's exactly what immer's doing
ummm I have a request to the reviewers... Um I edit my bot sometimes so while I do it won't work as you know xd and I don't have a particular time when I code, I code it whenever I remember that I should add this or that or edit this or that um nvm....... If you may dm me before testing my bot named yoink I would be grateful
You should submit a working version of your bot and develop it with another account
So have 2 bot accounts
one for development and one for the public
umm honestly I mistake a lot when I do that... I tried it once and the bot had to be deleted :\ ewe
a beta bot and a main/public bot
test your features in the beta bot
and push them if you like it
for css, I've a div set to overflow: hidden, but I want one of its child to let be overflowed. How can I achieve that?
the child is actually a dropdown menu
so it dont look like this
function Test() {
let counter = 0
const [name, setName] = useState("John")
const updateCounter = () => {
counter++
setName((str) => str + counter)
}
return (
<div className=''>
<span>{name}</span>
<span>{counter}</span>
<button onClick={updateCounter}>click me</button>
</div>
)
}
You've said, when the state changes, the component get rerenders
then the counter should get updated as well
Can you tell me, y this doesn't work?
In this case, as the counter increases it gets appended to the name.
counter is bound to the state, once the state changes, counter gets reset to 0
Use Refs for that kinda stuff
Ooh... I got it. Silly me
Hello
We applied for verification
For bot
And it says suspicious growth
But it is own growth no fake servers
And one of staff said
You want to make it 280 servers
If any one add it in fake servers
Will it verify
Anyone know a bot that can give a role to people who have something in there custom status? Like if someone puts my discord server url in they status they get a role automatically but once its taken out the role is gone
not that i know of
there is an event on client called presenceUpdate, u might want to look at it
Oh im looking for a bot thats already created
This is not discord.
@earnest phoenix join discord developers server and ask here
Do have link or any idea
imagine getting older
dose any one know how to make my bot when it is mentioned reply with its prefix
@earnest phoenix use regular expression
?
Regex
if you're using discord.js just use message.mentions
ohhh
sad
Tim, do you use galaxygate?
do i put in my index.js#
yes
I assume you prefer it over DO and AWS etc then?
Lol, that’s what I was thinking as well
show code
Is it recursively calling?
how can i have 1 cases in one switch but with 2 strings?
its bad but it kinda works
It’s recursively calling
it doesnt work lol, thats why its spamming
dammm
Why are you using on message tho
ok im not the best
message.mentions.bot doesnt exist
and youre sending a message in both if cases, so it will always send
switch (aww) {
case "no" || "maybe":
}
```why does this dont work
how can i do it like that?
case "no": case "maybe":
switch(aww) {
case 'no':
case 'maybe':
//some code
}
tnaks
np
the bot answers to itself, this is why it spams
oohh
hey
how do i save the data i receive from the request.get and assign it to a variable? (the response.body)
var request = require('request');
var options = {
'method': 'GET',
'url': 'URLGOESHERE',
'headers': {
'Authorization': 'AUTHGOESHERE'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});```
dude
seriously
use node-fetch
you got told 3 times request is deprecated
4 times now
hi
node-fetch has proper async support
i'm trying to connect heroku to mongoDB atlas
the thing is, i don't know how to authorize using node-fetch
but i couldn't find the ip to whitelist
just... add the header? the readme has examples on how to use headers
i searched and they say whitelist 0.0.0/0
which is kinda wrong since anyone can connect to it
ask the support of your host.
no it wouldn't because node-fetch uses promises
at that point it's just async/await or then pattern
you could've used that with request too, like tim and i told you
but drop request, it's deprecated and full of vulnerabilities
i literally did that
ok
you have a tendency to lie in this chat so i dont believe a single thing you say lol
Hello
Hello
@livid jackal is that u outside my window
In discord.py
em.add_field(name=f'Boosters [{len(guild.premium_subscribers)}]', value=str(guild.premium_subscribers))
this is giving response as <Member id=500305380014948362 name='Asuka' discriminator='7580' bot=False nick=None guild=<Guild id=787709538160869406 name='Asuka Bae' shard_id=None chunked=True member_count=1387>>]
I tried for half an horn using loops n all, but cat fighure out how to solve this
Well, you're stringifying a list, what do you expect?
For the list to somehow join properly, like how magic stuff happen in Python
how to use Vps ?
that's like asking how to use a car

you need to provide more detail on what you specifically want to do and what os your vps is running
Like you use a pc
uh how do you check for like 2 permissions like has permissions _____ or has permissions ______
which library do you use?
np
if you use d.py
then
if message.author.guild_permissions.administrator or message.author.guild_permissions.manage_guild:
do_sth()
or you can change the permissions
how some bots like koya make a welcome pic with the user name and profile pic and upload it as a welcome message?
The bot will "draw" the image (like with a canvas builder) then send it as a file.
"draw" is in quotations since there are many ways to create an image.
how to make this? with discord.js?
If you want to make clickable links, you want to use Markdown syntax.
[text to display](url goes here)
For example, [Google](https://google.com/)
It'll only work in embeds, but if you're using Webhooks, it'll work in plain text too.
kk ty
they use canvas
Config.json
{
"prefix": "+",
"token": "My_token",
}
My index.js
const fs = require('fs');
const Discord = require('discord.js');
const client = new Discord.Client();
const config = require('./config.json');
client.config = config;
const { GiveawaysManager } = require('discord-giveaways');
client.giveawaysManager = new GiveawaysManager(client, {
storage: "./giveaways.json",
updateCountdownEvery: 5000,
default: {
botsCanWin: false,
embedColor: "#FF0000",
reaction: "🎉"
}
});
client.giveawaysManager.on("giveawayReactionAdded", (giveaway, member, reaction) => {
console.log(`${member.user.tag} entered giveaway #${giveaway.messageID} (${reaction.emoji.name})`);
});
client.giveawaysManager.on("giveawayReactionRemoved", (giveaway, member, reaction) => {
console.log(`${member.user.tag} unreact to giveaway #${giveaway.messageID} (${reaction.emoji.name})`);
});
client.giveawaysManager.on("giveawayEnded", (giveaway, winners) => {
console.log(`Giveaway #${giveaway.messageID} ended! Winners: ${winners.map((member) => member.user.username).join(', ')}`);
});
fs.readdir("./events/", (_err, files) => {
files.forEach((file) => {
if (!file.endsWith(".js")) return;
const event = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, event.bind(null, client));
delete require.cache[require.resolve(`./events/${file}`)];
});
});
client.commands = new Discord.Collection();
fs.readdir("./commands/", (_err, files) => {
files.forEach((file) => {
if (!file.endsWith(".js")) return;
let props = require(`./commands/${file}`);
let commandName = file.split(".")[0];
client.commands.set(commandName, props);
});
});
client.login(config.token);
can someone help me make change prefix command?
for prefix i use ${this.client.prefix} to show prefix
you need a database
Anyone know a good npm package that can encode and decode strings of text?
i have database.json
encode to what?
For passwords and emails
jwt i guess?
inb4 str([1,2,3]) == "1, 2, 3"
I use bcrypt
Help
With what?
This
i have some problem, every gw i did with bot it save in database,json and my memori getting full
how to fix that?
Don't use JSON as a database.
An actual database
Doesn't matter. You can use sqlite or mongo or postgres or whatever. Just don't use JSON, it is NOT a database.
If they can use JSON they can use sqlite though and that's the easiest one.
but i have everything setup yet just i dont know why every giveaway i made save in database
can i make something like when gw finish to gw from databe delete
something like that
You setup something that's bad. And now it broke. So now you get to fix your mistake.
You are using a method that will break in many ways.
We will not help you load another shell in the shotgun you have aimed at your foot at the moment. You need to actually stop using JSON right now, it will only keep bringing you pain.
No help
then what to do, i only know for that
Get the better-sqlite3 module, and use https://www.sqlitetutorial.net/ to learn sqlite
If you think that's too hard because you're too lazy to actually learn things right, then go use one of the followign:
- nedb
- quick.db
- enmap
@joshdb/core
you mean this?
idk dont ask
json.sqlite.txt.data.pdf.csv
.txt
lol
now just to ask everywhere where is database.json i need to change that in giveaway.sqlite?
i just leave my local db files nameless, just the extension is there
in code
Lol
code.js.ts.c.cs.py.java
No you need to rewrite the code too
json.sqlite.txt.ini.env.pdf.csv.docx.xslx
so that it actually uses a database module
i mean to change this
yeah you can't just do that
again
you need to actually write code to properly access the database
I don't think that package has inbuilt sqlite support
I don't... what? A package???
use an orm like sequelize lol

I use MongoDB
im just kidding
I keep getting error
enmap is bae 
Mind checking your confug.json
You clearly have a syntax error in your config.json , so fix that
says the person who made it
😂
Obviously my opinion is highly biased.
How my config.json is this
{
"prefix": "+",
"token"my_token",
}
but hey millions of downloads agree with me
enmap bad
,
,
no trailing comma at the end
JSON is very strict, you can't add that last comma there
Remove the comma after my token
Oh
and the missing colon
Yeah
and the syntax in general
Though starting from the outside and slowly entering the inside is more efficient than starting from the inside: http://mariechatfield.com/tutorials/explanations/json.html
Tutorials and explanations by Marie Chatfield. Follow along with workshops, or proceed at your own pace.
raise HTTPException(r, data)
discord.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward.```
I'm getting this error when attempting to run the bot 
You sent too many requests to Discord and got temporarily blocked.
Though I don't know how you did it.
The bot is in only 13 servers... how on earth could it be reaching a limit 
Yeah happens to me time to time
How do you get to 429 with logins
You have two options either change the ip address or wait until it is removed
Like assign a new ip
IP address won't change anything
Or wait
I don't know how you'd be able to hit the 10,000 rate limit. Maybe it's something internal.
IP addresses that make too many invalid HTTP requests are automatically and temporarily restricted from accessing the Discord API. Currently, this limit is 10,000 per 10 minutes. An invalid request is one that results in 401, 403, or 429 statuses.
The ban is per-token
It does
I highly doubt Discord relies on IP addresses
The last time I got 429 on my Bot from discord was 3 days ago
I just assigned a new ip to the project from gcp
And restart
Bot online
Was there any breaking changes on mongoose v.5.10 to v.5.12?
If they're following semantic versioning, no.
Imagine following semver
semver sucks but we need it
whats 'semantic versioning'?
It's a way of versioning releases based on how it affects source code.
It is currently on a replit.com. Would that be causing it?
Maybe.
Tbf I don't mind following it. I just have an issue really understanding when I should increment minor or micro
See this
Oh, interesting
thats officially form replit?
Yeah, so Discord must go off IP for that then?
Probably
Curious why they decided to go with IPs instead of tokens
I got rate limits because I don't have any cooldown in my Bot and people literally spam the commands like crazy
That's from the discord.py Discord Server when you run ?tag repl
lol, but Replit is whitelisted from Discord, they just give token ban, no ip bans
Same. Literally no cooldowns 
Lol
The bot just joined a new guild, and then i hit the ratelimt. Any way to do guild reverse lookups?
How even
Djs ratelimit handling might be good but when my Bot stars spamming to the gateway it is more than 1k in few seconds like super fast even harder to debug
thats the ban case
Major = anything that may break a person relying on the code (e.g. changing a public function name and not adding a replacement).
Minor = A new feature (e.g. new public function) that won't break others' code.
Patch = A bug fix that doesn't break others' code.
What I don't like about semver is that a lot of changes can be major, and I also don't like how it makes it easy to climb up the major number (e.g. 24.3.2). Maybe if it were like edition.major.minor.patch where edition is a "big" release for the library.
djs doesn't have good ratelimit handling at all
instead of queuing your request, half the time it errors out
What does it mean?
You provided invalid intents.
You need to specify intents which exist
How do I do that?
@frigid mountain see https://discordjs.guide/popular-topics/intents.html#gateway-intents
imo minor could be used for both breaking changes and new features, while major is for really significant changes (like, say, complete rewrite of one system, if not the package entirely)
yeah but semver doesn't like that
🎵 Let's break the rules~ 🎵
But you agree or not djs is switching NodeJS versions like crazy
Nope
anybody knows goed node js hosting ( i want to host dashboard and bot )
Though at least in my case I don't do very weird shit to climb up to v10
... yet?
there's like no reason to not use the newest node version anyway
# set prefix on guild join
@client.event
async def on_guild_join(guild):
with open('prefixes.json', 'r') as f:
prefixes = json.load(f)
prefixes[str(guild.id)] = "."
with open('prefixes.json', 'w') as f:
json.dump(prefixes, f, indent=4)
#remove prefix on guild remove
@client.event
async def on_guild_remove(guild):
with open('prefixes.json', 'r') as f:
prefixes = json.load(f)
prefixes.pop(str(guild.id))
with open('prefixes.json', 'w') as f:
json.dump(prefixes, f, indent=4)
#change prefix via command in guild
@client.command()
@commands.has_permissions(administrator=True)
async def changeprefix(ctx, prefix):
with open('prefixes.json', 'r') as f:
prefixes = json.load(f)
prefixes[str(ctx.guild.id)] = prefix
with open('prefixes.json', 'w') as f:
json.dump(prefixes, f, indent=4)
await ctx.send(f'Prefix changed to : {prefix}')
Anyway I should change this? or a better way to do it?
My bot is joining guilds at times and it's not always updating prefixes.json, which breaks the bot for them essentially, no prefix, no commands.
stop using json as your db
Oh dear
So the json is simply breaking it?
Json is not a db
Apache Cassandra 😂
Hello, my dashboard api doesnt want to work: https://tickety.top/ is the dashboard and https://tickety.top/api the api but it gives an ubuntu gateway error! on the direct ip the api works
The perfect and most customizable ticket bot for your server! Manage tickets easier than ever!
it might be the underlying cause, you're probably overwriting the existing data because files don't support concurrent or parallel operations at kalypso
Alright, thanks
I'll look into switching over to sqlite
My bot is joining guilds at times and it's not always updating prefixes.json, which breaks the bot for them essentially, no prefix, no commands.
If there's no entry in your "database", you should implicitly default to a prefix (e.g..).
your privacy link does not work 
privacy ?
do not repost lol
I recommend you only add an entry if the user sets one rather than setting one for the users.
As a bot owner its a compulsory to have one, else your bot can be unverified
no credentials are stored
So it would check if a prefix has been set and if not, then use the default?
no because if i had a no dashboard it will be the same
You're required to have a privacy policy (even if you don't store data), but that's not your question.
indeed
thats a reason enough, you are saving messages
sure i will make one when my fk api works
Yes.
can you help me
finding out whats wrong
Also can you help me creating a privacy
What do i need to supply
In it
you just told your api is not working, no error stack, no code, no information
how can we help?
becuase i dont have any information
now errors
we do not have magic balls
no consoel errors
it is a question like
you can fix it by enabling this in your ubuntu settings
I don't have enough experience building a web server, but the meaning of the error is as so:
The HyperText Transfer Protocol (HTTP) 502 Bad Gateway server error response code indicates that the server, while acting as a gateway or proxy, received an invalid response from the upstream server. (https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502)
I noticed if I visit /api and get 502 then quickly switch to any other URL, I get the same error page. A few seconds after, it returns an average 404 on any other page (go back to /api and get 502).
Alright, so what would that look like exactly?
def get_prefix(client, message):
with open('prefixes.json', 'r') as f:
prefixes = json.load(f)
return prefixes[str(message.guild.id)]
client = commands.Bot(command_prefix=get_prefix)
This is what I currently have.
Instead of prefixes[...], use prefixes.get(...) and default to . if not found (.get(...) returns None).
But of course, as others have said, you should use a proper database for this purpose.
I'm only answering this question to tell you about defaulting rather than populating.
Correct, this is just a temporary patch while I learn more about db
def get_prefix(client, message):
with open('prefixes.json', 'r') as f:
prefixes = json.load(f)
return prefixes.get(str(message.guild.id), ".")
client = commands.Bot(command_prefix=get_prefix)
That look right?
looks correct. try it out and see
Okay so, i want to make a count system with an array, i mean i want something like
[1] - 1
[3] - 2
[5] - 3
[10] - 4
[20] - 5
so, 1, 3,5 for the first three digit, then it add 10 to the rest, but didn't how to do that
let count = 0;
for(var i of array) {
count += 10
console.log(`[${count}] - ${i}`)
}
[10] - 1
[20] - 2
[30] - 3
[40] - 4
[50] - 5
Well... I am still ratelimited. 
How long does the rate limit usually last? For a 429 Too Many Requests?
You could use a loop and check the index of the number. If the number is 2 or lower (1 - 3), you multiply the index by itself and add one. If it's after that number, you minus by the appropriate starting number and go forward.
Another way of doing this (which I recommend) is to explicitly log 1, 3, and 5, then to create a loop for the rest.
My answer was not to solve your rate limit. It was to solved a part of your data problem.
do client.on('debug')
Correct, this was a separate question. So between an hour - 24hrs, alright... I will find out soon™️
why does fetch invites require 2fa
Probs because it's considered a moderation action with data that should be private as much as possible
I wrote a little demo to go along with my explanation (which is a bit different from before).
for (let i = 1; i < 6; i++) {
if (i < 4) {
console.log(i + i - 1);
} else {
console.log((i - 3) * 10);
}
}
tysm
In discord.py i made this command to show all the boosters of the server
async def boosters(ctx):
guild = ctx.guild
em = discord.Embed(title='Lovely people who have Boosted this server...', color=0xFF3933)
em.add_field(name=f'Boosters [{len(guild.premium_subscribers)}]', value=guild.premium_subscribers)
await ctx.send(embed=em)``` but it responds as ```<Member id=500305380014948362 name='Asuka' discriminator='7580' bot=False nick=None guild=<Guild id=787709538160869406 name='Asuka Bae' shard_id=None chunked=True member_count=1387>>]``` and i want it as ``` Asuka#7580```
i tried many things, but cant figure it out, what to do
use list comprehensions and pass the member to str()
ohh let me try
it does not work still the same 😩
Boosters [2]
[<Member id=493267802883358731 name='Kashyap Patel' discriminator='3304' bot=False nick=None guild=<Guild id=787709538160869406 name='Asuka Bae' shard_id=None chunked=True member_count=1385>>, <Member id=500305380014948362 name='Asuka' discriminator='7580' bot=False nick=None guild=<Guild id=787709538160869406 name='Asuka Bae' shard_id=None chunked=True member_count=1385>>]```
Show what you did
async def boosters(ctx):
guild = ctx.guild
em = discord.Embed(title='Lovely people who have Boosted this server...', color=0xFF3933)
em.add_field(name=f'Boosters [{len(guild.premium_subscribers)}]', value=str().join(guild.premium_subscribers))
await ctx.send(embed=em)```
code
Do you understand what str.join does
It's basic list stuff
so if u can spoonfeed me pwetty pwease 🥺 👉 👈
😂
str.join is a method of a string, and what it does is join passed element's with the string on which the method is used
😂😂😂
My dumb ass keeps forgetting it must be a string
There we go
I'll remember it might be helpful if I learn it someday
the provided iterable must be of type Iterable[str], meaning it's full of strings
Strictly typed languages
Hmm
>>> class MyClass:
... ...
...
>>> [1, 'really', MyClass, MyClass()]
[1, 'really', <class '__main__.MyClass'>, <__main__.MyClass object at 0x000001C2B80C0F70>]
But I'll probably learn kotlin rather than choosing python
That's fine
learn it all bb
Because I have to rewrite my Bot someday in kotlin
you have to?
Yep
Hey guys. I'm using discord.js and I'm seeing that the guild owner is null. How is that possible? Every guild has an owner right? In the documentation is also says its nullable but I don't get why.
Am I missing some kind of permission or something?
If it's null just fetch it
<Guild>.owner is not guaranteed to be cached
How do I fetch it
Guild#ownerID is the id of the owner
await <Guild>.members.fetch(id)
or users ^
Why do you have to know, who the owner of the server is 
@slender thistle well i did this value=' '.join[str(e) for e in [guild.premium_subscribers]]) its showing invalid syntax, then i tried value=''.join[str(guild.premium_subscribers)]) and its showing TypeError: 'builtin_function_or_method' object is not subscriptable
ohh
does djs supports slash commands yet?
the master branch does
npm install discordjs/discord.js
does, npm install discord.js wont work?
nope thats the stable, public branch
and there are breaking changes, just to warn you..
so it'll be in stable at v13, right?
When it's released, probably
If you want to use it early, I you can experiment on the master/main branch.
I once read the on the site, that they'll also support clickable buttons on embeds, anytime soon
when you moved your files over to the vps, did you copy the node_modules folder?
you shouldn't do that as it can cause issues.
what's your node version
v.8.10
why are you using such an ancient version
use the latest
the error is probably coming from djs which uses optional catch binding
hi
Bot Quarantined
Your bot has been flagged by our anti-spam system for abusive behavior. While your bot is quarantined, it is unable to join any more guilds, or send any direct messages to users it has not messaged before. If you believe this to be in error, click here and select "Appeal an Action Trust and Safety took on my bot" as the Report Type to submit an appeal.
i got this above my bot
it was a bot ordered by someone and it sends dms to users whenever they join a server
it also has a point system which lets them add a certain number of users to their servers using oauth guilds.join
does anyone know what this means
I mean it's pretty clear isn't it?
it was a bot ordered by someone and it sends dms to users whenever they join a server
read what it says again
anyone know how to handle background task that takes too long time?
it's sending too many DMs clearly
i am using discord.py rewrite
https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html && https://github.com/Rapptz/discord.py/blob/master/examples/background_task.py
i tried this but as the task takes about 2-3 min in total to complete and after complition of the task bot goes offline without any error even the code is still running
Sync database wrapper moment
but it only sends 1 per user
that wouldnt be considered spam would it
mee6 does the same thing
it would be if there's 10,000 users.
and many other bots
there arent that many
I can't speak for other bots. But you're not mee6 or dyno
What does your welcome message look like?
its a custom message for each server
one sec ill have to check my db
Hey, you could win Nitro for FREE
Join these servers to WIN
and GROW your server FAST!
<inv link 1>
<inv link 2>
this is the msg
Because it's literally advertising
hmm
but ive seen those kinda msgs on mee6 too
why is it allowed for them tho
its yagdb or whatever
not mee6
lol
I don't know
if you want more details, or if you want to argue the decision, you know what to do.
Pretty sure it’s against ToS to send advertisement DMs like that
loads of bots do it th
o
damn
mine has the same command which mee6 has
that is to set a custom welcome msg
does anyone here have the link to the discord devs server
kk
mee6 can send welcome message DMs, but I don’t think it’s intended for the purpose of advertisement
well mine is the same thing
I wouldn’t risk anything
I haven’t seen any bots DM advertise links by default, unless it’s a custom message set by the server admins
Hi, a few days ago my bot started using shards, the problem now I have a lot of problems with counting for users or servers, is there a way to merge all members / servers of a shard into one count?
To see the servers count I use
$ {client.guilds.cache.size}
Below I leave 2 photos of the server count from 2 different shards
Lang: Javascript
https://cdn.discordapp.com/attachments/622379620674830346/840976774036324392/unknown.png
https://cdn.discordapp.com/attachments/622379620674830346/840976826213203979/unknown.png
in react I want to store <a></a> or <button></button> based on a condition in variable, so that later I could render it. How do I achieve that?
similiar to as='div' prop in some packages
It's much easier to just have a condition showing either/or with { if } blocks
but it'll get bulkier, If I later choose to add div or span too
That's how you write React components, better get used to it 😄
You can also do dynamic classes instead, on divs or spans, in certain cases
there's no universal rule here and you shouldn't try to find one
semantic > dynamic
I just want have a as prop on the component, which will accept any string element, which I want to render with
So make a component that does that and returns the appropriate thing then
like this
yes
that's a prop
that returns conditionally, probably
This is not a thing that's common
react has a function called React.createElement(), will it help?
it accepts a string, to render with
Please Explain Me How To Write Embeds
You can do that. But you should avoid it unless it's absolutely necessary
For example if you want a <link> or <button> depending on a condition it's much better to use an inline condition
that is not a embed. That's a block message.
^^^
if it's between like 2-3 different elements, write conditions instead of dynamic things
Alright
ok. thanks
u can write block message, by encapsulating ur message with 3 backticks on each side
This[✓✓✓]?
backtick is present on ur keyboard left to the key 1
```
thing here
```
` `
That’s 1
XY
3 for code blocks
that's single backtick used
at the beginning and the end
Code stuff
XY
magic
I want this as the result
what?
?
```Code stuff```
^^
You can also enable syntax highlighting
[```Code_Stuff]
```language
Code
```
Code_Stuff
There's a ghost inside me
It all belongs to the other side
We live, we love, we lie```
Still🥺
Still what?
I used ```
What’s the problem
Yes and you got a code block. What's the issue with it?
That means you used 1 or 2 backticks
Whut
I’m on mobile I can’t tell the difference between the two haha
TEXT INLINE CODE BLOCK TEXT
TEXT
NOT INLINE CODE BLOCK
TEXT
it's not hard to understand
Yes It's Not Difficult To Do Too
Yeah, not sure why your discord is displaying it differently
If so what's your issue?
How to loop through all the roles in a server?
the nicb is the best one
u do hv block
Maybe There's A Issue In My Settings
I see it as I’m supposed to
My Developer Mod Is On
?
that should be not an issue.
DV Mode Has Any Connection With These Blocks?
...roles.cache ?
Try looking it up, usually discord js questions are pretty common to find answers to
Thanks!
Btw Thanks For Teaching Me
<Guild>.roles.cache
I'll Try To Fix The Problem
Returns the IDs, I want the names..
I'm caching all the roles, but trying to return a collection not IDs but names.
Just like Dyno.
I wrote the ` intentionally to let you understand what to do. It's not an issue Discord isn't displaying a code block.
`No code block`
API v9 includes supports for threads, an upcoming feature. Older API versions will not receive any Gateway Events for threads, so it is important to update soon!
What does this mean? How can i update my bot to the new API?
Is this for the Discord API?
No, I did try this. message.guild.roles.forEach(role => console.log(role.name, role.id)), didn't work.
CACHE
Cache
lmao
message.guild.roles.cache.forEach(role => console.log(role.name, role.id))
now it'll work
^^
what djs version u using?
undefined
it should be
Yeah
What can I use instead, map?
message.guild.roles.cache.map(role => console.log(role.name, role.id))
guild.roles.cache will return a collection.
You can also convert it into an array.
guild.roles.cache.array()
Uh.
get the length guild.roles.cache.size and loop to it
so it doesn't have forEach u can use each instead
Returns the IDs
Well if they aren't cached then fetch them.
And did it work
Yeah, that's correct
Collection(9) [Map] {
'737011108954505267' => [Role],
'751138549432189030' => [Role],
'751676936283226124' => [Role],
'776710533130223626' => [Role],
'776710562821570560' => [Role],
'782644949698871298' => [Role],
'806548255013994546' => [Role],
'807824111840657472' => [Role],
'815657508600545311' => [Role]
}
if you want to convert it to an array, use map instead
each gives u a Collection back
That's why I mentioned to create an array message.guild.roles.cache.array() and loop through it.
You usually don't need to convert a collection to an array
Maybe 1 line more code
Depends on how you need it
also collection.map
Oh, forEach is a Maps method. That's y they didnt documented it
so it does exist, but it returns nothing
as well as an array method
i have a simple question
one which i get confused at
alot
totalcost > balance``` or ```js
totalcost < balance```
thx
How is the Discord chat 2 minutes BEFORE my local system time... 
i get confused mmyes
You might want to do greater than or equal to Incase they have exactly the cost
That’s a relatively simple thing, if your total cost is greater than your balance, then you cannot purchase whatever it is you’re buying
^^^
is there any npm package to parse a function into a string?
=< ?
<=
toString()
A JS function... no lib needed
function test(a, b) {
return a + b;
}
console.log(test.toString());
Isn’t toString() automatically called when placed in console.log
OR
console.log(`Funtion: ${test}`)
Ah, so only with interpolation
it only gets auto called, when u try to concatenate with a string.
Got it
same true for any object. (functions are objects too)
also, u can override the toString() method, to customize it a little bit
I'm pretty sure console.log calls toString automatically
ooh yes
The one at the broad side of the arrow is the one that has to be the bigger value
mAtHs
Imagine a lowering sequence, > means the direction
6 > 4 > 3 > 1
Or just remember that meme "something >>>>> all"
thx
for 2 things
helping me understand
helping me learn maths
(no sarcasm)
This technically is more logic than math
but
Iirc it only appears in domain definitions in math
stiill maths
Wait... so you don't know what > and < are in math?
my mom taught me that the one that's smaller is where the pointy part is at
since i was a child
idk I feel like I've always known this

its taught in kindergarden.
never went to kindergarten gang
Lol
Came with pre-installed softwares I see
it was full when i was supposed to go so my mom just said fuck it you're not going
and taught me everything in like two months
so i came to first grade fully literate
Damn you missed so much fart jokes
ive died atleast almost once during my time in Kindergarten



