#development
1 messages · Page 84 of 1
What should the command structure look like.
But with the proper structure
Just name and description
My original command setup didn't have the data : {}
And options/choices etc. if needed
But I can't load slash commands into discord.
You don't need data as object
Also transforming the object to JSON via data.toJSON is useless as djs does it automatically anyways
It doesn't.
For me atleast.
And if it should, please tell me how.
I'm running on V13.
It does once you use the inbuilt methods not the rest handler
Even v13 should have them
Take a look at the example of the create() and set() methods
Hm. This documentation shows this as a command.
It seems so weird.
I'm so used to module.exports = {}
I honestly don't fully understand.
Trying to grasp it.
You either register one per one command one time or update (and replace) em all using the set() method
You can pass your array commands to the set() method
Remove the JSON transformation completely
And you can but you don't need to remove the extra data object
No need to wrap the command structure into another object
And make sure to only add the properties which are allowed
For your example just name and description
Yup, and the cooldown I'd assume under it..?
It still doesn't make sense to me really.
module.exports = {
name: "name",
description: "description",
cooldown: 999,
run: async(...)
}
commands.push({ name: command.name, description: command.description });
And so on
You need to differentiate between your command module and slash command command structure
Both are different things
While you use your module cooldown property internally in your command handler (somewhere) doesn't mean this can be part of your slash command structure which you sent to the api
To register the commands you simply create an array of objects that include only your command structure you wanna register/update
Nothing else
FakE out
💤
yeah get out
Shut up lazy Klay
lol
how would i create a messagecomponentcollector that is general bound to a certain channel and not necessarily a message?
I still don't fully grasp it. I really don't.
Even too lazy to explain your own point 
I think that one of the mods told me that i could use a createmessagecomponent collector without specifiying an actual channel
wdym bound to a certain channel
i am using the createMessageComponentCollector but some mod here told me that i didn't have to specify a message
So that it would become a 'general' collector
Tf
A message component collector collects only components used in that message
Alright
It won't push to discord.
commands.push({ name: command.name, description: command.description }); isn't being read.
Any other component used triggers your interaction event
I don't think.
Which includes the properties to identify and/or filter the channel
i see
wait let me find the exact message back
That's literally the name 
To identify a channel? Not specific.
Yet the command is a lockdown command.
You filter the channel for example by its id
Which is provided as property and part of the class
Fake, we'll talk tomorrow.
@solemn latch
I aswell need to go.
lol imagine pinging yourself to advertise
🤦♂️
get free wifi anywhere you go
I've never heard someone say "flick some bucks" before
Quality ads
Get more ram by downloading it here!
Fake, I friended you. I'm out.
Just ping me here
I don't accept friend invites anyways
Nope

let fake = client.users.cache.get("243443167704121344")
if(fake) fake.ban()
null since fake does not exist
Ha not cached

Ight
ominous ghost ping aka I've figured out what I was asking
I was going to suggest using a transaction
Hii
why hello there
you just sent a message so you are now cached
mentioning users also caches them
Shhh don't tell anybody
does anyone know a good formula for the sequence:
5, 10, 20 , 40, 80 etc etc
i have a xp integer
and want to be notified if it's bigger in any of these sequences
xp*2
lol
if xp > (xp*2)*2
if the current xp is larger than the xp for the next level after the current one
actually nvm
start=5
new=old*2

