#development
1 messages · Page 65 of 1
let array = []
let object = {"array": []}
How would I push the items in object.array to array? (without .forEach if possible)
array.push(...object.array)?
yup thats it
concat is faster
anyone know how to make a specific message send with option choices? discord.js v14
it's literally just changing a word and removing the ...
technical debt is a thing u dont want to have
When I did that, it stopped working 😭
You simply pass your option structure as argument to your send() method
u probably did something wrong then
micro optimizations
not so much micro, spread is a hella slower
from .push(...object.array) to .concat(object.array)
and what error happened?
None
isnt it like const "name" = interaction.options.getString('option name')?
yeah
this is what i did for the option thing
const playerRC = interaction.options.getString('player-rc')
is that right?
channel.send({ content: "Java sucks", components: […] });
… is your array of components
In your case your select menu
ah js concat doesn't modify the original arrays as it seems
so you'd have to assign the returned array to the property
arr = arr.concat(object.array)
That’s how to get your application command option…
That has actually nothing to do with your question
Just explain once more what u wanna do, please @earnest phoenix
This is for just a startup script so couldn't really care less 😅
Thanks for your time tho
Is it possible to clear a select menu's selection after it is used?
just edit the components
What am I doing wrong? Im copying form stuff from here: https://chakra-ui.com/docs/components/form-control/usage#usage-with-form-libraries
so when I type in the Input field or click the button the page turns white and I get sum errors, this is my modification of the code, whats wrong? (https://hastebin.com/pisokuyiyi.js)
and yes, the one from chakra works when I dont edit it
fixed it, had to add this to the formik block
initialValues={{ }}
@client.event
async def on_message(message):
if message.content.startswith('.rules'):
embedVar = discord.Embed(title="Title",
description="Desc", color=0x00ff00)
embedVar.add_field(name="Field1", value="hi", inline=False)
embedVar.add_field(name="Field2", value="hi2", inline=False)
await message.channel.send(embed=embedVar)
ERROR: Bot not responding
full stacktrace thanks
Enable message content intent -> https://discordpy.readthedocs.io/en/stable/intents.html
It responding to other cmds
you're not catching if the user is the bot itself
also, still provide a stacktrace, that error is not descriptive at all
literally first priority when making commands and avoid ratelimits
because that would explain why your bot got ratelimited, if it has been
and would explain it not responding
RIP, everything was fine by my internet was so slow that it didn't save anything
can I use message.content.startswith as a variable and use it?
**```
trigger = message.content.startswith
@client.event
async def on_message(message):
if message.author == client.user:
return
if trigger('.hi'):
await message.channel.send('hello')
not like that as message would be undefined
why is your font funny
you'd have to define it in the event
so is there a way i could put a rule in db to not accept users with the same ID
you have a serious, SERIOUS structure issue there
there's not only a way, but a rule for structuring data on sql databases
me when primary key
all tables should have 1 or more primary keys, which is, by definition, an unique identifier for each row
optionally you can use AUTO INCREMENT to make it increment automatically
atgrainger
I'd even go a little further and make a constraint where username + discriminator must be a unique combo
since discord doesn't allow duplicate name + discrim too
I'm trying to write cookies on my client with react-cookie and cookie but it somehow doesn't work.
const [accessToken, setAccessToken] = useCookies(["accessToken"]);
....
setAccessToken("accessToken", data.token.accessToken, {
secure: true,
maxAge: 900,
httpOnly: true,
});
btw Next.js
so you are saying i wont need id's?
and just using the convos
nono, you will still need ids
ids are used for indexing the data, it drastically increases query performance
Auto Increment?
1, 2, 3, 4, ...
you don't need to supply an id when inserting data
unless u want a specific id
pg.query("INSERT INTO premium(id, username, discriminator) VALUES(1, 'random', '4232')", (err, res) => {
console.log(err, res);
});
what i am doing here is very basic
your issue is in the structure itself
and this ^
show me ur table ddl
what's a ddl
data definition language
the script u used to create the table
or did u create with the gui?
not cringe at all, go to "alter table" or smth and show me how it's structured
nothing much here
create table data (id primary key autoincrement, username text, discrim integer)
hmm, weird gui
but yeah that gui weird
but yes, drop the whole table and execute what una said
what's more beneficial? limiting var length on sql or checking the var length on the code?
code, but also limit on database
oh okay
that's great but still i will have to handle it on backend
reason is trying to input data bigger than the column size will raise an exception
and exceptions are quite costly
yes handle on both
ok, i'll break it up:
id INT PRIMARY KEY AUTOINCREMENT
├┘ ├─┘ ├─────┘ ├─┘ ├───────────┘
│ │ │ │ └ will receive an `N + 1` number as default value, with `N` being the current value
│ │ │ └ it's a key
│ │ └ primary constraint (non-repeating and not nullable)
│ └ will hold integer values
└ name of the column
una forgot the type of the column
CREATE TABLE users (id TEXT, username VARCHAR(32), discriminator VARCHAR(4)) PRIMARY KEY (id);
just store the actual IDs bruh
U almost nailed it, if not for TEXT
And discrim can be a smallint
Id can be limited to 32 chars
Text as primary key… smh
What prevents you from just using an INT AUTOINCREMENT primary as ID?
Full text searching on columns other than the primary one is still faster in the indexed table than text as primary column
Would even make more sense to use the user tag as primary key (or unique) as VARCHAR instead of text
32 chars max + hashtag + 4 digits as discriminator
i have a command with option choices:
.addStringOption(option =>
option
.setName("apply-for")
.setDescription("What are you looking to apply for?")
.setRequired(true)
.addChoices(
{ name: 'Player RC', value: 'player-rc' },
{ name: 'Creative RC', value: 'CREATIVE RC' },
{ name: 'Creator RC', value: 'CREATOR RC' },
)
),
And when a user picks a option i want a specific embed to send so Idk if this works but i put down this:
const playerRC = interaction.options.getString('player-rc')
and when i do playerRC.reply({}) i get a error. So idk if im doing it right
they mean using the user id, instead of a sequential id
it's usually much better if u need to fetch a certain user by id
Ah thought he just wants an unique id
But a bigint primary id which represents the discord user id still make more sense than text
your string option name is called apply-for and not player-rc according to your code
player-rc is just the value u get once the user selected it
so how do i make a specific message send when a user selects the option
something like this i guess ```js
const choice = interaction.options.getString('apply-for');
if(choice === "player-rc") {
// do something
} else if(choice === "CREATIVE RC") {
// do something else
} else if(choice ==== "CREATOR RC") {
// etc
}
ahhh okok tyty
hey hey guys, im trying to get my site to embed in discord but for some reason im only getting the image to pop up by itself. can you tell me what im doing wrong?
<meta property="og:image" content="https://mewdeko.tech/assets/img/monogatari-series-background-hd-1600x900-108924-1.jpg">
<meta property="og:type" content="website">
<meta property="og:description" content="Invite Mewdeko! The only completely free bot that's both open source and completely customizable.">
<meta property="og:url" content="https://mewdeko.tech"/>
<meta property="og:site_name" content="Mewdeko" />
<meta name="twitter:card" content="summary_large_image">
hey! discord heavily caches website embeds.
Is it possible its not updating just due to caching?
Definitely that
Also u forgot to close last tag
i tried adding a # to bypass caching
Doesn't matter
since it thinks its a "new" site
U can't bypass discord cache, I tried it
As long as it's the same endpoint, it'll still cache regardless of params
Except if ur sending an image url
i just did it
.... why is discord so stupid
and why did it send as a separate message
yeah that ik, will have to wait ages
Like, the cache probably cycled while u were trying
nah
When I was testing my og tags I made multiple endpoints to test it
I think query params work 🤷
its probably using the cloudflare setting kek
prolly
are you able to mention a role in dms?
kinda
but the other side will see deleted-role if they dont share the same server
i was just testing with myself and it came up as deleted-role
is there a way to fix that?
nope
there's nothing to fix, it's the client that transforms text mentions into interactive mentions
ahh okok
what a wonderful place to say that in #development
idk if Discord's cdn respects cache related response headers
might be something to test
Nope, tested that already
For testing of tags you simply add some random GET parameter
To bypass the cache and play around with it
How do you think to make music for my bot? If so, which networks should be included in the supported ones? I will definitely turn off YouTube, but what else do I need to turn off?
@solemn latch can u recheck my application
Application ? Staff application?
If you mean that we check them when we need new staff members.
If you mean your bot's approval we check your bot once its your bot's turn in the queue. It can take up to 2 weeks
Now please stop mentioning or DMing random staff member or you may get muted, thanks 
How to make custom prefix?
No my bot application deny because of nitro emoji and I removed emoji
Sorry for Ping
Simply check your message content to see if it starts with your “custom” prefix
..
Not to say that nowadays it makes much more sense to move to application commands anyways, aka. slash commands
yhea
All right then refer to the message below that 
just delete it

u mean slash command?
[No]
ok
then just delete it
non-slash commands aren't registered at all, just delete the file or the binding whatever
I want bot to delete command after command is used
delete the message, you mean
because "delete command" makes little sense since command means code
🚶♂️
u need to use the proper words when asking questions, else there might be confusion understanding what u want
Slash commands 67.6% adopted without even incentivising or pushing people to use them 👀
I mean, for the end user slash commands are way more appealing than prefix commands
Yeah they're much better
for the developer tho... 💀
The UX is much easier than messages
For users
And honestly for devs it can be easier too tbh because you have Discord's native input validation
Well arguably in Python there's no difference for example
it's easier if u use common command-response cmds with little syntax mutability
slashes allow little flexiblity when you need to have different syntaxes based on supplied args
Yeah they can be a pain sometimes
Finally, did it
I've only ran into that once though
Oh, hi mac
I made my handler in a way that I can switch to slashes at any moment by flicking a switch, I'm just waiting for discord to implement conditional syntaxes
How I can use every msg as a cmd input for an api
I run slash commands and prefixed commands off the same files but have to do a bunch of input validation and handling at the top of each file which is a pain
.message.content.startswith()?
that'll only check if the message starts with X
.message.content.startswith(Every single message)
you're new to programming aren't you?
well, I'd recommend you to take a few crashcourses before starting a bot, it'll save you a lot of headache later on
which lang?
BDSCRIPT 😂
that's not really a lang, and let's be honest, it did 99.9% of the job for you
Yes
programming is like...writing a bread recipe
you need to tell the runtime EXACTLY what you want to happen
BDFD is like eating that bread
sometimes, like in your question, it reads very fluently
message.content.startsWith
"message content starts with"
Yhea ik
so, if you were to write in plain english, "message content starts with every message" makes little sense
My bread
ik but you're really, really missing the essentials of programming, in this case "what are object methods and how to use them"
using raw coding is much more complex than using a bot builder, but also much more powerful
lmao
Bro u got that badge
oh there we go again
I verified right at the start of it, that's why I have the badge
Teach me
I wanna learn
I...cant because it takes a lot of time and dedication
I got both
I don't
😭
google has a ton of tutorials on how to program using js
yes, js is what you're using
No
does your code contain {?
No
oh it's python then
I'll be honest, python has a HUGE complexity curve later on
it starts easier, but snowballs very quickly
It looks simple
Like variables
variables are variables
Okay
they can change along the way
Constant in maths
I call python a "newbie trap", because it looks easier at first sight, but when you notice it's already too late
wrf
wtf
What you use
java
Okay
wdym
back to the topic, run a few courses on python to learn how things work, the longer you study the more you'll get to know it
agreed
because it is
But at the end it sucks
it's primarily targeted towards beginner programmers
well yes, but things get very messy real quick if your codebase gets big enough
they made it as a scripting language, they didn't account for bigger codebases
messy?
yes, very messy
doesn't that apply to every language
kinda, but most non-scripting langs have ways to make understanding the code easier later on
like, I love bash but I'd never use it to write full-blown projects because it's fuckin unreadable at bigger sizes
lmao
what's the difference between scripting and other types of programming languages
interpreted?
scripting languages have a shitton of abstraction and ways to write one-liners for objective tasks
with python I can manipulate windows and files like eating a piece of cake
no sweat, clear and precise
I wouldn't write scripts in c++, java or even js, per se, since they'll drag the code way longer than if I used bash, python or lua
using threads is...at best "awful" in py (js suffers the same), since you need to juggle child processes around instead of multithreading directly within a single runtime
you host your js bot in books? 🤯 😱
I don't wanna say this but that words made you look like avg 10 year old
Btw yes
nodejs worker_threads
not really "threads", it still spawn child processes
oh im sorry 😭 😖 im new to programming 🥺
I cant say if this is incorrect or not because the require cache isn't shared, so might be different memory spaces, but worker heaps are included in the main thread heap dumps
oh wait no
SharedArrayBuffer
they are actual threads
Ok
hm, interesting, so node does allow multithreading
Yeah node have their way with worker threads
Pretty nice article
guys if do bulk delete more than once is api spam how some bots delete more than 100 messages
They add a rate limiter in their code that follows the rate limits of Discord
how can I add a rate limiter too?
You code it so that you follow the rate limits, they're written in the documentation
I am using djs
That's cool but doesn't change anything
The same applies in any other library or language
Might want to take a look at what rate limits are on the internet, so that you don't delete messages too fast for Discord to not like it
Once you know what they are, it should be self explaining how to follow them
Just send msgs quickly
You won't get spoon-fed with code here though
For context, the closest they got to programming was with bdscript
No
Oh it's the syntax they use
Like

Yes, it's a bot builder
Yeah, then don't expect to have the same freedom as when using a proper library & programming language
They probably don't even support raw event listeners
Told them to do a few courses, but apparently they didn't yet
No no, they aren't using bdfd, they used it before
Now they're using dpy
But have virtually no knowledge of programming
perfect
finished bot
yes
well what should I do? I don't want code but I don't understand well what is the rate limits for bulkDelete ing message for example waiting 10 second between each bulkDelete is enough? so if they bulkDelete 1000 it will delete the messages after 100seconds, I know what is the rate limit but don't know how should I create a rate limiter/rate limit checker
Discord's API docs will tell you how many messages you can delete, then make the bot rate limit/wait accordingly
do note, mainstream libs usually have an internal ratelimit already
also, bulk delete cannot delete very old messages
It has limit of 14 days
ye
also depending what .delay() does, it might halt your entire bot
await cannot halt the thread in node as Promises are part of the event loop. It only halts the current scope
I'm pretty sure u can halt an application by awaiting
in other languages, sure
no, quite the inverse
in other langs (those that use multithreading) u cant halt the whole application (save for a few weird langs, like delphi)
had a talk with tim not so long ago abt that, how awaiting inside an event caused the application to freeze
Even ES Modules (await in top level) cannot fully halt the thread as even things like import statements are collected on load regardless of where they appear in the file, so if you want to do an async task before loading a module, you literally can't
not talking abt modules, imports or anything like that
The import statement is async
it is intrinsically awaited
but all of the imports are pushed to a Promise.all
The thread still is not halted
I have had to work around this in a few of my projects that were once cjs
Only synchronous methods can halt the thread
I would not compare imports with general awaits
The stack trace of errors related to imports literally includes Promise.all
still
If you can produce code that halts the js thread, I'll believe you
I have literally never witnessed the thread being halted
cba to make a djs bot for testing purposes
if there's anything wrong with that test I'll modify it, the file will stay there while I dont close the ide
the promise was supposed to execute infinitely without stopping "The end" from being printed
This is because the event loop works in ticks and while loops halt the tick execution as the thread waits for each tick to complete
The PromiseConstructor itself is not async, so the callback is executed immediately on the same tick and the while loop halts the tick, thus anything below doesn't happen
hmmm aight, brb
but wait, what can I use to test then?
if I make another promise await that async loop, it'll still be inside a promise constructor
You were trying to argue await blocks the thread
yes, gimme something to await
when something is awaited, it's pushed onto the event loop
a fetch call to https://amanda.moe
:)
why would a fetch would hang forever?
Does it need to hang forever for the effects to be noticeable?
pretty much yeah, or a task that'll take very long to complete
else it'll result in unnoticeable difference
oh ik one
Immediate console logs should be noticeable
they would be out of order
66ms to load a page is not a small amount of time when it comes to nodejs' throughput
indeed it didn't halt, perhaps it only happens inside events then
tho I'll not create a bot to test that
you can construct a new EventEmitter
const { EventEmitter } = require("events")
I'm pretty sure the events module is not coupled to the logic of the underlying event loop
ok, ran 2 tests:
- if the promise is created with
setTimeoutto resolve it later, it works normally - if I make any long-running task inside the promise, simply calling it will prevent the second event from running at all
Just due to how node waits for each tick to finish
idk if worker_threads have their own event loop
yup
Smart
I cannot think of any long running task other than an infinite loop, js is inlining everything I put
but ye, await does basically nothing regarding it, calling the method itself is enough to halt it
regular expressions funny enough halt the thread with compilation and matching
I wonder what monster of regex manages to take more than 1s to compile
everything in js is sync
until the point it isnt
even promises, callbacks and events are all sync
until one specific point when they exit the current event loop iteration
At their core, yeah
exiting the current event loop can only be done in a handful of ways
thats what actually makes the code "async"
Compiles are usually no problem. Cloudflare had an issue when it comes to matching, a regex they deployed backtracked a lot of times causing CPU exhaustion at scale and was just a regular expression denial of service. The part of a larger regex that caused the exhaustion was .*(?:.*=.*)
An example string they provided was
x=xxxxxxxxxxxxxxxxxxxx matched against that regex takes 5,353 steps mainly just backtracking.
https://blog.cloudflare.com/details-of-the-cloudflare-outage-on-july-2-2019/#appendix-about-regular-expression-backtracking
Almost nine years ago, Cloudflare was a tiny company and I was a customer not an employee. Cloudflare had launched a month earlier and one day alerting told me that my little site, jgc.org, didn’t seem to have working DNS any more.
lmao
ReDoS are fun
ID usually matters very little if exposed, but the log isn't supposed to be public anyway
like, it's probably a hash or smth, it's not like having your token leaked
- they most likely reset
very likely
main gateway sessions can be exposed just fine since they're under bot tokens. Sessions under the voice are more detrimental to leak
chances are it's just the current timestamp + shard index hashed into md5
sessions only reset if you do something to invalidate your session like sending a bad packet or something or your bot doesn't reconnect within 2 min
Like 2022-11-08 23:55:12 INFO discord.gateway Shard ID None session has been invalidated. 2022-11-08 23:58:10 ERROR discord.client Attempting a reconnect in 5.41s Traceback (most recent call last): File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/discord/client.py", line 627, in connect await self.ws.poll_event() File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/discord/gateway.py", line 645, in poll_event raise ConnectionClosed(self.socket, shard_id=self.shard_id, code=code) from None discord.errors.ConnectionClosed: Shard ID None WebSocket closed with 1000
Discord sends you an invalid session whenever you try to resume a session when it's past its expiry time or you did something bad
Like?
Something bad?
Sending invalid JSON or sending JSON which doesn't follow the { op: number; d?: any; s: number; t?: string } format
or sending an identify packet.d in a presence update op
json is json regardless of lang
every language has a JSON serializer/deserializer
Ok
dont mind too much about the technical details, focus on learning how to code first
Ok
the lib abstracts all those stuff for you, you'll very rarely, if ever, need to tackle into the internals
aside from using nano for coding, you really shouldn't hardcode the token
_probably doesn’t matter at this point anymore _ 
I like ur pfp FakE
nano > all other editors
who needs intellisense
your editor suggesting to you how you should code? Blasphemy
cough notepad++ cough
well, better to happen during verification than after it goes public
that said, test your features properly, don't simply give admin and call it a day
gotta love when you dont unittest your bots :3
if it works locally and on my server with admin, so will it on the moon
gotta love when
ofc I do lol
nubs exposed
Just have the car randomly stop 
I mean I am doing a esp32-based selfcontrolled car in vocational school rn
should just make a 5% chance of it just stopping lol
also a toy car, not an actual one
add another 5% chance after stopping to go reverse full speed

when u declare steering wheel angle as an integer instead of double
angle-snapping wheel
tho rip if it uses rad instead of deg
entering one 0 too much... wooshh cut off your legs
Lmao
This video tutorial will explain how to mod your Porsche 911 or other car to run Doom in just three easy steps. No engineering experience is required, it only takes a couple minutes, and this works for many different cars built in the last couple years.
Demoed with Doom and Doom 2 with a 2017 Porsche 911 Carrera S Cabriolet.
NOTE: This mod was...
say fucking less
I think at this point everything that has a screen had someone attempting to run doom in it
idk why bad apple is so popular, or where did it come from, I just know it's everywhere
funny weeaboo dance in black and white omg
there's an anime btw, but it barely covers the lore
it's popular because it's really easy to port it everywhere with not much effort compared to doom
but why bad apple specifically
because it's just a black and white video
which makes it really easy to put on everywhere
though ngl bad apple is a banger
it is, it's just odd that a random video from some nobody got to doom level
^
though it's not just some random video, the music video exploded in popularity when it first came out
// asynchrous thread
for () {
return new Promise((resolve) => {
resolve()
})
}
`for () {
I mean yeah, but there's no point in the loop
since the function will return after the first iteration
Didn't bother to fill in any arguments
But it would go to the next iteration once resolve is fired correct?
No
You're returning from the function
return transfers control back to the calling function
Remove return and it'd work?
The next iteration would start once the current iteration would "idle" or finish right?
That's what await is for
If you want to wait for the result of a promise, await is the way to go
You can use .then callbacks as well but they're messier in the long run
I think what you're looking for is an anonymous self executing async function maybe?
(async () => {
// Async stuff
})();
for (let iteration = 0; iteration < 2; iteration++) {
promise().then(() => {
console.log("Yippie!", iteration)
//"I have finished"
})
}
I'm just going back to the basics
Reminding myself yk
The for loop would go to the next iteration once "Yippie" is logged right? (Since it's the last line)
What you put there is correct, but you can simplify it to something like ```js
for (let i = 0; i < 2; i++) {
await promise();
console.log("Yippie!", i);
}
async/await is a lot cleaner
Would I have to put the for loop in an asynchronous thread?
Or am I just asking stupid questions at this point where the question I'm asking is a yes already.
is it possible if a user only has access to buttons if they used the command and no one else can use them?
you cannot disable or hide the buttons from other users, but you can ignore the button press so that nothing happens except if the user is correct
or you can put the buttons in an ephemeral message, only the user can see the message if its ephemeral
yeah thats what i want. But the command that i have needs to be visible to other users. Are you able to help me out on it?
if you want the loop to wait until a promise is fulfilled before proceeding to the next iteration, then yes you need an async context and you need to use the await keyword
await keyword where exactly?
await promise() correct?
if you dont use the await keyword, you will only be initializing the promise, without any guarantees of fullfilment
yes correct
And no differences if it's in a try block?
the same thing applies to a try block, it will only catch the error if the await keyword is used
sum like this?
yes
np!
Should I move the continue statement into the finally statement (or whatever I should call it)?
you need to store the user id of who ran the command somewhere, for example in the buttons uniqueid
another tip: use semicolons if you don't already C:
Tell me, what makes it different next to stacking lines?
you dont need the continue keyword, the will will automatically proceed to the next iteration once it reaches the end
It's less ambiguous
Define? 😄
unless you want it to skip the current iteration prematurely
The compiler is guessing where you MEANT to put them, but that may not always be where you intended them to be
🦆
It's usually not a huge issue, but it improves readability and reduces the chance for bugs
You can get a linter or something like prettier to do it for you even
If you can tell me where I can find the .json where it stores the extension/beautifier when using Shift + Alt + F in VSC
And you can set it to format on save
idk, I just copy the same .prettierrc file throughout every project I make tbh
am i able to put it into the handleButtonResponse?
shut yo bitch ass
i removed all semicolons from my JS projects because it looked a lot cleaner if i do so
does discordgo have a way to await for a user message?
it's not as ambiguous, unless you do things like
if (a.isTrue())
something()
other()
or
const a = () =>
69
+ 420
I think it looks ugly and can cause bugs
class MyClient(commands.AutoShardedBot):
def __init__(self, *, intents: discord.Intents):
super().__init__(intents=intents, command_prefix=check_prefix)
async def setup_hook(self):
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
await self.load_extension(f'cogs.{filename[:-3]}')
await self.load_extension('jishaku')
dbl_token = "e" # set this to your bot's Top.gg token
client.topggpy = topgg.DBLClient(client, dbl_token)
@client.event
async def on_autopost_success():
print(
f"Posted server count ({client.topggpy.guild_count}), shard count ({client.shard_count})"
)
is this correct?
Try it and see. Then report back the errors, if any, here
what was the built in node alternative of using oneline for multi line strings which don't break indentation?
Any help?
How about waiting some time for stackoverflowers to reply?
Waiting and being patient is part of being a developer :)
If you ask in tons of places and get a response at one place you most likely won't reply to the others that took the time to reply somewhere else; so ask at one place and wait 
hmm ok
ty
What that * mean?
Python Enhancement Proposals (PEPs)
Another good explanation is here on stackoverflow https://stackoverflow.com/a/26365795/15190238
Okay
command
Error:
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/discord/ext/commands/core.py", line 190, in wrapped
ret = await coro(*args, **kwargs)
File "/data/data/com.termux/files/home/discord/bot.py", line 36, in unban banned_users = await ctx.guild.bans()
TypeError: object async_generator can't be used in 'await' expression
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1347, in invoke
await ctx.command.invoke(ctx)
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/discord/ext/commands/core.py", line 986, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/discord/ext/commands/core.py", line 199, in wrapped
raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: object async_generator can't be used in 'await' expression
Blindly copying code from old tutorials won't help you learn, especially from such a bad tutorial serie on YouTube
See the documentation about how to use bans()
https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild.bans
They have two examples
u know which series was it just by looking at the code snippet?
Nope
Been helping in the python server for like 2 years for discord bots
Enough to be able to recognize tutorials just by seeing snippets
In this video, we create a command to unban a user from a discord server.
If you have any suggestions for future videos, leave it in the comments below.
NAMED TUPLES: https://pymotw.com/3/collections/namedtuple.html
GITHUB: https://github.com/Rapptz/discord.py
DOCUMENTATION: https://discordpy.readthedocs.io/en/latest/
OFFICIAL DISCORD.PY SER...
Here ya go
Yes
lmao
Lucas is also popular for that horrible tutorial series
Why horrible?
Not sure if that's a good thing to be popular for that but yeah 

