#development
1 messages Β· Page 1976 of 1
We just had that talk (again) yesterday
The people experiencing this issue are quite different, while I update the presence every 45s and have issues very rarely, others don't update their presence and the issue happens every now and then
I can't be more sure. Every time that client.user.setActivity is called, it's immediately followed by no answers from the API for at least 4 seconds. So when interactions finally arrives they are older than 4s and are not valid anymore. I can observe that after EACH client.user.setActivity calls. When I remove it, the bug disappear.
(not sure if this is the right place) how do i transform this to an image? (it's a guild's icon id)
Here is the Node.JS call trace (you can open it with the Chrome profiler). As you can see, there is a client.user.setActivity call then nothing for 4s
I don't have Chrome and will never do
Me neither, use chromium
https://discord.com/developers/docs/reference#image-formatting > CDN endpoints > Guild Icon
ty!
- In the case of endpoints that support GIFs, the hash will begin with a_ if it is available in GIF format. (example: a_1269e74af4df7417b13759eae50c83dc)
Well when running a few presence updates while waiting on the interaction response, none of them fails for me
I update the presence every 45s
Also since I mentioned this I guess I would have more trouble when spamming interactions to test
Continues the code without waiting for the output of the function even though I use await
Function:
Use:
If my bot fails to give the user the role they react-role'd for, should the bot DM them about the fail saying Hey I don't have the correct permissions to give you this role alert the server's respective moderator etc etc?
Or would DMs be too annoying for those kind of fails.
I think it depends of the number of servers. In development I can't reproduce the bug, but in prod (with 7500 servers) I can
in my opinion do not open the reaction role system if the bot does not have permission
or maybe it's because there is way more people in prod so more interactions, so a higher probability that the interaction happen at the same time as a setActivity
It try to alert about perms but sometimes Discord is so funky.
Or users changing perms etc.
Why does the code continue without waiting for the return inside the function to return?
;
because that's an event listener
the arrow function will get executed once the end event is fired
oh
but i can't wait for it
What the fuck is going on? Am I going insane or is git fucking up everything? Little changes from previous commits get deleted???
I think I'm losing my sanity
Do you want to check if an array contains the same elements in another array?
You can use the !, but you can't use .includes like that since it's for actual elements (e.g. if "e" is in alphabet, not if vowels is in alphabet)
You can use .every if you want to make sure every element is a subset
i still have the same problem
what can I do ?
That's because you're passing a function that'll probably be called some time in the future.
Not immediately, but some time later.
So there's no guarantee gender will receive a value by time you use it in other parts of your code.
there is actually a guarantee that gender will get a value
sendFiletoWeb function definitely returns a value
It doesn't look like it'll receive one in time
ok
oh
I can use if.. else
So is there a way to fix this?
this function combines audio files and converts them to wav format
Yeah, you could signal response with promises, for example
then i have to pass this file to sendFiletoWeb function so i can get the gender
For example,
function appendFiles() {
if (!chunks.length) {
return new Promise((res) => {
outputStream.end(async () => {
let gender = await ...;
res(gender);
})
});
}
// ...
}
// This is fancy for promises.
appendFiles().then((gender) => doStuff(gender));
What is the doStuff function?
Nothing special.
It's just a demo. It could be anything, like console.log
What's important is gender will have the value from let gender = await ...;
understood thanks
why
it worked before
let find = await cardss.items.find(item => item.name === card.name)
^
TypeError: Cannot read properties of undefined (reading 'find')
at Object.run (/workspace/commands/user/card.js:33:34)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
maybe cardss is undefined/null
but it worked fine
How do I check if my permissions in a guild contains admin (0x8)? example: 2147483647
either item or card isn't an object
try logging them
this logged undefined
Why ...
- TypeError: o is not a function
what is o
connection = joinVoiceChannel({
channelId: message.member.voice.channel.id,
guildId: message.guild.id,
});
I dont known where 0 is
The value of undefined still precedes the text "Cinsiyeti belirledim + gender (line 23)" in the function
is gender undefined or something else? gender should have a value assuming the assignment does return one
can you show the stacktrace? it may show where
I assigned the gender variable to the value from the function
"Erkek"
but it doesn't expect the value from sendFiletoWeb function
I fixed it but now checking how to play it
what do you mean by "expect the value from sendFiletoWeb"? it looks like it logged fine. maybe at .then((gender) => console.log(gender)) is the issue, but that looks correct given res is called. Since that log did show a value, it looks correct.
connection = await joinVoiceChannel({
channelId: message.member.voice.channel.id,
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator,
});
I'm using google translate
That's why I can't say exactly what I want to say
If I have:
{
"0": {
match: {
id: "i like cows"
}
},
"1": {
match: {
id: "i like cats"
}
},
"2": {
match: {
id: "i like animals"
}
}
}
How would I loop through the JSON data? I can't loop through it normally since data contains strings of numbers, not arrays.
for (var i = 0; i < data.length; i++) {
// Do something with data[i].match.id
}
I'm working with Challonge API, but this is a general JavaScript question I guess. This is my code:
cha.matches.index({
id: tourneyID,
callback: (err, data) => {
// Should be able to get the match ID based on whether the participant ID atches.
}
});
How to play the audio as in the guild it says subscribe
The main purpose of my function is:
Combining the audio files in the recordings folder and converting them to wav format and
Sending the "out" file created in wav format to the sendFiletoWeb function
get the output (Male - Female - Not Determined)
You can loop through and object using it's keys:
const obj = { ... };
for (const key of obj) {
let value = obj[key];
// do stuff...
}
It's in, not of
Thank you π
Huh. It says that data isn't iterable.
for (const key of data) {
let value = data[key];
console.log(value.match);
}
/home/container/index.js:576
for (const key of data) {
^
TypeError: data is not iterable
at callback (/home/container/index.js:576:25)
background-image: url("https://picsum.photos/1920/1080"); how to change that with js
the class name is bgBlur
Never mind using in works
woops my bad if u use of u need to use Object.keys
ah. Ty
import dotenv from "dotenv";
dotenv.config();
class Tempesta extends Client {
constructor() {
super({
intents: [
"GUILDS",
"GUILD_MESSAGES",
"GUILD_MEMBERS",
"GUILD_INTEGRATIONS",
],
});
this.login(process.env.TOKEN);
}
}```
how do i run that class without exporting it
Use it like any other class? Create an instance of it?
const bot = new Tempesta();
And make sure you require whatever file uses that class.
like ion wanna make it as a module yk
class Tempesta extends Client {
constructor() {
super({
intents: [
"GUILDS",
"GUILD_MESSAGES",
"GUILD_MEMBERS",
"GUILD_INTEGRATIONS",
],
});
this.login(process.env.TOKEN);
}
}
new Tempesta();``` anyway to run it without new tempesta();
Well, what do you mean by "run" in this context?
You want to "make it like a module", but not export it?
Which is how modules are used.
actually nvm im not sure yet
don't use a class
90% of the classes people who ask questions in this channel write here don't need to be a class
if you have a class with just a constructor or a constructor + 1 method, your class is doing nothing
Classes in js/ts are usually more or less meant for tracking state within an object, since everything else can just be done with a function more easily
Just make a function called start or something and have it do the work for you
damn
best formatting ever

indentation moment
I better not be the only one to immediately gaze away from code formatted like that
our eyes are programmed like that
How exactly does passport attach the user prop to the session?
is it just
<Request>.session.passport.user = {...}
because you're using a colon instead of a semicolon.
it goes both way if i do semi colon it asks me to use :
then can you show your code but without that hovering thing in the way
pretty sure the issue is the colon but might as well see
forget about it lol
that was my side project either way
btw is quart built on top of flask ?
I don't think it uses Flask as a dependency
but it does expose the same api structure
You can use it like Flask
wym
?
Referring to Quart
ohh btw you know how to do a redirect uri
No
ohh alright ig ill figure it out
all slash commands on my bot are just gone now
changed nothing
just disappeared
help
Thanks for providing context
yay got my http client working, and sending multipart multiple attachment π
https://cdn.discordapp.com/attachments/825411104208977952/941142977022156880/unknown.png
dpp::multipart_response multipart = dpp::https_client::build_multipart(
"{\"content\":\"test\"}", {"test.txt", "rick.jpg"}, {"ABCDEFGHI", dpp::utility::read_file("rick.jpg")}
);
dpp::https_client c("discord.com", 443, "/api/channels/907951970017480707/messages", "POST", multipart.body,
{
{"Content-Type", multipart.mimetype},
{"Authorization", "Bot " + token}
}
);
decided to replace the http library im using in my lib with something simpler i can maintain, e.g. my own code.... cant maintain a third party header only lib or debug it π¦
How can i ge that --config option into a docker compose?
$ docker run --name some-mongo -v /my/custom:/etc/mongo -d mongo --config /etc/mongo/mongod.conf
i'm not sure what option if any compose exposes for it
that syntax def needs a factory tho
@slim heart no way to pass it into the container via env?
either that or have a shell script in your container that launches mongo, and the shell script as the init of the container
that shell script can have the --config parameter
well yea
i can just make a Dockerfile if i wanted to
but im hoping to just keep it in the docker-compose if i can
How can you find the mem usage on python project?
Is there a way to remove all buttons from a message?
components: = row
I assumed I could just do row.components = [] then just edit the msg with it being an empty array but it does say components[0] is a requirement.
"components[0].components: This field is required",
.edit({ content: "No component", components:[] })
Are you sure you're supplying an empty array for the action row's components?
Ah. I mean that does make sense. 
yap. All g I'll do what Tyrone said. Mucho easier.
Isnt that the same what klay asked 
I mean. Also true.
But I was doing something like..
curPage.edit({embeds: [pages[page]], components: [row]})
But it just makes sense doing components: []
smooth brain moment
well yeah if you wanna remove all components, making the components as a empty array works. But if you wanna remove a specific button/select menu or an action row (when you have multiple) you gotta be a bit more specific
Ya was just a simple "press button -> remove all buttons, keep message" thing
wasn't thinking too smart with that question
ahh alr
Is there a python package for something like canvas for node?
Probably, all langs have some kind of graphical lib
By graphical I mean rendering images, not GUI
Yeah ik but i cant seem to find any :/
Quick google search yielded this https://pythonawesome.com/pixie-a-full-featured-2d-graphics-library-for-python/amp/
Idk what do u mean "couldn't find any"
Just type "python drawing lib"
Well i didnt know what to search for something like that lol
Thats a gui for app man
Pill?
Pill as in Pillow lol
N is that the best one out there ?
Im guessing it is the best one looking at the number of downloads
yes it is
pillow as in body pillow?
ππ
Cant tell if thatβs a genuine question or you just messing with me
pill as in medicine
...yeah... medicine
drugs
tf is bluepilled
someone on reddit says:
Redpilled: Describes someone who is seen to be, or who thinks themselves to be awakened to the truth of reality and the way of the world.
Bluepilled: Describes someone who is seen to be ignorant of the way of the world, or who chooses an insular perspective of life.
zoomers are weird
bro im boomer even though im zoomer
@quartz kindle Figured you might be the go-to guy for this
JS
I'm currently using array.reduce to get values of specific keys in an array of objects and combine them. Is this by far the most optimized way, or is there something else I can do?
I believe so since this is the documented way to do something like this
don't think you'll get any better performance not using it
What about a for loop?
that's probably how reduce works under the hood, a simple for loop which calls the function you provided with two elements and a sum
from reading a bit on it online on bigger amounts of data reduce wins slightly and on smaller amounts of data a for loop will win
but yeah Tim will know more about this
AFAIK reduce uses a special algorithm that I forgot the name of
so it's should be faster than a for loop
it does but benchmarks show otherwise
it all depends on how you implement the reduce method you pass to it + size of data
hence "should". for loops are part of the control flow and it may get optimized by the JIT compiler, while reduce probably doesn't
js is really confusing with benchmarks
mainly because of JIT optimizations. That's why benchmarking doesn't really matter that much unless the numbers are drastic
As long as the time / memory complexity is the same you shouldn't be worried
on bigger data those numbers can definitely become noticeable
if the time complexity is the same I doubt there would be too big of a difference
js engines do a ton of optimization on array methods so I find that hard to believe
if you're worrying about micro-optimizing loops in js you've already gone down a dark path
I find criticising performance and finding improvements even if it is tiny to be a good habit
though im not one to speak i optimise things in terms of clock cycles not milliseconds π
loops are part of the control flow, while reduce function calls are expressions. Same reason why if statements are faster than the ternary operator. Of course this performance increase is minimal and you shouldn't care about it unless you're writing speed-critical code in javascript
uhh what
source: dude just trust me
a js engine has the ability to optimize expressions too. These optimizations don't take place on the source code level
there's nothing that makes an if statement inherently faster than ternaries. The implementation might be different but statement vs expression has nothing to do with it
they're also not only ahead of time either. V8 will optimize and de-optimize certain parts of your code during execution depending on different factors
I think it's good to think about but people forget that optimization often comes at a cost to the codebase itself. Making your JS code run 10 microseconds faster but making it 3x harder to read isn't a great tradeoff in my eyes
yeah it depends on the environment
besides optimising an interpreted language too much won't usually lead to expected results
mfw im asking about branchless programming in a language with 300 levels of compiler abstractions
i don't even know how reduce works
starting value
start loop
starting value += value
return starting value
real and valid python code
meanwhile im spending days microbenchmarking my serializer
with multiple ways of doing the same thing depending on the size of the data
nothing beats for loops for small data, except a gazillion ifs
and bigjnts are stupidly slow
also math.pow and the ** operator are both stupid slow
I've never needed to use powers in code
the closest to that I needed to use is bit shifting which is very fast
did I forget to mention bit shifting is a native instruction in the CPU architecture that takes less than a single clock cycle to complete
yes bitshifts are fast, but they are terribly slow on bigints
and in js shifting is limited to 32 bit on non-bigints
everything in js is slow ain't it
how much of mdn have you memorized
How does your serializer work?
is it open source?
not yet
gonna release soon
example:
{
int: 40510349,
float: 26107.14072,
boolean: false,
null: null,
string: 'kjcjtegkfptayfvxhpoh',
string2: 'uqmtfxykba',
emptystring: '',
zero: 0
}
``` this object takes 145 bytes in json, 108 bytes in messagepack, 103 bytes in mine
and its twice as fast as JSON.stringify() on average
Interesting. I'm not really familiar with messagepack, does it keep the keys?
no messagepack doesnt
it supports extensions tho
so the user can create a messagepack extension to store keys
Tim gonna rewrite JS into JF because the S stands for slow
yours doesn't too I assume?
mine has built in support, disabled by default
also supports sharing context
so it keeps keys remembered across packs and unpacks
I see, that's cool
also supports object references
So like, you have the same object in 2 places, one place is the original and the other just points to the original?
yup
only works with actual references tho, doesnt work if its two different objects with the same content
ie js { a: {}, b: {} } vs ```js
o = {};
{
a: o,
b: o
}
second one will store the reference, first one will not
my bot got denied how to appeal
You dont
well what did you get denied for
Why would the first one not?
Curiousity time
thats a no no
How can i do that when i want to create a new document using a schema in mongoose, if i dont fill something it auto-fills it with, for example ""?
Im trying to do this something: { type: String, required: true, default: "" }, but keeps telling me ValidationError: Text validation failed: something: Path 'something' is required.
because objects are differentiated by reference:
{} === {} // false, two different objects
let x = {}
x === x // true, same object
it would be very expensive to transverse an object and compare every single property
but checking if its the same reference is fast
someone knows about this?
I see
just dont make it required lol
if its required, it cannot have defaults
defaults are only for optional things
I'd suggest making it optional, but don't use an empty string as a default since that mimics null
Alright, thanks to both!
is it possible to change .setFooter("//") to .setFooter({text : "//"})
without changing in every file
djs
You could overwrite the prototype for MessageEmbed
But it's better to just replace it in every file come on now
How do you collect a response from a select menu?
const row = new MessageActionRow()
.addComponents(
new MessageSelectMenu()
.setCustomId('select-' + otherDID)
.setPlaceholder('Select the winner')
.addOptions([
{
label: rows[0].name + ' won',
description: 'Select this if ' + rows[0].name + ' won.',
value: message.author.id,
},
{
label: rowse[0].name + ' won',
description: 'Select this if ' + rowse[0].name + ' won.',
value: otherDID,
},
]),
);
component collector, or awaitMessageComponent
Ah just saw the djs guide ty
is there anything resembling keyword arguments in slash commands by any chance?
For collectors, how would I collect a select menu without waiting?
const filter = i => {
i.deferUpdate();
};
message.awaitMessageComponent({ filter, componentType: 'SELECT_MENU', time: 60000 })
.then(interaction => interaction.editReply(`You selected ${interaction.values.join(', ')}!`))
.catch(err => console.log(`No interactions were collected.`));
I don't want to use a filter, but rather just wait for a response infinitely.
how can i wait for the result of event listener inside a function ?
with a promise
you want anyone to be able to respond?
Yes.
Okay. Thank you!
But for a collector, won't time: 60000 not allow anyone to respond after 1 minute? Or could I just remove time entirely?
this function, but without waiting for the output, it continues the codes in the folder where I use the function
how do I stop logging errors like this
fix them
here it doesn't expect the result even though I use promise
show where you use the function
what does console.log(gender) log?
undefined
what is chunks?
extremely bad idea
what if 100 people use the command
you'll have 100 listeners infinitely waiting
still a valid gender 
Unfortunately it is in 2022
This will only be run every once in a while. I only need 1 select menu anyways
const filter = () => true;
message.awaitMessageComponent({ filter, componentType: 'SELECT_MENU' }).then(interaction => interaction.editReply(`You selected ${interaction.values.join(', ')}!`)).catch(err => console.log(`No interactions were collected.`));
Also, upon selecting something from the menu it logs "No interactions were collected".
console.log() value where I use the function comes before console.log() inside the function
well that's fine
for polls, giveaways or other stuff you can have infinite listeners
console.log the err in the catch block
π
which one of them
Yeah that's essentially what I'm doing
where I use the function comes before and the output is undefined
but the console.log() value inside the function comes later and the output is correct
which one of them
you have many console.logs
i dont know which ones youre talking about
show your console output
Ah.
Error [INTERACTION_NOT_REPLIED]: The reply to this interaction has not been sent or deferred.
at SelectMenuInteraction.editReply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:138:48)
at /home/container/index.js:256:107
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
[Symbol(code)]: 'INTERACTION_NOT_REPLIED'
}
this line 75
this line 22
Seems like you never even sent a reply in the first place
what about this
the property is named Gender instead of gender
is this in your logs?
i => i.deferReply()
without {} should work
my function is to combine audio files
and here it shows which files it has merged
but is that in you logs?
thats the problem
your promise only kicks in when chunks is empty
what about when chunks is not empty?
your function starts a bunch of things and returns undefined
yes after merging all files already console.log("Finished" )
I don't think there is anything wrong with that part.
there is
because the function output is correct but when I use the function it jumps to other parts without waiting for the result
because your promise only works if !chunks.length
Well it looks like it defers, but nothing gets sent.
const filter = (i) => i.deferReply();
message.awaitMessageComponent({ filter, componentType: 'SELECT_MENU' }).then(interaction => interaction.editReply(`You selected ${interaction.values.join(', ')}!`)).catch(err => console.error(err));
No errors are logged either.
EDIT: When I delete the channel, the console gets spammed with:
Error [INTERACTION_COLLECTOR_ERROR]: Collector received no interactions before ending with reason: channelDelete
at InteractionCollector.<anonymous> (/home/container/node_modules/discord.js/src/structures/Message.js:533:21)
at Object.onceWrapper (node:events:514:26)
at InteractionCollector.emit (node:events:406:35)
at InteractionCollector.stop (/home/container/node_modules/discord.js/src/structures/interfaces/Collector.js:197:10)
at InteractionCollector._handleChannelDeletion (/home/container/node_modules/discord.js/src/structures/InteractionCollector.js:206:12)
at Client.emit (node:events:406:35)
at ChannelDeleteAction.handle (/home/container/node_modules/discord.js/src/client/actions/ChannelDelete.js:30:14)
at Object.module.exports [as CHANNEL_DELETE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/CHANNEL_DELETE.js:4:32)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:345:31)
at WebSocketShard.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:443:22) {
[Symbol(code)]: 'INTERACTION_COLLECTOR_ERROR'
}
yes after merging all files the chunks value is empty and terminates the function
no
the function terminates before it even starts
the rest of the function is executed asynchronously
when the function runs, the value of chunks is not empty
exactly
if chunk.length exists and is bigger than 0, your function runs this:
and then returns undefined
there is nothing there to make the function wait
you create an "end" event listener, then return undefined because there is nothing else to do
it's not my intention to make the function wait here
line 21
then the function will always return undefined
but the output of console.log(gender) value inside the function is correct
yes its correct
the function is already terminated when you get there
because you dont make it wait
so what should i do
if you want to make the function return the value
you have to make the function wait for the entire process
starting with the .on("end")
let me try
also, why do you need chunks to exist outside the function?
can i use it like this π³
aaah this google translate is so bad
can I return anything ?
i changed it like this
no
res(client.appendFiles())
otherwise the function returns "Finished."
not the result
okey I understood it
I'm trying to collect the response to select menus, but the interaction gets deferred with no response.
const filter = (i) => i.deferReply();
message.awaitMessageComponent({ filter, componentType: 'SELECT_MENU' }).then(interaction => interaction.editReply(`You selected ${interaction.values.join(', ')}!`)).catch(err => console.error(err));
No errors are logged either.
try const filter = (i) => i.deferReply() && true;
Error handling request
Traceback (most recent call last):
File "/home/container/.local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
resp = await self._request_handler(request)
File "/home/container/.local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
resp = await handler(request)
File "/home/container/.local/lib/python3.8/site-packages/topgg/webhook.py", line 132, in _bot_vote_handler
self.bot.dispatch("dbl_vote", BotVoteData(**data))
File "/home/container/.local/lib/python3.8/site-packages/topgg/types.py", line 279, in init
super().init(**parse_vote_dict(kwargs))
File "/home/container/.local/lib/python3.8/site-packages/topgg/types.py", line 19, in parse_vote_dict
query_dict = {k: v for k, v in [pair.split("=") for pair in query.split("&")]}
File "/home/container/.local/lib/python3.8/site-packages/topgg/types.py", line 19, in <dictcomp>
query_dict = {k: v for k, v in [pair.split("=") for pair in query.split("&")]}
ValueError: not enough values to unpack (expected 2, got 1)
why does this happen?
i was expreimenting with /vote?info
code
@commands.Cog.listener()
async def on_dbl_vote(self, data):
member_id = data["user"]
#tquery = data['query']
#currency = qurey['currency']
channel = self.bot.get_channel(939966852157820999)
# if currency == {"TPET"}:
reward = random.randint(800, 1000)
embed = discord.Embed(title = "Thank you for voting!", description = f"<@{member_id}>, your reward for voting is: ||{reward}$TPET||")
embed.set_footer(text = f"Member ID: {member_id}")
await ecomoney.update_one({"id": int(member_id)}, {"$inc": {"bank": + int(reward)}})
await channel.send(embed=embed)
await channel.send(f"<@{member_id}>")
# elif currency == {""}:
# reward = random.randint(800, 1000)
# embed = discord.Embed(title = "Thank you for voting!", description = f"<@{member_id}>, your reward for voting is: ||{reward}$TPET||")
# embed.set_footer(text = f"Member ID: {member_id}")
# await ecomoney.update_one({"id": int(member_id)}, {"$inc": {"bank": + int(reward)}})
# await channel.send(embed=embed)
# await channel.send(f"<@{member_id}>")
print(f"Received a vote:\n{data}")
client.user.id does not exist before the bot is logged in
Well, now it sends an error
``
Error [INTERACTION_NOT_REPLIED]: The reply to this interaction has not been sent or deferred.
at SelectMenuInteraction.editReply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:138:48)
at /home/container/index.js:256:107
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
[Symbol(code)]: 'INTERACTION_NOT_REPLIED'
}
Even though it defers
filter = async i => await i.deferReply() || true
π
That works! Ty
Okay so I have been working with discord bot maker and I was wondering if it is possible to make a feature where people can create a voice chat then manage how many then after this they have full control via commands from the bot but they will be able to add people remove people set a limit change the name of the voice chat mute and deafen people and move people to their voice chat.
Is this possible also wanted to know if I am able to make like the bot automatically do things after a command. Like auto support for certain things.
don't use a maker then.Diy,Learn how to code and it will be much eaiser.The Platforms are really shady
discord bot maker is fine
and bot makers in general since they make the process easier
they tend to bite you back later on
hence they're easy
for many people, what it can do outweighs what it can't do with the bonus of not having to learn an actual programming language
my little idea of automating a chromium instance to totally not have a selfbot streaming
is not working out well
discord wipes the localStorage object from the Window
so you can't insert a token field to be logged in
trying to find a workaround
sure, i can input the login creds
but then you encounter a captcha
i'm going to get an aneurysm by the time i'm done with this
I'll set up an appointment with your therapist for you
Cant you just like, use the web app?
and then just manually log in first?
or do you want to automate that as well
want it automated as well
ah fairs
i had a dumb idea to totally not have a movie streaming selfbot
so that's my motive right now
just run it and it worksβ’οΈ
i think i'm going to skip over the login part and come back to it later
just want to see if it's possible to stream a movie
if the discord client can do it a bot definitely can 
self bots are the discord equivalent of the dark market
i love it
self bot is not the actual bot right?
meh i just use an old version of djs which still supports user clients whenever i want to play around
well depends on your definition of bot
....
i'm genuinely surprised discord still didn't kill off old gateway versions as their measure to prevent selfbotting
also another fun fact
users cannot send rich embeds anymore
they're not doing too much to stop them
what a fun fact
`` js
for (const key in de){
console.log(de[key])
}``` how do i only log this 20 times only?
you mean run the loop 20 times?
Like done in a for in, with a let variable
well, te de[key] contains 82 entries, i am trying to get the 20 first only
do it exactly like that, just index de with that number variable
oh
instead of using for in i would use a for i = 0 loop since you dont need to worry about implementing the i variable and increments yourself
plus its faster
owh wait what
but how would i simulatenously use a const to loop in the de file
const keys = Object.keys(de);
for(let i = 0; i < 20; i++) {
console.log(de[keys[i]])
}
or
let count = 0;
for(const key in de) {
if(++count === 20) break;
console.log(de[key])
}
This would be more proficient i would say. Thank you tim!
Going crazy
for (const key of Object.keys(de).slice(0, 20)) {
// stuff
}
π
funny how every time js releases a new feature, its slower than the old way of doing that feature
Hey, if I had an object like so:
let lb = {"user1":355,"user2":45,"user3":124,"user4":567,"user5":12}
How could I "sort" it so that it would turn into:
{"user4":567,"user1":355,"user3":124,"user2":45,"user5":12}
(javascript)
objects are unsorted, you cannot sort them
unless you convert them to array or Map
hm, okay
if you want to display it somewhere in a sorted way, you can sort the object entries
Object.fromEntries(Object.entries(lb).sort(([,a],[,b]) => a-b));
``` 
that basically does nothing lul
Numbers are ordered first, and they are ordered within themselves from smallest to largest as long as they are >=0 (see below for more details)
Strings come second, and they are ordered within themselves by insertion order
Symbols come last, and they are ordered within themselves by insertion order (note that we didn't use symbols in this example)
Can someone help me with this please?
interactions dont have MessageComponentCollector
What does they have then?
if maps were ordered you'd not have O(1) access time
I mean, pure maps not maps backed by arrays
Now its
it did the thing in my end 
New js lib is so complicated π₯²
which new lib
π§ Except it aint
oh are they talking about djs
it really isn't lol
working with djs is like playing with legos
everything that's intermediate and beyond in difficulty is done for you
i.e. collectors
Yuh i havenβt coded js for like 2 years n now Iβm back at it is pretty much like whole new book to read
channel is undefined
well hash tables are actually ordered in a way
but the order is based on the resulting hash
or just keep two indexes, which is basically what Map does
one hash index for access, and one key index for order keeping
Hello my bot has 5,200 servers and 5 clusters, I create a MongoDB connection for each cluster (like first cluster connects to db then second cluster connects) is this wrong or should i just create one connection?
For all clusters
how would you even create a single connection for all of them?
i'm wondering about that too lol
Dedicate database backend 
you still need multiple connections to the backend lul
Using the same socket which does require one system
well, techinically its still multiple connections over the same socket lmao
hear me out
make a dedicated cluster that has the connection to the db
and the other clusters can send data to that cluster to contact the db
Which does require multiple connections to the database request handler
Not really much of a difference to multiple database connections
i regret to inform you that you are wrong
That's essentially the same I said
Be quite, you suspicious OS dev!
(β―Β°β‘Β°οΌβ―οΈ΅ β»ββ»
this command works in my server but crashes the bot in others and in dms, why?
tsk tsk, deleting question is not cool
still, someone might have a similar question but too shy to ask
that's why stackoverflow works, imagine if people deleted solved questions
node crashes on uncaught exceptions
that's an expected behavior, you should catch everywhere where things might fail
in this case, I imagine it's because the bot can't speak in the channel
then well, show the error
there's not much I can say when supplied with only 3 lines of code
in dms, in server, and in my server
if so it does not explain the dms but yes i think so
well, that's what the error says
the dm one should work then
"should" is a bold assumption
user might have closed dms or blocked the bot
in which case it'd fail
add a check before you send the message
add a check before you send the message
no it's my own dm
add a check
this is probably why it does not work in dms interaction.channel.send('Pong').then (async (resultinteraction) =>{
it says Cannot read properties of null (reading 'send')
^
hey so when my bot errors on something i want it to respond with an ephermal message with the error
how would i do this
pls ping with response cuz i go sleep thanks <3
Why tf do you send a channel message as interaction response?
That will let the interaction fail
Respond by using reply() on your interaction object
Anyone know best uptimer site ?
how can i convert [object Promise] in result
resolve the promise by awaiting it
ho
how
app.post('/dblwebhook', wh.listener(vote => {
let response = fetch(`https://discord.com/api/v9/users/${vote.user}`, {
method: 'GET',
headers: { Authorization: `OTM4Masdasto`}
})
fetch(URL, {
"method":"POST",
"headers": {"Content-Type": "application/json"},
"body": JSON.stringify({
"content":`${response}`
})
})
.catch(err => console.error(err));
console.log(vote.user)
}))```
in this method how can i
Look up async/await in js
You aren't awaiting the fetch so response is a Promise object instead of the actual user data
Got it
if (interaction.isButton()) {
switch (interaction.customId) {
case "cookie":
if (interaction.guild.id !== "GUILD_ID") return;
break;
default:
return;
break;
};
};
How can I not return but break out of the if statement and continue the code?
just remove the return keyword
I want to break out of the interaction.isButton() statement.
yes... remove the return in the default, actually you can completely omit the default
and put your code outside of the interaction.isButton() if statement
You can completely remove the switch if that's the entire code:
if (interaction.isButton() && (interaction.customId === "cookie" && interaction.guild.id !== "...")) return
maybe you could try labeling it.
Like this:
label1: if (whatever) {
switch (your_case) {
case "foo": return label1; break;
case "bar": break;
}
}
I've never seen labels before.
because they're useless in js
emphasis on in js so kuuhaku doesn't give me a five hour lecture on their importance in java
What do labels do?
break an if statement without returning the entire function
labels
PREPARE FOR THE LECTURE
Oh, it's good, then?
Did I cause this. π
label1:
if (condition) {
if (guard_condition) break label1;
//code
//code
//code
//code
}
//if guard_condition evals true, code will skip the rest of the block and continue here
//code
//code
//code
not only ifs, u can break any scope
pls for the love of god don't ever use this
if (condition && !guard_condition) {
// code...
}
Like a sane person pls
if (!guard_condition) {
// code
}
unnecessary indentation level
also how would you solve this case:```js
label1:
if (condition) {
//MUST RUN
//MUST RUN
//MUST RUN
if (guard_condition) break label1;
//code
//code
//code
//code
}
//if guard_condition evals true, code will skip the rest of the block and continue here
//MUST RUN
//MUST RUN
I am self hosting my bot, but it gets disconnected/ reconnected for no reason.
Is it common? Any recommendations on how to tackle this problem?
depends
discord does fart sometimes
but if ur getting disconnected very frequently there might be an issue
The problem only occurs with a private counting bot, even though I have a recursive function to run the bot client in case it crashes.
bot client in case it crashes
WHAT crashes?
the bot, as in the code still run
or the code itself?
break is useless when you return before it
also u cant return a label
you can return evil corp
This might sound vague but basically If any exception got raised when running the bot launcher.
The script will sleep for a minute then try to restart the whole process. [The errors are logged though.]
show the error
^
you can
switch (true)
{
// top to bottom judged by case priority
case <button>.isUrMom(): return ur_mum;
//...
}
Lol, no reason. π
you didn't log it
that is a very confusing example
show the code that prints that
you have a code that MUST run before reaching the guard, and code outside the current block that also MUST run
Holy.. you guys still arguing. π
@feral aspen
@lyric mountain you know what
i don't know
you go help me doing codewars
loop1:
for (let i = 0; i < 5; i++) {
loop2:
for (let j = 0; j < 10; j++) {
break loop1;
}
}
:)
codewars?
just use functions you evil villains
cod wars
I will make this code as difficult as possible to understand
i will just use js
This is an alert when the on_disconnect gets called, any leads on how to log the causes of it?
does it happen frequently?
there is always an argument of the emit
it's python so idk
No, 3 times a day mostly.
Worthy to mention that on_ready does not get called though and the bot do not go offline.
@earnest phoenix hopefully this has convinced you that labels are like school, useless most of the time but useful at times
on_ready probably shouldn't get called on reconnect anyway
there's an on_reconnect
I do not think there is in Python wrappers.
loop2 wouldnt need a label tho
but ye, for escaping nested loops it's very useful
listen to on_resumed
if you get an on_resumed everytime you get an on_disconnect, then its normal
most libs handle disconnects fairly transparently, unless u disabled auto-reconnect
@solemn latch
@solemn latch
on_resumed, will try this. thank you for your help.
Got it, thank you.
what the dog doin
banning nitro scammers
@quartz kindle by the way make sure to participate in the next code wars next time
what code wars, i suck at them
they keep asking to solve weird shit like ciphers and cryptography
The Cod Wars (Icelandic: ΓorskastrΓΓ°in; also known as LandhelgisstrΓΓ°in, lit.β'The Wars for the Territorial Waters'; German: Kabeljaukriege) were a series of 20th-century confrontations between the United Kingdom (with aid from West Germany) and Iceland about fishing rights in the North Atlantic. Each of the disputes ended with an Icelandic vict...
nice
iceland and uk fighting for fish
agreed
What do you call this function?
(() => {
console.log("Hi")
})();
bad code
An IIFEβimmediately invoked function expression
what why
It's just useless in this context
but we can use it to run await 
i hate doing desktop apps
the worst part of it is deciding which framework to go with
One message removed from a suspended account.
cross-platform, performant, easy to work with - pick 2 π
One message removed from a suspended account.
HEY
One message removed from a suspended account.
i left discord for a few months but i'm back now cause i'm in quarantine
i'll talk to you in general
One message removed from a suspended account.
You forgot "looks good"
a way to use top level await in nodejs

fun fact: hello world in powershell is Write-Host 'Hello world'
or just 'Hello World' 
yes
powershell can be very powerful tbh
way more powerful than shell script
watch me go #include <Windows.h>
You can't add javascript in your topgg page?
No
would be a huge security risk
dw
you can still track user IPs if you really want to
cuz lets face it, thats all we really use JS for now days 
No but I could steal your session Id and make request on your behalf if I wanted to.
Assuming Top.gg hasn't dealt with CSRF issues.
TBF I could make my site have a button that makes a put request to top.gg and assuming everything's stored in cookies it should work. 
"Click to join support server" -> Nukes your bot page
rumours from previous devs say topgg sells your data to google ads
I don't even know what data, it's all already there lol
wouldn't we at least need to show google ads for that lol
Right lmao
we had banner ads before, we don't now because they suck
the tracking is just the ad provider's way of counting impressions, google doesn't give you control of that when you want to show ads on your site
it do be
Xet blog when 
that dont look too good
Make sure to rest up king.
Blame everything on Ken
object Object will always have a special place in my heart from the counless times i tried to send an object in chat
what is chakra it looks cool
dont mean to make you panic but uh
yeah its just a once in a time thing
lmao
@woeful pike if you didn't know
also i think there should be an option to remove the gradient from the pages
dont know its just not doing it for me
maybe because of my screen size
I was playing around with some settings to prevent ddos :q
ahh alr
looks like I might have set it too low
testing in prod moment
Iβm in need of people asking simple questions so I can continue procrastinating thanks
Website is slow
what is an http request?
Good question
(I may be trolling)
The noun is request, and the adjective describing it is http, therefore itβs an http request
Np
I dont think a better answer exists tbh
π seo is annoying
https://i.woo.pics/e5d1e24b3a.webp
https://i.woo.pics/cc4d9fabb4.webp
how do I add more pages for a one page website 
https://i.imgur.com/jNKQhxA.png
Lmao
Ironically Iβm sitting in a βweb designβ class that has taught me nothing a 5 minute google search couldnβt teach me in the last 6 months
Yup
Havenβt even started with js
Literally just html, small amount of css, and some graphic design stuff
π
I took this class thinking I might actually learn something
I suppose I was wrong
sadly thats how it goes
Yeah
My computer science class isnβt really useful either
It would be useful if I didnβt know anything beforehand but unfortunately itβs just things Iβve already learned
Hopefully my data structures course next year will be different
unfortunately probably not
at least compared to what you run into in the real world
Imagine a society where you didn't need a degree from your school to get a job
The only thing I learnt from my computer class is not to open Excel on a windows 7
I feel like you're getting into comparing software engineering and computer science.
People go into CS expecting to get a SE degree.
yeah they tend to go "oh well I want to work in software"
and then they come out with a CS degree thinking they know everything about how SE works and what it involves
unpopular opinion
coding is the easiest job because there is an undo button
when in reality they know nothing and their code quality and team work is awful
Not an undo button for when you set the pacemaker to beat at 900bpm and not 90bpm
Uni doesn't really encourage working as a team at all. It encourages a competing with your coworkers which is a really bad way to do SE
Most CS programs that I've looked at look like they try to solve this with two "Software Engineering" classes. One's a basic class which introduces waterfall/agile tactics and the second one is generally a "Senior Design" thing where you work on a team to create a product and have to apply agile to meetings and find an actual customer for your product.
At least mine did that.
I've had a bit of downtime at work recently after coming off a project so I've been cleaning up some software the interns wrote
and their code is just
bad
in so many levels
Right. Some places don't teach good practices.
I'm so very much thankful I met amazing programmers at my uni. They helped me learn and guided a lot of us.
I'm so very much thankful tim exists
may God be with you my friend
armful br??
armful br!?!?
armful simp?
who
π
unironically who
Congrats on trial. Good luck
tyty
You're obviously going to beat the record, right?
obviously
Good BR.
what else would i be doing
Not doing queue I guess.
my strat is to keep queue at sub quota so no other brs can reach quota 
Good luck π
ty
jobs that require software engineers to have a computer science degree be like oooooaaa
i dont think you'll come out with the greatest quality of code
i dare say universities are largely a pointless money grab nowadays
all resources you need to get started on a topic are on the internet
there are also some great online tutors and classes for a small price compared to a degree cost
the only incentive to go to university is to get a "globally recognised degree"
computer science isn't programming. It's kind of ridiculous that one is seen as a pre-requisite to the other
you actually have a point
if you wanna learn more about how computers work, the science behind it, math theory and stuff yeah that's cool. Go do a cs degree
cs courses have an element of code to them
but for a company to ask you to know cs theory to make websites and stuff just seems a bit crazy
a large chunk of credit is due to code
kind of can be compared to "knowing how every component of how a car works" and "knowing how to make a car from scratch"
should a racecar driver know how cars work? It would go a long way to showing how dedicated you are I guess but do is it required to be a competent driver? idk probably not
how computers work
only for softwares
It's because you're dispensable
for hardware it's CE
I mean that's half of CS
imagine needing a cs degree to work with photoshop
there's value in a lot of what you learn in a cs degree (I imagine lol) but the fact that it's an industry standard for hiring is stupid
people are very quick to get a degree and know they 100% want to go to university but me not so much
trust me, majority of people don't know wtf they want to do or why they're going to university
it's just "what you're supposed to do"
my school also heavily encourages and only talks about university probably so they can make claims like "90% of students got into their first choice university"
Yeah 90% of schools are like that
its a huge debt gamble
me running a school with the headline of "50% of our students decide to drop out to pursue the thing they're really passionate about"
what if you also drop out half way through
you're still stuck with a debt, less significant but still large
I spent thousands on college and dropped out 3 years in. Thankfully it was community college so I didn't go into any debt at all
huge W
nice
im in a kind of community college equivalent in the uk
sixth form
will never turn down a free qualification
yeah I have an associate's degree now too, dropping out was one of the best decisions I've made
I learned so much more than imaginable compared to what I would've if I stayed in school
im more inclined to get an apprenticeship, you get paid, learn, get a degree (maybe) and work free of charge
internships are good if you can find a decent one
Apprenticeships are even better 
not sure what the difference is
i live close to a GCHQ headquarters and my teacher has contacts there so some guy apparently wants to come down to talk to me from there
probably the best option
Generally Internship implies either temporary with no real progression and / or it's not paid
I lived 5 mins away from blizzard headquarters 
also Apprenticeships generally give a degree with it
so you get paid + get a degree anyway
oh? interesting
co-ops
From what i've heard from ~people~ they treat you like shit
yeah it all depends where you get one tho
that doesnt sound good lol
but is it still worth it
i mean no
if your treated like shit and dont like what you're doing then dont do it lol
there are tons of other opportunities out there
"GCHQ"?
There is a general saying that working for private cyber security firms are great, but government cyber sec sucks ass
UK Cyber defence / intelligence agency
garbage collector headquarters
Government Security is literally filled with braindead programmers that haven't had to code in 35 years lol
Sounds painful
Yeah it is.
basically what the vibe is from anyone i've talked to who's done it lol
No, working for intelligence agencies in general
interesting i'll keep that in mind
but yeah im not really into cyber security anyways
or programming so im stuck on what to move onto
like the next couple years are going to be really quite full of companies trying to employee tech people so it shouldn't be too hard to find somewhere to start
security is so fun
a different type of security
The amount of messages and emails I get from recruiters a day is mad
and quite annoying :(
Nah, it'll still be very difficult
CS is very competitive in most places and we know that
pretty sure its things like going through binary files and analysing how malware works
Unless you went to MIT
probably some pen testing too which can be fun
mmm in the UK right now it's kinda mad
At least in the US that's how it is
seems to be definite gap / more jobs than people rn
even on the junior jobs side
which is unusual because normally its too many juniors not enough seniors
i also see a lot of people using computer science as a kind of "lifeline" for a career
I mean its quite an easy industry to get into
Tons of HR people don't know the difference so it's pretty easy to get in with one.
If you're motivated enough and driven enough you can get into it earning a solid living without any past experience in the field or education in it
fake it till you make it actually works wonders, if you can pull it off
mfs getting a 6 figure job from watching indian youtube tutorials
i cant do it, my consciousness wont let me
there was a story about some dude who spent his entire savings to rent a porche and go to job inteviews with it, and he landed the best management jobs
Just move to San Fran and pray you have good connections
just because of the car
I enjoyed my CS degree. I think all the classes I took helped me form a way to think critically in more than just programming.
and to work out of desperation
The debt isn't that bad, especially with a programming job lol
i wonder sometimes, am i poor because since i dont have debt, i dont have motivation to work?
lmao
no, you're poor because you're brazillian
xD
unironically this
no way in hell im gonna work in brazil and get paid in reais
i wanna get paid in euros
or crypto
you're onto something
work for bitcoin
meanwhile, the president
he probably gets it so rarely he has to make a public statement about it
*80% conversion tax rate included
if you're heartless
hr literally eats your soul
only if im given motivation
*soulless
"what do you mean you cant be in 2 places at the same time while earning minimum wage??!!! YOURE FIRED"
be ready to be forced to follow gender and race quotas and be forced to hire based on heritage over skill level
:^)
also, if the boss asks you to hire his nephew, you better do it or you're fired
isnt that a border control simulator?
same thing
might work for innersloth idk
so that i can get leaks on among us 2
with mediocre unity code
my slightly shitty Figma ability :(
dude that logo still looks the same as last time and it sucks