but what if the xp is within an already sequence (such as 45)
Will never get to 45
ohh yeah if they reset it on each notification
//im trying to add this too
const secondapi = "http://apisite2/" <-------- me trying to add this too
//working
$.get('http://apisite/' ,function(data){
$.each(data, function(i, item) {
blablabla
},'json');
hello im making html page with api fetching to display userinfo
my problem is i need to fetch one more data from another api site too. but i dont know how i can compile two
I found a recurrence relation already but thanks for the help!
\
ara[key][1].type === 'GUILD_VOICE'```I have this check in my code
but after running it will eventually tell me: cannot read properties type of null?
let channels = await interaction.guild.channels.fetch();
let mapped = 0;
let ara = await [...channels]
for(const key in ara){
if(ara[key][1].type === 'GUILD_VOICE' && ara[key][1].id !== vc.id && ara[key][1].members.size !== 0){
mapped++;
console.log(ara[key][1].type)
ara[key][1].members.map((member) => {
member.voice.setChannel(vc)
})
}
}```this is the whole code
i really don't know why it's fucking up
Try using for of since ara seams to be an array
The for in statement iterates over the enumerable string properties of an object
So try using for of and see if it works
Nvm you’re using for in correctly I’m stupid
So it’s saying that ara[key][1] is undefined right?
Or null
Try logging ara[0][1] before the for loop
bruh
:

@unkempt ocean hi
Fucckkkk
Dylan#1234 muted RiskerMadhavpro|YT#0388 indefinitely Reason: Emoji spam in #development.
RiskerMadhavpro|YT#0388 was successfully muted

const avatar = await client.users.cache.get(userid).avatarURL({ format: 'gif' })
hello, i have problem at this code.
if member doesnt in server and trying to catch avatarurl from
it gives "cannot read properties of undefined (reading, avatarurl)" error
how i can make system that if bot didnt fetched avatarurl then it replace with another image
use optional chaining (?.) and using OR (||) or use conditional operator with client.users.cache.get(userid) as the statement
can u give me example
const user = await client.users.fetch(userid)
user.tag or user. displayAvatarURL
i know these
i just need help
if avatarurl undefined how i can change it to another image
^
...
my problem is different
i dont know code so
for example im saying
const avatar = user.avatarurl
if avatar is undefined avatar=anotherimage.png
i need this code
const avatar = user.avatarurl || anotherimage.png
not trying to fully spoonfeed but here's the example that you need to adjust yourself
const avatar = user?.avatarURL || 'fallback'
these not work
Show what u did
I also don't think It's avatarURL, try using iconURL
its work
It worked?
You can put it In a try catch.
so im trying to make if bot cant fetch avatarurl then change image to another image
so error will not appear
Wont it be better to use null caching opperator tho? user?.avatarURL ?? fallback
i maked working system before but i deleted file so
I don't think It matters to be honest
my code before like to avatar == null then avatar= anotherimage.png
something like that
I did not Intend for It to sound like that. I meant like It doesn't matter which one you use.
What version of dj are you using?
Its what @pearl trail said but just cleaner
You can use ||
const avatar = await client.users.cache.get(userid).avatarURL({ format: 'gif' }) || client.guilds.cache.get("1033299353445605396").iconURL({ format: 'gif' })
this what i do
const avatar = await client.users.cache.get(userid)?.avatarURL({ format: 'gif' }) || client.guilds.cache.get("1033299353445605396").iconURL({ format: 'gif' })
was thinking about it but yeah still do "the same thing" 
why does this respond with { error: 'unsupported_grant_type' }? I copied from discord docs
Does anyone see anything wrong with my button pageinator? I used this exact code in v13 and it worked fine, but transitioning it to v14.5.0 I could never figure out why it would never respond.
https://hastebin.com/ijezadahik.js
The botton styles when I was originally trying to make it work were renamed appropriately to CapCase instead of all caps, this is just directly copy pasta'd from my v13 bot so changes don't reflect what I've already done.
You can read the guide for updating to v14 if you haven't. I used this to update my bot to v14: https://discordjs.guide/additional-info/changes-in-v14.html#before-you-start
Read the docs so you can see how to make buttons, how you are making them rn is the problem
iwth ActionRowBuilder, ButtonsStyles, etc?
Did you change action row creation methods?
Ya
well then is there an error
Let me just re-create my code again since I forgot I had changed more than just the style names. I recalled it not erroring, just not responding to button clicks.
One moment.
I must be overlooking something
https://discord.js.org/#/docs/discord.js/14.5.0/class/Message?scrollTo=createMessageComponentCollector nvm it iscreateMessageComponentCollector probably something to do wit this not being a thing anymore.
Ok
so just subsitute any "message.channel" as "interaction.channel" since it's the same thing in regards to how it works
Have you tried to check if the collector catches you at all?
I can log something sec
buttonCollector.on('collect', async (buttons) => {
//not reaching this part of the code
}
nope
Oh I think I see it.
const filter = (interaction) => interaction.user.id === message.author.id
Interactions don't have authors
Well
Wasn't it.
renaming every "message" to "interaction" to not confuse myself and changed the "const filter" part to just (i => i.user.id)
must be related to the event portion of the code because when the timer expires the buttons do get removed as it should.
Strange because if the collector does not fire at all, then there must be some problem with it, but it doesn't look like it
I have no idea either
It's strange because the timer portion of the collector is working, I know this because after 30000 milis it ends the collector and removes the [row]
so it has to be something with buttonCollector.on
What if you just gave up on this filter and just checked in buttonCollector.on() if it works for just anyone?
I can try that ya
I just don't see the option to add a filter
Or nvm it its
XD
A very strange situation
changing the filter to const filter = (i) => !i.user.bot just to ignore the bots, it still doesn't appear to work
Do you have the ability to toss this into some junk .js file to maybe help me debug the situation.
grandpappy fake is typing
Bots can not use components
Or interactions at all
Fair enough.
But should still technically work as a filter
which wasn't my original filter
Yes
I would, but I'm on my phone rn
But isn't actually needed tho
I know I don't have too. It was for testing why my bot wont respond to button clicks at all
sec I'll hastebin my changes
What, can't code and drive at the same time?
pathetic

But yeah essentially I console log within the event portion just before the switch case and it doesn't get to that point, so it's related to either the event itself or the code above it.
I would guess the filter component type is wrong
it was "BUTTON" before
Should be 2 (int) not button
oh really
Not sure if discordjs still parse this internally
There we go
1 min Support = 1 Hour = 120$
nah u get hug attacks instead im piss poor

_next time I'll take ur soul _
deal
(he doesn't know I don't have one)
https://scs.twilightgamez.net/g/vpJQd.gif also note they also changed .data.custom_id this portion from .customId
but ty again fake works well now I can get stinky emojis removed
When accessing the data property you will see the structure as the api sends it without the stupid transformation of djs changing all property names to camel case
aka the raw structure
which since it works fine it's like better aswell
This request has been blocked; the content must be served over HTTPS.
my website cant fetch data from my express.js api site
anyone know solution?
you just need to fix https or use http on source site depends how you got it setup
1-2 years ago i fixed this with
1-2 line code add to my express.js file
but i forgot
code adds allow to http etc
found this gem on SO this morning
if u looking for some mental exercise pls enjoy
What if you use regex?
Maybe that fixes it?
check the encoding
and no, definitely don't use regex for that
also, attach a debugger to it and see what is being passed to the check when it reaches that point
Im losing my mind, why tf is this for loop not looping?
const type = (url.type === 'STATIC' ? 'GET' : url.type)
pageDisplay += `[-] [${type}] ${url.array.join('/')}\n`
}```
content of `urls`:
```[
'GET/': {
file: './test/static/index.html',
array: [ '', 'index.html' ],
type: 'STATIC'
},
'GET/s.png': {
file: './test/static/s.png',
array: [ '', 's.png' ],
type: 'STATIC'
},
'GET/say/:word': {
array: [ '', 'say', ':word' ],
type: 'GET',
code: [AsyncFunction: code]
},
]```
why tf did that suddenly work
I swear I tried it before
but why doesnt of work?
typescript doesnt say anything about of not working, full intellisense available
What would be a good way to remove users from discord cache when a bot leaves the server? I’m aware of cache.delete but can you access the users of a server the bot left in the guildDelete event?
Like <img>?
Its <img> from the html code
okay thx
Probably
At work so i cant test for a few hours but having a rotating bot status it delete remove the guild count on leave but I noticed the user count didn’t change
So I’d likely have to get each user aslong as the bot doesn’t see it in another server and remove them from cache
Just google html img
Itll tell u how to use it
But no ur method is incorrect
could you show me an exemple please ?
I guess it would be possible because if you have access to everything else in this event then why not have server members
There u have everything u would need
Reason why is because the guild gets uncached on leave automatically so wasn’t sure
Ok it's good I succeeded thank you
it's not even consistent across languages
Ah ok
straight up github color scheme
I mean the new one is kinda better, the colors look more appealing to most people I guess
Yeah
<img src="Image_URL_here">
Try again 
Doesn’t that need a closing thingy
Nah browsers will parse any shit nowadays
It would be needed when going for html strict
There's another char missing
But in order to use the "right" syntax, yes you would also close the tag />
img tags don't have an enclosing tag, they don't need any
Correct that's why you close it inline inside the opening tag aka self closing
the problem with his thing is that he didn't do src="url"
ding dong you won the prize
If you respect the correct syntax then u gonna use the self closing tag or go to hell

We do not have an enclosing tag declared for such tags, such tags are to be used alone
Tf are u talking
I'm gonna force you to read through https://html.spec.whatwg.org/multipage/
There's no enclosing tag, yes
Have fun
Nobody except u is speaking about an enclosing tag
Or was
I'm talking about this
#development message
I might've misinterpreted what you've said
<img src="..." />
Ah I see
Yeah you misinterpreted this
Should have said self closing tag in the first place
Oh I see what you're talking about, yeah what you said is the original syntax and does work but the thing is that's what the syntax was, the / was made optional, strict modes don't even check for that
iirc strict mode creates a warning when the self closing tag is missing or not?
Or was it xhtml
Idk anymore
I think you're talking about something else, I've never seen it warn about that
Yeah maybe I'm thinking about something else
Idk
Doesn't really matter tho
If you respect the correct syntax then u gonna use the self closing tag or go to hell
Just states it's optional
react does need the closing tag otherwise it’ll throw an error 
Probably the same sort of discussion like using semicolons in JavaScript
who gives a fuck

Python users when you use even a single semicolon
javascript is better then python if you know what it can do
So true
When you spend 4 days making a program that then memory leaks because you didn't exit and it's left running for 3 days slowly taking more and more ram untill you find out
may not have done that
When you make a parser that just suddenly broke and then after 6 hours you find out you missed a continue statement
at lease i have ftp to not worry about breaking my machine
to be fair getting a server to put your "Development stuff" is very useful as your able to code that from anywhere if you Need
Hey Fake.
@boreal iron I didn't understand how this would fit into the code yesterday.
commands.push({ name: command.name, description: command.description });
This will push an object incl the name and description of your slash command to your commands array
That array will be sent to the api to register or update (all) your commands
That's it already
Alright. It is labelled as commands in my command handler.
This structure does only include the properties the api expects not your additional ones you need for your command handler
Since you removed the data object those properties name and description should be available directly after importing the module
If you wanna keep the command details inside the data structure then just edit the mentioned line
name: command.data.name, etc
command was the imported module in that case iirc
Just as personal tip, it might make sense to use more proper var names
client.commands = new Collection();
client.slashCommandFiles = walkSync(path.join(__dirname, '/SlashCommands'))
Yeah.. I know.
It's a habit.
Take this for example lmfao?
When importing the file I would call the var module for example,
const module = require(...);
As it is the entire module (structure) not just the command
Alright.
Confusing var names are a mess once u have to edit your code somehow and dunno what was what
Or wrongly names vars
But those are personal preferences
I still don't fully understand this. I've surprisingly never seen it before.
How does it find command.name
iirc you defined command as var of your imported command file
const command = require(...);
Here in index.js creates a collection.
Alright.
What would I require there though?
Yeah after importing your command file you gonna push the module (structure) to your array client.commands
(and use it later on in your command handler)
I didn't see you doing this in the code you sent the last days
All I saw was you creating another array called commands to push your slash command structure to
It's fairly simple and i would like to give you an example how it works but sadly I'm still working unexpectedly
And looking on various parts of shared code on mobile is just hell
Well your command files and you already have this part of code where you loop through your command files, filter em and import (require) em
Once imported you can use em in your code
// module module
module.exports = {
name: "test",
description: "Voltrex weird guy",
...
}
// somewhere over the rainbow
const module = require(module module);
module.name -> "test"
I just don't get why I have to go through all of this.
The commands automatically updated themselves.
And all of a sudden it didn't causing issues.
Well since you put your command in modules you have to
just wondering what the vote api checker is. because the bot is giving me errors when I try to access the api. top.gg/bot/{bot-id}/check?userID={user-id}
Then I got different documentation telling me two different things.
That's what I am doing.
I've gotten this far, not going back.
This is what my echo command looks like.
Very simple you see it in every bot.
U need to provide the api token and correct content type in the header of the request
the api request says voted={0} or voted={1}
I just need the default url. for the simple command
Yeah, so you're using modules for your commands and import the modules into your index (or whatever)
Alright.
Also notice the command option tYpe "STRING" does not exist
The api expects the corresponding integer
You can also use the (stupid) djs enums
Wdym?
That's what it is supposed to return, either voted or not
nvm, i just got the api link. top.gg/api/bots/{bot_id}/check?userId={user_id}
I'll cross that bridge when it becomes a problem.
I think I've gotten it hopefully down.
Yes.
I know I'm finding why.
I think I know.
description technically doesn't exist.
Would I do module.exports.description?
oh boy
Man i can't follow you I'm sorry
const command = require("./path/to/command.js");
It's hard to follow random code snippets and screenshots
then you can access the exports on it
Sorry, I do that.
const slashCommands = client.slashCommands = new Collection();
client.slashCommandFiles = walkSync(path.join(__dirname, '/SlashCommands'))
const module = require(module);
slashCommands.push({ name: module.name, description: module.description });
This is what I have in index.js
just saying that makes absolutely no sense
What would I do then. I don't follow half of what Fake is saying.
https://discordjs.guide/creating-your-bot/command-handling.html#loading-command-files look at this guide and adapt it to your code
should give you everything you need to set up a command handler
Makes me vomit
Sharing Links to the djs guide should be a bannable offense
It makes no sense though.
I don't use the SlashCommandBuilder.
This is like randomly learning how to use arrow keys when you've spent your life using WASD in games.
Yeah but you straight copied the rest methods to register the commands
Fact.
Which is already inbuilt into djs
But the fuckers at djs are too lazy or stupid to make a more reasonable and understandable guide for people who don't understand the registration process
if he's writing this, then the guide will help him understand what to actually do, then it'll be easier to help him
Copying and pasting that trash moves a lot of people into trouble we're trying to handle over here
at the moment it seems like he does not understand what require does, which is a whole different topic than just making a command handler
Yeah I already noticed
Require I believe reads the files.
And allows you to export them.
Atleast that's what I've been taught.
it loads js files
if you truly understood what it did, you wouldn't be writing const module = require(module) lol
I wanna use the term imports them
reject import, return to require(...)
hey
hi
That's not differently... that just doesn't make sense...
So I'm being told the actual things from Fake, while looking at shitty docs.
I'm just confused.
module as a keyword (in cjs projects at least) usually refers to the current file
module.exports can be used to specify what should be exported from the file
if(points1 == points2){
collector5.on("collect", async (i) => {
if(boolhit1 && boolhit2 || !boolhit1 && !boolhit2 || !done){
.... }) } ```Does anyone know why this collector is only collecting once? I know it's because it's a regular if statement, but wrapping it in a while would seem pretty bad..
Well you said before you throw anything into your big index file and don't wanna use modules, after this you sent the screenshot of your command module (file) and said this is what u do which means you didn't really know what it means as you said he opposite before
I didn't know that, thank you.
That's true. I'm confused, don't know what a lot of terms mean so for some things I just pull something out of my ass.
For example: ```js
// In file.js
module.exports = {
name: 'Something',
description: 'something else'
}
// In index.js
const something = require('./file.js');
console.log(something.name); // Something
console.log(something.description); // something else
Well the guide actually shows correctly how to use modules and import them but not really how you handle the registration
So the link Waffle shared is okay
Regarding modules
Saving the slash command structure and registering it is a different story
This example probably just helped me so much down the road.
It's way harder to understand than his to me.

const fs = require('fs');
const path = require('path');
var walkSync = function(dir, filelist) {
files = fs.readdirSync(dir);
filelist = filelist || [];
files.forEach(function(file) {
if (fs.statSync(path.join(dir, file)).isDirectory() && file != "subcommands") {
filelist = walkSync(path.join(dir, file), filelist);
}
else {
if(file.endsWith('.js'))
filelist.push(path.join(dir, file));
}
});
return filelist;
};
module.exports = walkSync
I've had that file the entire time..
Which to me, is what I needed.

If anyone knows the answer, please ping me. My fat ass is going to get a snack.
Most likely because points1 and 2 don't match anymore
that shouldn't cause an issue if it gets set up in the first place though
since it just binds an event listener if points1 == points2
That if statement fires only once, but the event listener should be still alive right?
So it wouldn't be the issue i suppose
yeah that's what I'm thinking
your if statement logic inside of the collector is probably fucked up
i tried logging the variables, the first time it worked but after that it just stops
and doesn;t do shit
Maybe currently checking it out but it looks fine to me!
also your logic can just be shortened to if (boolhit1 == boolhit2 || !done)
Hhahahha yeah i just figured, thanks for pointing out
This is really strange btw
because even if my if statement logic would be fucked, the console.log is right after the collector.on
So it should still need to log the actual interaction
which it does the first time but then it quits
What does he collect even collect?
it's a component collector
so a button
To me after all the information that I was slapped in the face with in the past day, it looks correct. And if it is correct, why isn't the slash commands pushing to Discord?
Owh yeah my bad forgot to show it
any filters?
uhh yeah i.member.id !== client.user.id
are you using this in DMs?
const filter1 = i => i.member.id !== client.user.id
const collector5 = kdb.createMessageComponentCollector({
filter: filter1,
componentType: "BUTTON",
max: 50
});```
i.member won't exist in DMs
nope, regular channel.
so even if you're using it in a regular channel it'll crash if you try it in DMs
yeah
this is v13
- update to v14
- always use the number/enum unless it doesn't let you for some reason
The collector works the first iteration why wouldn't it the second time?
Does it work once or not?
yes
Ah nvm
Maybe i could like share a bigger snippet on like pastebin or something
Okay, right on it.
The module is just to walk through your folders and return the file list
It doesn't has anything to do with (slash) commands
https://pastebin.com/Drmb6Z3W please don't mind how shitty the code looks
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Just a generic little helper (function) you can import and use anywhere
Tf use source bin or anything with syntax highlighting
As this is supposed to be a general collector, i have made 2 counters. 1 is the ender that checks whether 1 round has ended (modulo 2 as each user can only do an action once each round), and counter to switch through the users (mod 2 == 0 = user 2, else user 1)
okay
And proper scaling for mobile devices
That's like discord code blocks in light mode 
whahahaha my bad sorry
This is not the complete complete code snippet but i guess that this is the code that is important
oh my...

I guess no matter how much I beg and plead you still use json for a "database"
i never said it was good boys
i actually switched over to sql

however this is a home project so i don't really care about the data.
It's just for me and my friends
Which is why i put minimal effort in the layout etc
However this issue is fucking everything up and idk how to fix it
Tbh it's impossible for me to see which parts belongs to which statement as the format is fucked up a lot as u said
Unless Waffle sees the issue I would consider to start to comment out your statements and nested code and see what makes your collector stopping
if your code is THAT indented then you've got a major problem 😭
i know i have 😭
I totally understand
i will just rewrite this part from scratch again and see where it went wrong. Thanks for everything boys!
At first I would start to comment out anything expect the logging inside the collector to see if the event fires multiple times then
The going down to the deeper nesting
I tried logging inside the collector, only fires once
Weird English I know
When anything else is commented out is what I said
So really strange almost like it gets stcuk somewhere? Which it can't as it's an event
oowh lmao my bad
Maybe something you await that will never finish
That shouldn't prevent the event to fire again but could make the event loop stuck ?! Idk I'm not that deep into JS
But try it out
Oh. Alrighty. I think I can manipulate it.
Should go damn quickly to comment the entire code out or just delete it
Alright then tell me if the event fires multiple times
Which it should do
Also where tf is @quartz kindle
Are you still alive?
I did it finally.
Slash commands are now loaded.
It only took a little bit of brain power to be honest. Waffle definitely helped me.
What would be the best way to resize an image (e.g 500px 1:1) to 1px 1:1 but being able to zoom in and seeing the same image as before
Or something that has the same results
Not development related but it is a techy question
Ye, it's impossible to resize raster images without loss of information
^
rasters are described per pixel, whereas svgs are described by mathematical formulas, like bezier curves
Scalable Vector Graphics
And no, putting a png inside an svg won't make it resizeable
Just in case (saw some people doing this already)
Yeah the data itself has to be in some form of vector graphics in the first place to be scalable
that's why SVGs are very desirable for web dev
Sayu loves svgs
I'm a little sad I didn't realize how useful autocomplete was. This opens up a lot of opportunity with my bot and all the manual inputting I've been making the users do. 
https://scs.twilightgamez.net/g/YJZZF.gif
Of course. If they just type whatever instead of picking then it still attempts the code as normal.
You can still type and send some weird shit that won't have an option available
Yes that's what I mean
The good thing about just now figuring out this what a thing is that I already had those checks in place 
But my mind is like 🤯 since all my database related stuff can be in those and man does it make life easier
There should be the required flag to force the user to pick an available option
Or not and still be able to input and send even without picking a matching option
I definitely agree with you there.
So before I used to have people run a /playlist select to set a playlist as "Selected" in database to then make changes too or simply just play w/o the ID of it.
So ... once discord notices and agrees when might see this feature in the next 5-10y
This just like completely changes my way of thinking with my system now
Yes autocomplete is very useful
But choices are, too and ensure a much faster response time
And they are shown immediately
me realizing I have to go through 1000's lines of code to enforce auto-complete
probably over exaggerating the amount, but a large portion of my bot will use it now
👀 surely there's a good way to handle that.
📝 just sign here and welcome aboard! Github access will be given to you shortly afterwards. 
Yeah I'm sure there is. My code isn't the prettiest and I'm sure I could do much better in regards to simplifying stuff.
Pon
Just rewrite your bot at that point
In the process make it more performant or what not
soo how does autocomplete work bois?
You type something and the bot "suggests" which choices to choose
From what I understand, these choices can be set inside the command itself instead of in the data of this command
This is probably more flexible because these choices can change, for example, depending on the popularity of the song
One month, one song will pop up as a suggested song, and the next month, another because it's more popular
well yes sorry i meant how does the code side of it work? any docs?
well I do know how to setup command choices but yeah, I suppose just gotta use that system for the moment 🤷♂️
Of course they are
nice
danke bros i've added autocomplete now 💪 was pretty easy
That's true, it's not too complicated if you use the guides and documentation and don't mindlessly copy code from stackoverflow
yuup
hey guys in dbms, an index is just used to save the pointer and location of data tuples so that a query can run faster and more optimized.
However i got this question in my practice and don't really know when to use an index?
I mean, if an index can be used, it should be used right so that it will always return fast results?
Because otherwise it would first have to analyze through the whole year database etc etc and then select all data from them, but using indexes it can just retrieve all locations and filter them and return the result.
Actually i think it's the 2nd one
Because it honestly depends on the dbms you are using. Some already have good analyzing techniques, so an index would be useless if they have the same estimated costs.
Does anyone know if a mysql (mariadb) bulk insert is faster than a single insertion multiple times. Mainly used to inserting user data into a database? I would assume so, just wanted to know if there could be any draw backs to inserting potentially 100's + of users for example on a guildJoin
there shouldnt be any significant drawback
Okay cool. Originally I was just forEaching each member and doing single inserts, then I realised a nested array is basically a bulk insertion
so I could dim it down to a single database query
yes, that is going to be much much better

If a user is already in the DB which I can do something like a INSERT IGNORE, would that update any information or should I potentially do 2 queries, an INSERT IGNORE and an UPDATE IGNORE
How does the new code block format on Discord work?
should be same, just new highlighting right
Haven't seen any specific information from Discord themselves so far, trying to figure it out
there is a new code block?
Ah so they meant new colors with "new format" then
var test = 10;
```?
console.log("hello world")
for(i=0;i<100;1++) {
console.log("tim smells" + i)
}
new color highlighting
I guess they were meaning to update the screenshots for the colors
you smell
facts
:^)
like, insert if not exists, else update?
essentially since username or discriminator can be changed by a user.
realistically I don't need the discriminator
INSERT ON DUPLICATE KEY UPDATE
oh i see
should be VALUES, why SET?
idk it's what I've always used.
Ik how to use VALUES () I don't exactly recall the reasoning to why I had switched to SET in the first place
but it works atleast for the stuff I've been doing
INSERT INTO table_name (col1,col2,col3) VALUES (val1,val2,val3) ON DUPLICATE KEY UPDATE col1 = 'a', col2 = 'b';
if you're filling up all columns, you dont need to specify them
just INSERT INTO table_name VALUES (val1,val2,val3)
INSERT INTO user (userid,username,discriminator) VALUES (member.id,member.username,member.user.discriminator) ON DUPLICATE KEY UPDATE username = '${member.username}', discriminator = '${member.user.discriminator}';
I think would be accurate to what you sent
yup, that should work
cool
OH
I remembered now
So my user table does have more than just those 3 things but in the DB will have default values of 0
or the unique ID
so they wouldn't effect the query right
yup
awesome.
Ty again
well how would a bulk insertion work in this sense?
await client.database(`INSERT INTO guild SET guildid = ?, guildname = ?, membercount = ?`, [//bulk goes here], false)
my old query
i was also wandering, had to look it up
apparently its something like this ```sql
INSERT INTO table (col1, col2, col3)
VALUES ('1','2','3'), ('4','5','6'), ('7','8','9'), ('10','11','12'), ...
ON DUPLICATE KEY UPDATE
col3 = VALUES(col3)
oh okay so the VALUES is were the nested array would go
[[]] = (), (), () to mysql
cool
Nested arrays are turned into grouped lists (for bulk inserts), e.g. [['a', 'b'], ['c', 'd']] turns into ('a', 'b'), ('c', 'd')
from stack
also,
After MySQL 8.0.19, you can use as keyword, for example:
INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6) AS new
ON DUPLICATE KEY UPDATE c = new.c;
I technically use mariadb but they follow for the most part the same queries
I'll likely use your first example
depending on which library you're using for the client interface, they could have specific methods for doing that, for example using prepared statements
yeah, I'll do some testing and well find out 😛
after playing around with it, I finally got it to work however it doesn't seem to be checking for duplicates. I've researched and I seem to be doing it right I believe?
https://scs.twilightgamez.net/q23tw.png
await client.database(`INSERT INTO user (userid, username, discriminator) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE username = VALUES(username), discriminator = VALUES(discriminator)`, members, false, true)
I had to do it this way due to it not liking the official SQL way.
notes:
members = nested array
false = not to return the data (For when I store it in a variable)
true is a bulk insertion using database.batch()
userID needs to be at least UNIQUE
I think I understand where I screwed up
where I do
user (userid, username, discriminator)
putting id infront of userid should do the trick
await client.database(`INSERT INTO user (id, userid, username, discriminator) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE username = VALUES(username), discriminator = VALUES(discriminator)`, members, false, true)
because id auto populates with auto-incrament
so if it exsists ignore and update?
since columns are named, their order shouldnt matter
the userid needs to be a UNIQUE index in your table
or a PRIMARY KEY
I'm using client.users.cache.get but it just returns UserManager. Does anyone know how to resolve?
I'm using discord.js
what's the full code that uses that line?
just the client.users.cache.get
well that alone I don't believe gets you anything.
for example
client.users.cache.get(//userID here)
if your getting a specific user
I thought it was the partials, but I did it all over again, and it still didn't work.
module.exports = {
name: "ready",
callback: async (otto) => {
try {
otto.user.setPresence({
activities: [{
name: `Go to the stars`,
type: 3
}]
});
console.log(otto.users.cache.get("1061033912786235583"))
} catch (error) {
otto.logger.error(error.stack);
}
}
}
that's it
c.c
oh
I see
module.exports = {
name: "ready",
callback: async (otto) => {
try {
otto.user.setPresence({
activities: [{
name: `Go to the stars`,
type: 3
}]
});
let user = otto.users.cache.get("1061033912786235583")
console.log(user.<whatever>)
} catch (error) {
otto.logger.error(error.stack);
}
}
}
https://scs.twilightgamez.net/ZKpLp.png for example
wow... it worked, but why? when i was in v16 version of node i could do like this console.log(client.users.cache.get(id)) and it worked
Must've changed something within the API or DJS itself
stuff changes between updates
Oh you said node
I'm on v16.14.0 
I was using version 16 a while ago and everything works normally the way I told you, then I went to v18 and it changed there 

I never experience 18 so I couldn't tell ya 😛
No problemo
that is likely to never happen, maybe try updating djs to the latest version if you haven’t (?)
im using v18 node and it’s working as intended
the parent channel's name?
bae sometimes I wonder if you even bother checking the docs
Maybe they don't know how to use them
personally i am too lazy to check myself sometimes
ye
the docs are super quick especially when you know what you're looking for
Writing the error from the console in google is also 10 seconds 
copy paste instead?
there was no error in this case
he just didn't know what the props were called
hence why we have docs
nope, i prefer coming here 
I know, but I mean those people who come and wait for hours for an answer and sometimes they don't get it at all
error, file not found
"what does this mean????"
or, you could save yourself the waiting time and spend 15 seconds on the docs ;^)
he does it as an excuse to make his project take longer to finish
then he can brag "oo my project took me 5 years to make"
4.5 of them was waiting for help here
:^)
never done that before, what are you talking about 😳
my project will also take 5 years to make
but 4.5 of them was looking at memes online
relatable
There was a problem with your request.
Cannot read properties of null (reading 'name')
😐
the docs have lied to me
They never lie
on a scale of 1 to 10, how well would you say you understand discord.js
like a solid 9 before taking a 4 months break from bots now i'd say a 2.5
alright then suggestion
spend more time learning javascript and discord.js before working on your bot
i'm good
would be a lot more productive than coming to ask a question here every 2 hours
i will remember the whole discord.js in about a week when working on the bot
personally i learnt js by doing bots but do projects that you enjoy so you get things done and learn, but try to avoid asking people too often as most of your questions are on the web 👍
i haven't been here in about 2 days before asking question about the parent
nearly all the languages i learned were from trial and error, never went on a single course besides taking ICT at University
i had my dad to help me so i can't fully relate but yeaah, i was more like "I need to make x system" and then asked my dad for advice etc
yeah that's a good way to do it
you'll see a person do it once and you'll remember it for life
sometimes
i just need to refresh my memory with discord.js and i'll be good to go
either way how do i get the parent name since that didn't work
docs said to do parent.name
my dad mostly helped me with JS by introducing functions like JSON.parse(), ajax-request package and then i learnt more and more by making bunch of bots for people in the communities i were in
Has the channel ever been created?
you didnt await setparent lol
yep, it asks for the parent after creation to send the confirmation message
💀
and yet it still worked
it didnt? you got the null errror
it parented it tho
await would probably secure that it happens before your message.reply
but your code tried to access the channel.parent.name before the setparent went throught
the null was from the .name variable which does not exist
alright so an await will fix it?
😉
setParent works better for what i'm planning
i want to expand the command later
add a way to create parents instead of having to do it yourself
also a way to setup permissions
and more channel types
it is related with debugging however the chunk was a proper string and chunk.at(0) worked properly
well the road to my answer began with my first question to the OP
from your image, is it possible that the debug is running after the comma was already taken out? is it also possible that the chunk may begin with more than 1 comma so sometimes debugging at that exact spot would still show a comma?
anyone has a working android 9/10/11 ROM?
you'll be dead before the program loads
https://gyazo.com/ba9bd49da4a01d243dd2dfdb55fe9e86 after several hundred painful lines of opengl
opengl
alright I need someone to suggest (typescript compatible) js libs for discord bots
unfortunately detritus hasn't been updated in 7 months
Honestly just make your own
The only updated one rn is djs from what I've seen
and I already know you hate djs
hell no
Why not
not gonna spend 3 weeks writing JUST the gateway code
...
you spent longer than that writing a language out of rust which is harder than just doing a discord lib
Also waffle there are an enormous amount of benefits of just going libless
and did I finish it? nope
if you don't really care tho just use djs its the most stable in terms of not dying anytime soon