probably for bad habits or not properly explaining what he's doing
notorious
word i was searching for
Ig he explains good ig
At least better than my physics teacher
There is an entire gist about why his tutorials are bad, feel free to read it
https://gist.github.com/wasi-master/835adfeec4802423f6a1522c25689010
cc @lyric mountain@outer crater
credit card? /s
A few comments about the presence for example or why not to read a file on every message event are as stupid as you called out the videos on YouTube
¯_(ツ)_/¯
Google cloud is better than local host?
It doesn't serve the same purpose
But they got better internet connection than me
You definitely don't want to host your bot at home
I'm doing rn
GCP is one out of many other providers, you probably don't want to go for GCP or AWS due to their pricing
Nothing then
Oracle has a free VPS
Oracle is perfectly fine for a free VPS for hosting a small bot
You will eventually need to upgrade, but that goes for any service. Oracle at least provides a proper VPS for free
What is Minimum server limit to continue free service?
There is definitely no server limit because Oracle doesn't create their VPS specifically for Discord bots
You most likely have a specific amount of hours per month/year your VPS is running for free, after that you'd need to pay
I really reccomend reading and understanding their free service tier before using it in a production environment.
Why is DPI so complicated
Should've never started that
https://github.com/advisories/GHSA-8g2p-5pqh-5jmc
C Tic Tac Toe moment
I'd not say that nowadays
they cancel your account out of the blue without any justification
I used to think tim was joking, until it happened to me not so long ago
a vps doesn't know or care about the bot, it's just a remote computer
u use it for whatever u want, as long it's legal