give a man a game engine and he'll write a game, teach a man how to write a game engine and he'll never write anything
You could always use my shitty lib that I made that is not complete
it already has gateway code written
honestly I might be forced to go with djs
That is why I stopped wanting to make a game engine in C++
fuck that shit
i'd lose interest in game dev entirely
at least I've seen enough shitbox code in this channel to understand the ins and outs of it lmao
we don't talk about that
Honestly most of my time is helping out my dad's ex with her business idea
I got bored and decided to help

Also I dropped out of precal
Damn why
Got bored of it
Also the college I am now looking at going to doesn't require it so
Precal is boring but calc is fun
Plus you’re gonna need it in the comp sci world
Especially if you want to do gamedev
I will take precal in college
Right now i gotta worry about passing highschool and that one class is stressing me out
I am failing alot of my classes cause of how hard it is to learn anything in that class and me failing it
Hi
This looks a bit funny, did I do something wrong? I'm doing this via tailwindcss. https://cdn.hamoodihajjiri.com/Fax7PyVx9J
<img src="https://www.hamoodihajjiri.com/assets/images/hamoodihajjiri_banner.png" className='w-full h-40 md:layout pattern'/>
I'm trying to figure out if I can just crop the image, instead.
that's pretty normal for img elements, you can use object-fit property
Guys
Trover
How can me make if someone vote to my bot the bot will give him coins
use the webhook feature 🤓
Dont use a fixed height for images when planning on rezizing them
Either use a container with a fixed height and set the image as background or remove the fixed height entirely and live with the fact the height will change when rescaling
You can still define a minimum height for example to prevent to much rezizing
hi there
do someone know stuff about github ci/ci actions?
i wanted to know how to make a difference between my main branch and my dev branch in my .yml
because when i merge dev into main, the main.yml from the dev branch overwrites the main branch one
do u have any ideas how to avoid this ?
Hello, how can I delay forEach() in discord.js?
you want to delay a particular time after getting each element?
there's a package named wait in js, you can use that
const names = [
"Alberta",
"Barry",
"Charley",
"Christopher",
"Dianne",
"Ellen",
"Ethel",
"James",
"Jodee",
"Joseph",
"Lilia",
"Mark",
"Mary",
"Merri",
"Michael",
"Mildred",
"Randall",
"Roy",
"Thomas",
"Venus"
];
names.forEach(name => {
console.log(name);
});
For example I have this, and I want every name would be displayed after x seconds
I'd use an interval for that
const wait = require('wait');
names.forEach(async(name) => {
await wait(1000)
console.log(name);
})```
It would wait 1 second and then log all list
nope
I need them logged separately
there's no need for a third-party package
use a Promise with a setTimeout
So many good solutions other than that. Ye
I'd just use an interval and log the first item in the array and then remove that item.
And delete the interval when it's empty
JavaScript developers love to use a third-party package for the simplest of things 
i'm an exception, but I agree, but that applies to any language devs that I know 💀
const names = [
"Alberta",
"Barry",
"Charley",
"Christopher",
"Dianne",
"Ellen",
"Ethel",
"James",
"Jodee",
"Joseph",
"Lilia",
"Mark",
"Mary",
"Merri",
"Michael",
"Mildred",
"Randall",
"Roy",
"Thomas",
"Venus"
];
const awaitTimeout = delay =>
new Promise(resolve => setTimeout(resolve, delay));
names.forEach(name => {
awaitTimeout(3000).then(() => console.log(name));
})
you mean like this?
yes
though i prefer awaiting the awaitTimeout and making the forEach callback an async function
But this code wont log them separately
this
forEach is very rarely preferred over the normal for-each
plus it also adds some overhead
Unrelated,
I'm trying to extract a .tar.gz using 7zip CMD, it throws me "Cannot open the file as archive"
But when I extract the same .tar.gz using 7zip GUI, it works fine
does it take relative paths
try absolute paths
Does anyone here have experience with Grafana? I'm getting Data is missing a number field on a Time Series graph even though the data is there
How do I get the current file path in batch hmm
[{"time":1664646854,"number":13245,"label":"October"},{"time":1667328854,"number":11475,"label":"November"},{"time":1669920854,"number":9593,"label":"December"},{"time":1672599254,"number":544,"label":"January"}]``` Example of the data
And no I'm not doing shenanigans
I'm making a vulkan installer for star citizen

aw
SET path=%~dp0
VulkanInstall\7z.exe x "%path:~0,-1%VulkanInstall\dxvk.tar.gz" -so | VulkanInstall\7z.exe x -aoa -si -ttar -o"VulkanInstall\dxvk"```
h
does anyone know why this code ends up as on the screenshot? the text is supposed to be on the left
is the download awaited
How do I
idk
If I had to guess, your Alert component has a child element that gets added with the p and Button.Danger on the same level, which makes the justification three elements