@_@
This not good as a discord bot must be online 24/7
And that is why free VPS are not good
and that is why free things in general are not goid
good
what a surprise
quality comes with a price, if you can't provide that price, you won't be able to have that quality
free = not good
good = not free
free + good = you're the payment
free + good + unlimited = they're selling your data
also, + heroku: omg free token may I use uwu
whatever host has some sort of tier that allows you to private your stuff lol
With ads?
Absolutely useless
You get once a week/month or something on the panel, if you have automatic deployments you never even go there
I have had 3 free oracle machines running for about a year now with no issues
well, you run the risk of having them terminated without previous warning
I'm not too worried about it because it's just personal programs being run. And even moreso now that I have a home server
Just no point in migrating them to my home server if they're doing their own thing there without issues
Ppl running home server
You should be well aware about the runtime costs and hardware prices
how many FakEs does it take to run a bot
How can I limit the body size in a node:http server?
you don't
you simply reject the request if it exceeds a certain size
how do I get the size? Just check if the body has like more than 1 mil chars or something?
yes
would that prevent massive post bodies lagging a server?
do note, it wont work if u intend to use it to limit upload size
no
and it doesnt matter if it's get, post, put, delete, whatever
the server will receive it regardless, receiving is what can crash a server
if u want to prevent that, use a middleman
like nginx
does expresses body-parser have the same problem?
idk what that is, but if the request reaches your server, it's already too late
you can check the content-size header
before you start actually downloading the data
or rather, content-length
not content-size
express and body-parser have a size limit option you can configure
That doesn't really prevent long uploads though.
ie, if I upload 1 million characters and send 50k a second, that still will cause issues right? 🤔
no wait, we've talked about this before. thats non blocking?
the server wont process any data until you tell it to
for example in node:http you need to explicitly add a "data" event listener to start receiving the data
until you do that, the stream is paused
the uploader's side is also paused
the uploader will only start uploading when the server starts downloading
so you can check headers and reject the request before the upload starts
will the header always be available when a body exists or can malicious people somehow remove it?
content-length is mandatory except when you use chunked transfer encoding
afaik
chunked transfer encoding is used when the total size is not known, for example for audio/video/dynamic file streams
in that case each chunk will have its own content-length
is content length the amount of characters or size in bytes?
another thing you can do is start reading the data, but only read X amount, and if still not finished after reading that amount, cancel the reading and reject
size in bytes
node has methods to manually read streams
instead of using the data event
Can't content length be faked tho?
I would imagine express stops downloading as soon as content-length is reached.
Any idea If this code will work
module.exports = {
prefix: 'shutdown',
description: 'help_shutdown',
action: async function (msg, data, safeDS, command_message, message, app_permissions) {
// Check Global Permission
if (safeDS.config.allowShutdown) {
// Shutdown
if (app_permissions.superAdmin) {
await safeDS.console.file.sendDSUserLog(msg, 'mod', 'info', 'log', `${safeDS.lang.get('cm_shutdown_result', data.lang)}`, null, true);
// Emit Event
await safeDS.events.emit('command_shutdown', {
bot: data.index
}, msg);
safeDS.close_app(`${safeDS.lang.get('cm_shutdown_alert', data.lang)}`.replace('{user}', msg.author.tag).replace('{id}', msg.author.id));
}
// Nope
else {
// Emit Event
await safeDS.events.emit('triedSuperForbiddenCommand', {
bot: data.index,
command: 'shutdown'
}, msg);
// Send Message
await safeDS.console.file.sendDSUserLog(msg, 'mod', 'error', 'error', `${safeDS.lang.get('cm_shutdown_not_allowed', data.lang)}`, null, true);
}
}
// Nope
else {
msg.channel.send(safeDS.console.discord.error(`${safeDS.lang.get('cm_shutdown_not_allowed', data.lang)}`));
}
// Complete
return;
}
};
been tryna make this for a while
does anyone know how I can do it with markdown?
try it and see
Cant rn
lists can be done with either - or * characters
My host is messed up rn
for example:
- 1. something
- 2. something else
it looks like this
.
I get notifications when my bot joins servers
That most likely uses HTML with custom styling
File "main.py", line 5, in <module>
client = commands.Bot(command_prefix = "!")
TypeError: __init__() missing 1 required keyword-only argument: 'intents'
i have this error
import os
from discord.ext import commands
client = commands.Bot(command_prefix = "!")
async def hello(ctx):
await ctx.send("zsx is a W")
token = os.environ['TOKEN']
client.run(TOKEN)``` My code, Its a project im creating but i wanna see what im doing wrong
yep made it work
how do I fix this huge spacing though? xD
import discord
import os
from discord.ext import commands
intents = discord.Intents.default()
client = commands.Bot(command_prefix='!', intents=intents)
async def hello(ctx):
await ctx.send("zsx is a W")
token = os.environ['TOKEN']
client.run(token)
?
your token is inside hello command
Yeah you need it hidden lol
Is there a way to get a user from the API without authorizing (i.e. to hit /users/...)? I'm working on my personal site and don't want to hard-code my Discord tag.
use lanyard api?
could save your info in a db
I ended up just using laryard (ty daff), though am considering a more permanent solution
Then you'll need to have a backend that gets that information using Discord's API
You have no option but to use authorization using for example a bot application's token, since you're working on your personal website you can just put that in there and fetch the user information
So Discord still requires a bot application even if the bot won't actually interact with anyone?
if making changes to options such as roles etc, yes
The bot doesn't have to be connected to the gateway or anything like that in anyway, the main reason the user endpoint requires authorization is to ratelimit you if you exceed the limit
Find yourself
Hey how do i get my bot on app directory?
on the developer portal page it says my bot meets all requirements
but its not appearing on the app directory
am i doing something wrong??
is your bot verified ?
yes
its in 11k servers
damn that's whys it wont show for me 😢
what? lol
damn
i try'ed to look for it and it wasn't there
mb mb lol
yea not yet ;-;
good luck with it
ty :)
bump

Where I can host my website for free? I got my html file....any suggestions?
webhostapp if it's just an html file
but lol enjoy that 000webhostapp domain
💀
can you pls help me 
how do i get my bot on app directory
yes this has been done it shows all green for me
but the "Enable discovery" is disabled for me
here screen shot
In that case
We do not represent Discord, nor are we affiliated with them. We merely use their service.
If you have any questions and/or suggestions regarding Discord itself, or wish to report any violations to the Terms of Service, you can use any of these links:
How to leave feedback/suggestions to Discord
How to report bugs/issues to Discord
How to report a violation of the Terms of Service to Discord
How to contact Discord for general inquiries
netlify
Okay,,lemme check
github
there's also replit
Repli domain is ugly
https://name.project.repl.co is shorter than most free options
Keep in mind domains cost money.
tk is...something else
With replit
you never really get to "own" any of freenom domains
you just borrow them, and your site gets iframed inside a proxy site
this causes many services to simply reject talking to your site at all (since freenom tlds have a looooooong history of scams)
Iirc tk domains can be taken from you at any point.
If it grows too much they will take the domain back and ask you to pay a lot of money
that too
Which you'll at that point have to pay, because all your users only know that domain.
they also include a few trackers in that proxy site, so there's the privacy concern
time to ddos every website using the .tk domain
Tk domains are amazing for fun projects that you only intend to use for a short period of time.
It's saying not found
repl co is the suffix for replit
Yay....got that!
https://de.tox.aviral@141.reple.co
Why
It's not showing full link?
@lyric mountain can i use javascript and collect ip of visitors? Is it legal?⚖
well...it's a gray zone
Umm?
it aint illegal, but u need to state you'll be collecting it
and gathering ip is usually frowned by people
the question is, why do you need it?
ip is considered sensitive data, so it falls under GDPR (whatever it's called in your country)
Hint: just don’t steal user data
IPs are mostly used for validation purposes. If you have no legitimate reason to collect them, then don’t
Simple as that
and if you do, remember sensitive data must have a TTL and be available for deletion at any time
OK
but.. but.. I wanna see the funny numbers
...
fe80::1
converted to ip it'd be 222.173.190.239
open the file -> write text -> close file
...
u added an extra zero there
Received txt
To .txt file
With
Html
Is there a way to like get options if you've selected an option
for example im creating a slash command, and if someone creates the option "enable" they get a list of other options like "channel", "role" etc but if they select disable then none of the options are there. djs v14 any way of doing that?
nope
well, you found out one of the reasons I refuse to use slashes
the lack of mutable syntaxes is awful
then just do it
open file, write text, close file
Its
search google
Null
$("/text.txt").html(data.ip);
But it will be like I have to use paragraph id
buddy ur ip logging
*sigh*
what part of "You shouldn't grab IPs unless you really need them" did you miss?
and in plain text, to put a cherry on top
you're asking to get sued for GDPR breach
It's for EU
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
all countries have their own version of GDPR
it's a pretty much standard law, with very little variation between them
but you'll eventually make it public no?
How
why tf are u making a site if you'll only use it locally?
I don't have money
we gave u a lot of free options
Yhea
I use replit for ma bot
As I said
"#1 ranked"
ok
6k users boi!!!!
u meant servers right?

You know which is best platform to host imgs and videos for Website with HD quality
@lyric mountain you were typing something
fixed
cuz it more likely isn't, it might give ur bot bad reputation for bragging without source
and a )
imgs -> imgur, github, whatever file host you choose
videos -> youtube
and "with hd quality" depends on what u send
Rip me, I use Discord
Why "no"?
No, no no no
Your repl bandwidth will suffer if u do that
Just use YouTube like a normal person
Youtube is a video host primarily, with added social network features
Who cares
well I guess an Icon doesnt matter though, right?
Your bot
My bot is on bdfd
Or site, whatever
Idc
If you dont care then do it
How
Well, soon you'll learn those hosts have a maximum upload rate
I said cauz he said my bot will suffer
The more u clutter the bandwidth, the slower things load
holy this 30mb image loads slow, prob insane limits then
https://aous.replit.rjansen.de/30mb.jpg
I use for embed image and one icon
Also if I'm not mistaken, replit has a maximum project size
There's really, REALLY no reason not to use dedicate hosts, unless it's for something like 0x uses for, icons and stuff
yup, on some hosts you can get whole vpsses for 1$ a month
one off workers responding to master commands
I want to somehow load balance my slash commands
I mean for media
but as my bot is a music bot, there is the assumption that the gateway exists for commands
Not for bots
I mean you can just setup nginx and host images there aswell
Not worth it still
Unless ur vps is on expensive tier
Youtube is there and more than happy to host your videos
Same for imgur
idk about more than happy
They are, cuz it means revenue for them
You misconstrue how much ads actually pay off





can i get some real help pls


