#development
1 messages · Page 85 of 1
I'll try using tar -xvzf instead
that ends up like this
this is the alert component
then you probably want the p to take up the rest of the space in the box
if you mean add text-left w-100 then that also doesnt work
no
you need to tell the individual flex item to take up the rest of the space
flex-grow may be something
thanks!
you may also need to get rid of the centering you're doing in your alert since the text will be centered otherwise
items-center is vertical
really? I didn't know that
yeah, justify-center is horizontal
not always vertical/horizontal, but cross-direction/same-direction
Any idea to why 'user' would be null
{
name: 'play',
category: "Plalist",
description: 'Play your current select playlist OR a specified playlist title or id',
type: 1,
options: [
{
name: 'user',
description: 'The user who owns the playlist you want to play',
type: 6, // user
required: true
},
{
name: 'playlist',
description: 'The playlist you wish to play',
type: 3, // string
required: true,
autocomplete: true
}
]
},
the options
autoComplete: async(client, interaction, config, db) => {
switch (interaction.options.getSubcommand()) {
case "play":
{
console.log(interaction.options.getUser('user')) //null
const focusedValue = interaction.options.getFocused();
let search = focusedValue.length === 0 ? client.database(`SELECT * FROM playlists WHERE owner_id = ${user.id}`, false, true) : client.database(`SELECT * FROM playlists WHERE title LIKE "${focusedValue.toString()}%" AND owner_id = ${user.id}`, false, true)
let choices = await search;
await interaction.respond(choices.map((choice) => ({name: choice.title, value: choice.playlist_id})))
}
break
}
},
Autocomplete
javascript making me go insane again
check speed of concat method
hmmm good idea
gimme examples if I missed.. going raw is fast, even with numbers, but the difference is notable between numbers and strings in concat and it's slower overall
not a good way to benchmark
alr, elaborate
js does some optimization when u repeat the same task many times
meaning u wont get real performance of given task
to get a rough idea of what the performance is like
I mean, it'll show mostly incorrect results
you're not about to figure out what optimizations your cpu is doing
ur repeating the same task 500m times, JIT will inline it almost always
plus, ur not restarting the runtime after each task, meaning commonly used methods will get optimized during previous execution
took away one "0" from the other tests above
I get what u saying I ain't saying "u mad"
I'm just saying that if I run the same test the same amount of times to separate functions I can compare them
not really, but if those results satiate you...well, go on
benchmarking involves very strict environments to assert two tests are done with the exact (or as exact as possible) same starting conditions
I mean.....
those numbers mean nothing
the point of science is for things to be reproducible, I'm not trying to measure my cpu, just seeing what function is faster
if the methods are ridiculously close to each other in speed
a common optimization done during runtime is to calculate only once and return the same value for the remaining iterations
if all input values are the same
and if they're that close to each other when I do them a couple million times, well word
the results mean nothing if the experiment is done wrong
I've tested things on functions that play with randomly generated arrays
still
I gave only one example, it ain't the sole optimization done by jit
you'll never get correct results without correct tests
idk why you insist that running 2 functions a couple million times and seeing roughly a consistent difference means nothing
because that's how it is
"correct" only ever meant "which one is faster" in what I'm testing for
yes, and your tests wont tell u that
how hard is to understand that one call might influence future calls?
in application, things aren't run in sterile environments
so actually, why would u test them there.. when your intent is to have something be faster in application
yes, that's why u test in a separate environment
because u want to test which method is the fastest
it's like testing which car is the fastest but in a crowded road
sounds like u would see if a boat sails without ever putting it on water
see the car example
u can say "yea it should sail" but the proof is the application
if ur gonna test which car is the fastest, you'd do it in a straight, empty and controlled space
you really just want a controlled experiment man
@sudden geyser that's all I'm on yk
I think the console test is fine as is for small cases like this
by small cases I mean as a trivial test
a proper benchmarks tries from a fair state and controls certain variables
but most people aren't going to go through the effort for such a thing
so I think the console test or using a library / program is fine
well, there's a site for that
nope
a test also tries multiple times and measures differences
which helps remove noise
usually
well it'd be rather difficult to say how much ms it takes for the function that small to execute
that's why u force a bigger test
to see which one is faster over time
no, to strain-test
well yea, so that what I choose has the lowest strain
u were saying this isn't a good way to measure that
the entire time
like ```js
let a = "";
for (const i in [0..10000]) {
a += Math.floor(Math.random() * 10);
}
console.log(a);
why would I try to see which of these things are faster that exist all over in something bigger
because...nevermind, do what you will, if u want to 1 + 1 = 3 so be it
that will be called on numerous times
console.log is a snail on browser
as I said, do what you will, I can't convince u to do a proper test so there's no point in attempting to
console.timeStart/timeEnd is half decent for measuring times quickly, but there’s a lot of complex engine things happening in the background without a proper testing environment
Write a plugin to integrate chatgpt
js wont ever be able to do accurate benchmarks, you will have to settle for those small console tests
that code will not be measuring the concatenation performance, it will be measuring the Math.random() performance, since that by itself will eat 99% of the cpu time in that one line of code
in order to defeat the amazing js optimizer, you need to introduce things that are orders of magnitude slower than the things you actually want to measure
which makes measuring even more stupid, because at that point you're basically benchmarking a big ass code with a small needle somewhere inside, and trying to get the timing of that needle
Forgot abt that
I suppose u could switch for a string literal then
the actual reason for this is a bit deeper
in the first code, the array is actually initialized as a small number array, then the inner array is unpacked and the other numbers are added, completing the small number array
in the second code, the array is initialized as a blank array, so it has an unknown/mixed type under the hood, then when the numbers are added, the array remains a mixed type
the js engine does these weird shenanigans with arrays
js arrays have many different types under the hood
hmmmm
of course the difference also comes from the number of items being unpacked from the inner array, less numbers to unpack will be faster
ik ik, but I also was noting that yes, adding values then a ...array was different from plain ...array
that's pretty dang cool
still is really weird that the performance hit is so big
but yes, if you can, initializing a non-empty array will always be faster than an empty array
nah, the numbers being that wildly different mean nothing according to someone else 😔
since it gives the engine an array type hint
k jokes aside I was shocked at it tho
a while back I remember the ... being slower than using a for loop to begin with
so I thought "ah lemme just make a full spread function that'd be faster" which led to me testing that specific case and being like "what the hell"
hahah
actually let me test this deeper
holy wow
this code [...[1,2,3,4,5]] generates this bytecode
very simple, very straight forward
but this code [1, ...[1,2,3,4]]
generates this...
lmfao
from this point of view, the first code should be faster, but i guess the second code has so much more information provided that gives the engine a lot more things to optimize there
also the last part makes it seem like (im no expert in reading these, so correct me if im wrong voltrex), in the second case, the inner array is not actually unpacked into the outer array, but rather the outer array will hold references to the inner array instead
so both arrays remain separate in memory
What's happening here is that the first code ([...[1, 2, 3, 4, 5]]) is the exact same as [1, 2, 3, 4, 5] because it unenrolls the spread call as it has no effect here, resulting in a minimal bytecode, however in the second one ([1, ...[1, 2, 3, 4]]), it goes a lot deeper as it looks up in the target object's descriptors (all objects and literals has their own internal slots) as to what appropriate behavior it has for a spread call, which in itself generates it's own bytecode
however, the first code is 7x slower than the second for some reason, thats why this is all so weird (and funny)
lmao
my thinking was that maybe if the second code keeps both arrays separate in memory and just references them it can skip the concatenation in the first code, thus it becomes faster, but if the first code does not actually concatenate anything like you say, then im at loss for an explanation here
It's the complete opposite for me
You folks may be using a version of V8 that had a regression for this specific case
chromium 107.0.5304.88
let me test on node too
indeed, node 19.3 gives a different result
Chromium 107 uses a version of V8 that has a regression
reminder to always test weird things on more versions xD
@viscid gale
Yep, we merged the patched V8 release in the Node.js v18 releases
just pinging myself so I can search for this ping later
really bloody interesting things
it happens
i was right on one thing tho, but i got it the other way around actually
on the dev tools memory inspect, [...[1,2,3,4,5]] is the one that actually shows it being a full SMI array
whereas [1, ...[2,3,4,5]] does not, indicating its a mixed type array
ahhhhhhh
Yes, there are wrapped type hints for spread calls on elements with other types
We do everything we can to optimize as much as possible™️
the first one takes 44 bytes, the second one takes 100 bytes
this is another js secret that most people do not know, identical objects in js can have very different memory usages, depending on how they were created
so far I'm only using the spread function (for loop that does [...array]) for that case only and another case where I say [1,...array] I leave it
1 is shorter than a word that makes human sense and it could be shared over a websocket an ungodly amount of times
much to think on, gn 👋
I guess it’s time… I’ve gotta swap back to djs
why
detritus hasn’t gotten an update in 7 months
And I definitely don’t want to be writing my own raw lib
I would never get anything done
Unless someone has a better suggestion, I’m gonna have to use djs
Or I could fork detritus but that’s kind of a complex lib
im adding something pretty cool to my raw lib, an actual disabled events option
that prevents the event from even being parsed into json
by matching the event name when still in binary data
my benchmarks showed a 10x performance boost for disabled events
just find another library?
some person in this channel I can't remember the name of wrote a fairly interesting library
thought it was tom
yes, not tim!
tom and jerry
Tom and Jerry more like Tim and Berry
berry the platypus?
oh his name was actually tim
timsmart
the library is called droff
Good
no more being stuck with bigint ids only
shit was so confusing
indeed
what was the nail in the coffin?
now if only i can figure out the most annoying problem of all
snake case or camel case
_<
PascalCase ftw
because discord uses snake case
this shit is now C#/Java
and i want it to be 1:1 to the discord api docs
discord used to be backed by py
but then my own extras on top, if they are pascal it gets weird
if they are snake, its also weird
i cant decide
hahahah
How about dynamic keys and the user can decide
for example what looks/feels better```js
{
large_threshold: 500,
disabled_events: ["PRESENCE_UPDATE"]
}
or
{
large_threshold: 500,
disabledEvents: ["PRESENCE_UPDATE"]
}
Thats something I have yet to see
large_thresold is an api option so it has to remain snake
Just have a set of internal keys and dynamically set the prototype of classes based on options
lmao
It could work tho
like I prefer camelCase
but jimmy bob here might want snake
Im so inconsistent with my shit tho. I use snake case in C#
its the most cursed shit
do i just duplicate all of it on intellisense and coalesce the case in the actual code?
lmao
What I'd do which might be reasonable is have different entry points for cases and dynamically assign to class prototypes based on some value you can bounce around
instead of using the syntax sugar for classes
that way you can have 1 code base with internal keys
To be fair the only reason I’d be using djs over a different library is because I don’t want to learn another lib
discord.js is a memory leak itself
Hey, I need a help. I tried to make a website and it's working good, it's made in html. I tried to use express and made a basic file in which I putted this```js
const express = require('express');
const app = express();
const path = require('path');
const router = express.Router();
router.get('/', function (req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
});
router.get('/invite', function (req, res) {
res.sendFile(path.join(__dirname + '/invite.html'));
});
router.get('/support', function (req, res) {
res.sendFile(path.join(__dirname + '/support.html'));
});
router.get('/vote', function (req, res) {
res.sendFile(path.join(__dirname + '/vote.html'));
});
app.use('/', router);
app.listen(433);
console.log('Running at Port 433');``` but when I'm opening the website, it's showing it without the components, it's showing just like a blank website with just normal fonts written and with no images
its insane how much memory you'd be saving if you just didn't import such fucking large libraries. The module require cache is insanely stupid and comes with a lot of overhead since Discord.js likes to have a ton of files for each thing
I know
but they'd save a lot of memory if they used something like tsup
for initial import
inline src maps are also pretty cool
the files that the html file uses, for example images, css files, font files, etc... all of the must have express routes too
to make this easy, express has a "static" system for static files
it'll show all the components and images then?
app.use(express.static('folder name'))
that will make everything inside a folder you chose marked as a static file, so express will always find them
I've my file structuring like this
Should probably have an src directory
all the css works and all are in assets
Not required but good practice
then make assets your static folder
ok
app.use(express.static('assets'))
the files inside the folder are exposed to the root directory
so you have to remove any /assets/... from your html code
or do this instead
app.use('/assets', express.static('assets'))
👍
now I've to get it hosted 
It looks like its just static files currently.
Github pages probably would work fine
^
I can link my domain there ?
yep
Websites for you and your projects, hosted directly from your GitHub repository. Just edit, push, and your changes are live.
oki
hi
got a pb with windows env
pGlob doesn't work
does someone know how to fix it?
windows also supports forward slashes, you dont need to use double back slashes
What does one call these?
justTesting vs just_testing?
Surely there's a specific name for these
Ping me when you respond please, thanks
pascalCase and snake_case
Nice one cheers
there are many others as well
pls Advise?
like SCREAMING_SNAKE_CASE that discord uses
What do you personally prefer?
What do you think is best practice or is this just a 'case' of personal preference?
personal preference
fair enough
but in js/ts most people use the same style as the image above
lol which one
fair enough
js people dont like snake case
I don't utilise these like I should tbf
python people on the other hand use snake case a lot
My code would look cleaner
also web apis are mostly snake case
because web data formats often do not differentiate between upper and lower case keys
other case styles xD
Hey guys may be the wrong place for this but does anyone have any info on when/if puginator will be available again. Thx in advance
Probably best you join their Discord server
My bad. They have this one listed on their site
Is there a site that can check what browsers a site (or JS file) is compatible with?
A whole file I dont know, but mozilla has information on specific js features iirc
Do bytecodes e.g 258 use more bytes (qua size) than their corresponding character?
lemme just try sum
are you talking about character encodings?
who help linux install mysql database phpmyadmin
any react folks here?
Alright so I'm trying to use MongoDB for the first time.
^ This is my datasetup file.
Then I have one model for my lockdown command. Which looks something like this:
const mongoose = require('mongoose');
const Schema = new mongoose.Schema({
Guild: { type: String, required: true },
Lockdown: {
Enabled: { type: Boolean, default: false },
Channels: { type: Array, default: [] },
}
})
module.exports = mongoose.model("lockdown", Schema);
For some reason, my error catch returns just "An error occured" not specifying why.
My datastore looks like this.
Is it correct?
Can you hover over const Keyv = require("keyv")?
Believe it's typescript.
To do with TypeScript.
What is the exact error?
That is different than what you said
Are you running it on your computer or on a machine?
Computer.
Okay one thing first
Are you sure you are connected to the database?
This error usually means that it took to long to respond and find the resource
Showing connections on the primary, yes.
which usually means that its not connected
Personally, I have this error because I have terribly shitty WIFI
Also another issue could be due to you trying to use the model before a connection is fully established
How could that be prevented?
You could use async/await on the .connect which will only continue allowing code to run after the .connect once the promise has been resolved
https://stackoverflow.com/questions/65408618/mongooseerror-operation-users-findone-buffering-timed-out-after-10000ms all of which is actually mentioned here
a simple google search provided this stackoverflow page
Well I took here over google.
Sorry.
Looks like replit to me.. which is not your computer
Hello Guys I have a problem this is my code and when I add new roles it won't update in data base any idea? 🤔
as you can see in both images from DB second role didn't add (first image is for before add second role and second image is for after adding it)
(first role is added because the code is different for adding when there isn't any role)
if data.dj or data.dj.roles was not found, then the variable djRoles becomes an empty array []
that empty array is not connected in any way to data
so data.dj.roles will continue to be empty
see the console.log result
its not empty
you are logging djRoles not data.dj.roles
well djRoles is what I want to save 🤔
but you're doing data.save()
so 
ohhhhhhhhhhhhhhhhhhhhhhhhh
and there are no changes to data
wait
there is a change 
I change data.dj
it was
{
roles: ['id1'],
djOnly: false
}
and now its
{
roles: ['id1' , 'id2'],
djOnly: false
}
don't kill me Tim 
const a = data.a || [];
a.push(1);
console.log(a) // this will always work because its either data.a plus 1, or empty array plus 1
console.log(data.a) // this is different, if data.a existed before, then its data.a plus 1, but if data.a did not exist before, it will continue not existing, because the new array that is created above is separate, and not added to data automatically
Well then, it is indeed Replit.
🤭
so what should I do now? 👀
if data.dj.roles already exists, then your code should work
well thats the point!
why it don't work
you said it did work?
you said there was a change
there is a change but in data base nothing changed
I have this, I believe.
const { mongooseConnectionString } = process.env.mongooseConnectionString
const mongoose = require("mongoose");
module.exports = async () => {
if (!mongooseConnectionString) return;
await mongoose.connect(mongooseConnectionString, {
keepAlive: true,
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
})
return mongoose.connection
};
This is located within ./handler/mongoose.js
In index.js, I have:
// MongoDB
const mongo = require('././handler/mongoose')
mongo().then(connection => {
console.log('MongoDB shard connection successful.')
})
Maybe this? @quartz kindle ?
this is where you have to use async await
or you have to put all the code inside the .then()
maybe, i dont use mongo
Yeah. connection is declared but it seems never used.
how else do you use it if its never used?
how were you using it?
ello tim
lmfao
ello
// MongoDB
const mongo = require('././handler/mongoose')
mongo().then(console.log('MongoDB shard connection successful.'))
Would it look like that..?
no...
brotha
im talking about your code that uses mongo
like idk how it works, connection.query() or mongo.query or mongo.findOne() idk
Schema.findOne()
I don't think it's my schema though.
yup
const schema = new mongoose.Schema()
const model = mongoose.Model(schema)
model.find()
model.save()
``` is that how you are using it?
anyway it doesnt matter
what matters is that ALL of thay schema model stuff has to happen AFTER the mongo connect fimishes connecting
and the problem with a .then() is that it does not make your code wait for that
all your code outside of the
.then() continues running before mongo finishes connectong
Yeah.
In a way though.
const model = mongoose.Model(schema)
I don't use that though..
module.exports = mongoose.model("lockdown", Schema);
just put this ```js
const mongo = require('././handler/mongoose')
await mongo();
or in your ready event
const { Client, Events, GatewayIntentsBits } = require("discord.js");
const { token } = require("./config.json");
const clc = require("cli-color");
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.once(Events.ClientReady, c => {
console.log(clc.white(`Logged in as`), clc.red(`${c.user.tag}`));
});
client.login(token);``` Undefined Reading of `Guilds` at ```js
const client = new Client({ intents: [GatewayIntentBits.Guilds] });```
oh fixed it
why not map through all the Intents at once
I know bit number
const Discord = require("discord.js"),
client = new Discord.Client({intents: Object.keys(Discord.Intents.FLAGS).map(x => Discord.Intents.FLAGS[x])});
oh ok lol understandable, I used to as well
👀 why?
Exactly
Try const client = new Client({ intents: 131071 });
Why all intents?
ew
Sometime people don’t know what they need on their bot plus most bots use all
👀 how?
But not everyone needs them
I know
if you use all without knowing why you're making a mistake
Idk much abt this but still managed to get, shrug
Ikr mostly beginners doesn’t know their intents
👋
hi?
you must have nice cpu usage
:^)
if discord gave me presence intent id still turn it off
Tho idc abt cpu usage/ram/disk space, as I my own machine setup for this lol
good night guys
lmao
I even turned off the message intent
another good one to turn off
Since there are slash commands, struggling to write a text command is not worth the time
At least for me
my bot was so much easier to use with text commands xd
but then again i didnt actually finish the slash command rewrite yet
i just made a make shift solution
and its been like that for months now
I used to think text commands were better too, until I saw that you can add choices, select channel/user and autocomplete without having to go to much trouble with it
It made it a lot easier for me when it comes to writing the bot
You're not alone
The list of stuff to do no matter it's related to code or reality already fills two life cycles

Sad reality
lmao
Might be kind of a stupid question, but how do I resolve paths properly after my typescript has been compiled?
For example, I'm trying to load a .env file where the structure is like ```
ProjectName
| src
| .ts files
| dist
| compiled .js and .js.map files
| .env
Nevermind. Got it with process.cwd()
Im trying to add 2 buttons but They wont show.
const { SlashCommandBuilder } = require("discord.js");
const { EmbedBuilder } = require("discord.js");
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("ping")
.setDescription("PONG!"),
async execute(interaction) {
const embed = new EmbedBuilder()
.setTitle("PONG! 🏓")
.setDescription("Test Pong")
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel("Support Server.")
.setURL("https://")
.setStyle(ButtonStyle.Link),
);
const row2 = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId("version")
.setLabel("Version: 0.12.3")
.setStyle(ButtonStyle.Secondary)
.setDisabled(true),
);
await interaction.reply({ embeds: [embed], components: [row] [row2]});
},
};
because that is definitely not the way to use arrays
I'm surprised that even works without errors
fixed
So I'm trying to dynamically import compiled typescript modules, but I seem to run into this error no matter what I try: Error occurred whilst loading events: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' and here's the code that causes the issue: ```ts
const events = fs
.readdirSync(path.resolve(__dirname, '../events/client'), { withFileTypes: true })
.filter(file => ['js', 'ts'].some(e => file.name.endsWith(e)) && !file.name.endsWith('.d.ts'));
show how are you importing those files
const ret: EventImport = await import(path.resolve(__dirname, `../events/client/${file.name}`));
as for the type (doesn't really matter here) ```ts
interface EventImport {
default: { name: 'string'; execute(payload: any, client: Client): void };
}
18.12.1
Now I've got this, and it doesn't load the event as far as I can tell (doesn't execute any of the code in my execute function)
Oh I just realized what's wrong
It's got two default props for some reason... ```
[Module: null prototype] {
__esModule: true,
default: { default: { name: 'ready', execute: [Function: execute] } }
}
not a big deal but that's very odd
odd, seemed to work just fine in another project
Granted I was using ts-node and ran the ts directly
Just gonna keep it that way and just do ```ts
const ret: EventImport = (
await import(file:///${path.resolve(__dirname, ../events/client/${file.name})})
).default;
Otherwise ts yells at me
working perfectly now!
thanks @quartz kindle C:
👍
const { SlashCommandBuilder } = require("discord.js");
const { EmbedBuilder } = require("discord.js");
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("cosmit")
.setDescription("Cosmit is a "),
async execute(interaction) {
const embed = new EmbedBuilder()
.setTitle("Cosmit")
.setDescription("yyy")
.setThumbnail("https://i.imgur.com/vV3C17U.png")
.setImage("https://i.imgur.com/vV3C17U.png")
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel("Join Cosmit")
.setEmoji("1062180410928414770")
.setURL("https://")
.setStyle(ButtonStyle.Link)
);
await interaction.reply({ embeds: [embed], components: [row]});
},
};``` for some reason it wont show the images.
where is the .xyz?
Does ur bot have perms to send images/embed links?
yes
removed when i sent it
issue solved had to restart it
Every time you make a change to your code you need to restart yes
man using djs makes me miss detritus
slash commands were so clean in detritus
pristine
how to get topgg token
You can get the token only when having an approved bot on the topgg page
Editing it will show give you the menu you can navigate through to generate/see your token
bruh

allowed_mentions.users[SET_TYPE_CONVERT]: Only iterables may be used in a SetType```
What is this error
Anyone can explain
libless is life
slash sucks at getting avatars
wdym
literally what I said

Try to get avatar of uncached user
This user ID as example u can use:
422088370060263424
you're using slash commands though
discord sends you a user/member map if you say the option is a user
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Ik buddy, I am already using it, and result remains the same
don't see how it couldn't be simpler
wdym getting avatars tho 🤔
That seems like a code issue, I get user and avatar from slash command user and it works just fine
U can get the correct link to avatar, yep, but when I am trying to view it using embed, it's just empty
And no, that's not only for my bot, I also used dyno to get avatar from same user, and result is same, no picture, but the rest info is fine
Also not, cuz one person avatar displays fine, and the other one is not
In same channel

Like this

?
does the person have a custom avatar or is it the discord avatar btw?
nvm boomer issue
Then it must be something related to the embed itself
Have you tried maybe changing the avatar format, its size or something?
Tried using size and not using it
Same situation
And dyno seems have same issue

Using standard .displayAvatarURL() func
Okay, have you tried using .avatarURL() instead?
.displayAvatarURL() returns a discord default avatar if they do not have an avatar
avatar on screenshot, that I sent earlier appeared after some time
That kinda kekw
Changed to .avatarURL, seems working now

Images in embeds work terribly strangely
You can send 100 identical messages with the same link as an image and 99% chance there will be a message where that link will not load properly
😍 we love sudden breaking API changes
For me, for example, links from imgur don't want to work very well
if the URL fails, it can sometimes cache the failure

I recommend putting a random query on the end
?cache=${Date.now()}
thats what I do
Prevents caching
not really sudden, was announced 3 weeks ago
"Hi all! Today we are removing the Discord API, the change is rolling out as we speak."
i wouldn’t question it if they made bots a nitro-only feature
standard discord behaviour
If that matters, added dynamic: true and size options to displayAvatarURL () and now it works pretty fine
For earlier post
at this point every new feature is locked behind nitro
can slash command names have spaces?
well you can always try it and see 😎
i can’t run my code offline
well i havent seen a command with spaces yet
no
however you can use SUB_COMMAND
it was a pain first time but was pretty easy 🤓
So i have my slash commands separated in folders i have my reply reading ./commands/../${file} idk if this works or not
deploy*
ok thanks
so I had this beautiful package, twin.macro so I can turn a tailwind string into css live, but it doesnt seem to work with nextjs, is there any good alternative?
So i am doing a facts command and i want it to list a fact but it only shows the number
im sending the code
const { SlashCommandBuilder } = require("discord.js");
const { EmbedBuilder } = require("discord.js");
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("igorfact")
.setDescription("Sends an Igor Fact"),
async execute(interaction) {
let facts = [
"Burbur Sucks at Fortnite",
"Cats = Good"
]
let result = Math.floor(Math.random() * Math.floor(facts.length));
const fact = new EmbedBuilder()
.setTitle("Igor Fact")
.setDescription(`${result}`)
await interaction.reply({ embeds: [fact] });
},
};
const { SlashCommandBuilder } = require("discord.js");
const { EmbedBuilder } = require("discord.js");
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("igorfact")
.setDescription("Sends an Igor Fact"),
async execute(interaction) {
let facts = [
"Burbur Sucks at Fortnite",
"Cats = Good"
]
let result = facts[Math.floor(Math.random() * Math.floor(facts.length))];
const fact = new EmbedBuilder()
.setTitle("Igor Fact")
.setDescription(`${result}`)
await interaction.reply({ embeds: [fact] });
},
};
@hidden gorge ^
ez
thanks igor
can’t test it rn
I'm a bit confused? https://cdn.hamoodihajjiri.com/YFHPX4DtCH
Weird 👀
Make sure you’ve restarted after adding in next.config.js
It’s annoying and makes you restart
Restarted VSCode?
No I mean next.js
Ohh, fair enough. It works.
:)
🙂
I'm setting up GiscusComment, which is an app in GitHub. How can I retrieve the repository ID and the category ID of a specific repository? (discussions)
By reading the documentation at https://giscus.app/
Actually no need to even read anything, type your repository name and it will generate everything for you..
I've actually set it up, wrong. It works, now. :)
so my bot has slash commands and im seeing double of a few of my commands how do i fix that?
that happens when you register both a global command and a guild command with the same name
fixed
my ping is reaching -650ms
let pingms = `${Date.now() - interaction.createdTimestamp}ms.`
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel("Support Server.")
.setURL("removed")
.setStyle(ButtonStyle.Link),
new ButtonBuilder()
.setCustomId("ping")
.setLabel(pingms)
.setStyle(ButtonStyle.Secondary)
.setDisabled(true),
hell nah
that method of timing will always be inaccurate
that method of timing will always yield incorrect results because you are comparing two timestamps of two different machines
interaction.createdTimestamp is the timestamp according to the discord server
Date.now() is the timestamp according to your computer
different computers are almost always out of sync in time
you can see it yourself, sometimes the time in your pc and the time on your phone is not exactly the same
they are often several seconds off
sometimes even a minute or two
i think a common method is to edit afterwards with the time it took
does someone know why my embed is not defined
You probably didn't import Discord
Wait
Why do you want to send it before its creation
const { EmbedBuilder } = require(“discord.js”);
also move the await send below the embed
i just wanted to do that lmao
I totally don't understand the ping command. For me it is useless
Like the bot-info command where people post the library they use and the specs of their VPS
for curious lads
does anyone actually care about bot specs
I don't know what's interesting about whether someone's bot has 8gb of ram or 16gb
indeed
i did this to flex my ram usage tbh
lmao
but the statistic command is currently disabled
Can not send an empty message...
const { SlashCommandBuilder, PermissionFlagsBits, Embed } = require("discord.js");
const { EmbedBuilder } = require("discord.js");
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("dm")
.setDescription("Moderation Command")
.addUserOption(option =>
option
.setName("user")
.setDescription("Member to DM")
.setRequired(true))
.addStringOption(option =>
option
.setName("message")
.setDescription("Message to Picked User"))
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
async execute(interaction) {
const user = interaction.options.getUser("user");
const message = interaction.options.getString("message") ?? "No Message Provided";
const embed = new EmbedBuilder()
.setTitle(`You have recived a Message from ${interaction.guild.name}`)
.setThumbnail(interaction.guild.iconURL())
.setDescription(`Message: ${message}`)
await interaction.user.send(embed)
}
}```
Keep in mind that this command is a terrible idea
its for support server only
If you have no way to opt out then it’s against TOS to do this iirc
im working on the opt out
let link = 'https';
if(!message.content.startsWith(link)) return;
let embed = new Discord.EmbedBuilder()
.setAuthor({ name: `SHARK automod`, iconURL: bot.user.displayAvatarURL() })
.setColor("#2E3192")
.setDescription(`You cant advertise here.`);
message.channel.send({ embeds: [embed] });
``` can someone please tell me why my anti advertising isnt working
when i send something with https it doesnt send the embed
because you inverted the condition
You're essentially saying if message.content does NOT start with link
oh wait
I read that wrong
hold on
Okay
what's the exact message you're sending?
discord invites don't always start with https
you can do stuff in discord like discord.gg/dbl
ik but the one i sent did
Keep in mind that this will only work if the link starts with https. Someone can put a period and spaces and it won't work anymore
I would probably use includes instead of startsWith()
so it is includes(https)
includes(link) in your case
oh yh i forgot
Then all messages containing https will be blocked
it still doesnt work
Do you have code above that? You’re probably returning early somewhere
do you have the message intent? 👀
bot.on('messageCreate', message => {
if(message.author.bot) return;
let prefix = '>';
let MessageAray = message.content.split(' ');
let cmd = MessageAray[0].slice(prefix.length)
if(cmd.toLowerCase() !== 'mm'){ if(!message.channel.type == Discord.ChannelType.GuildText) return; }
let args = MessageAray.slice(1)
if(!message.content.startsWith(prefix)) return;
let commandfile = bot.commands.get(cmd);
if(commandfile) {commandfile.run(bot,message,args)}
let link = 'https';
if(!message.content.includes(link)) return;
let embed = new Discord.EmbedBuilder()
.setAuthor({ name: `SHARK automod`, iconURL: bot.user.displayAvatarURL() })
.setColor("#2E3192")
.setDescription(`You cant advertise here.`);
message.channel.send({ embeds: [embed] });
})
``` this is my message.create event
yes ofc
exactly
Yes, but what I mean is that if the message doesn't start with a prefix the rest of the code won't work
oh
So your link blocking code won't work if the message doesn't start with a prefix
how can i fix it
It's best to create a new event dedicated to blocking links
Because the one you sent is responsible for the commands
See how simple it is
yup i didnt taught abt it
but 1 more question
how can i make it that it deletes the link message that was sent
message.delete()
You'll just have to think about it a bit more because I don't know if you really want to block all links or just links from specific domains such as Twitter/Youtube
all
but i can add to my let link = 'https'; just let link = 'https', 'http, 'Https', 'Http', 'discord.gg'
Then it should work as you want, but keep in mind this invitation that Waffel sent
yes
No no
Thats bad
You'd have to have an array of these links, and you'd have to check if the message had one of them in it
You also don't need to pay attention to uppercase and lowercase letters because you can just convert the whole message to lowercase with toLowerCase()
Then you will get rid of this Https and Http
oh okay
http covers https too
This is also useful in commands because you want your bot to respond to both !ping and !Ping
just a side note, if your bot is in a development server with this code it will delete messages without links in them too.
http & https is talked about pretty frequently in dev servers.
That's true too
all images will be deleted too
ie
^ this would be deleted, since its just a link to an image
didnt understand that i just used the || lol
You can also do it this way, but learning how to use arrays is useful
A lot of things in discord.js rely on collections and arrays
i try to make when someone says hey or hi or something like that the bot will say hi back or something but then with random things
And that's what arrays are for
You can put e.g. 10 different answers in them and then by simple drawing a number from 0 to 9 you can choose the answer
ummmm
when i type https rn or something like that it keeps spamming cant advertise here
any chance the bot is activating its own message?
Okay
First of all, this let link is bad
It will always return the first thing
Second, you don't ignore messages from bots
should i do this then
how can i do that
oh
You have it in the previous code you sent, which is if(message.author.bot) return
Then the bot will not respond to messages from other bots
do i add my collector for my buttons in the same file?
By works you mean it blocks the link?
are you using the message.content.includes("something" || "something else")
because if you are that's why it's not working
i do
that's wrong
what do i need instead
let arrayOfBlocked = ["words", "you want to", "block"];
if(arrayOfBlocked.some(s => message.content.includes(s)) {
// do stuff
}
``` for example, I don't mean this to be a spoonfeed but this is the way I'd approach it
how do i make it delete a message in dms when i press a button
Of course this is not a hugely desirable as it will block any message that even so much as has this word in a subset of a full word
But it seems like what you're looking for
ig that is what im looking for yes
<button>.message.delete() most probably
…
???
How to add the same data(db) in anthor code?
like /setchannel /// set channel for alarm db.set
-- /deletechannel /// delete the channel from db db.delete
If your database supports multiple connections you can connect the same way twice.
I have a database assigned to my client, so I have access to it wherever I need it
I assume by another code they mean another program
I thought he meant bot commands and separate files
i mean this
send message or set channel discord js
What data I need
the channel id is all the data you really need.
does anyone know why i can still vote while not being user1?
const filter1 = i => i.member.id === gamedatabase[key].user1
const collector = r.createMessageComponentCollector( {filter1,
componentType: "BUTTON",
time: 10000,
max: 1,
});```
because filter1 is not a valid collector option
Also the component type... a string might not be parsed to the integer anymore by djs
Use the expect api value 2 or djs constants
Hello guys, how you doin?
How i can get this?
let replyObj = await interaction.reply({embeds: [embed], files: [new AttachmentBuilder( pngBuffer, {name: "card.webp"} )], components: [actions], ephemeral: true, fetchReply: true})
Always gives me error: unknown interaction
If you can not ensure to respond to the interaction within the 3s limit, than defer the interaction, execute your code (whatever it is since you didn't provide it) then respond by editing the reply (which was the initial deferring)
ty
More simply, before creating your image or fetching it from an api or whatever you're doing, defer the interaction
Then edit the reply once you're ready
i asked cuz i used deferUpdate() instead of deferReply()
Ah yeah that's only available for buttons the reset the initial loading state
So I am thinking of possible problems with my original thoughts on a messaging system. What should I do to prevent people from spam sending messages in a chat? Should I implement a queue system that will only send the rest of the messages if they aren't rate limited?
That can work but that's a bad idea, sending the messages after the rate-limit ends can send the message in a completely bad time and would most likely be out of context
Just block the message from going through with a short-lived pop-up that says the user is rate-limited
I see
That makes more sense
Also, what is RabbitMQ? I know its a messaging service type thing but I don't understand what practical use it can be used for
I've seen a lot of people use it in their messaging apps
it can be used for load distribution
and also cluster bi directional communication
I'll give Discord interactions as an example. Your master server receiving HTTP messages can send that message off to RabbitMQ to a specific channel and slaves that listen to that channel can decide who takes care of it probably through identifiers or first come first serve. This way, new slaves can be added to a super cluster without needing to add logic or configuration about new slaves
The master can be totally stateless
Okay but why would RabbitMQ be needed for something like that? Couldn't you do the exact same thing without it
You could if you so desired, but you might need some other intermediary system for relays which is what RabbitMQ is or do peer to peer through configuration which might facilitate a restart among nodes to know who to communicate with
So RabbitMQ is simply a means to broadcast real time data to multiple endpoints?
Basically. And there are multiple channels which can have their own message queue so slaves can listen to specific ones and be specialized, but all of the messaging being centralized
Mmm so an example would be a channel for specifically handling Discord Interactions
And another for whatever like communications or receiving gateway events
and those slaves attached to the channel would only process any message sent on that channel ignoring others
yup
there's also acknowledge systems so if a message isn't acknowledged, it's resent
So the master is what a user would request to e.g me sending a message and then it gets sent to the slaves for them to process
Yup
This makes more sense
its really scalable
No. WS operates over http which isn't the case with RabbitMQ
http has its own overhead
How does RabbitMQ operate?
I need to learn networking ong
Seems like a valuable skill
I have no idea what TCP and UDP actually are
most realtime games use UDP because of throughput and having packets being guaranteed to be received isn't totally necessary as rubber banding happens
TCP has systems in place to ensure packets are received
through acknowledgements
windows firewall
You have no idea what you're talking about
even I can tell that is invalid
actually i do i use TCP and UDP for my GTA 5 servers
I know I do have to open some ports on my linux machine specifying the protocol for my rust server
totally unrelated to what we're talking about
It uses TCP and UDP, UDP for the game port and TCP for the rcon stuff
thats as far as I know what TCP and UDP are tho
just saying UDP and TCP are on both Inbound and Outbound rules of the windows firewall
stuff like movement and such can be shoved on UDP since it needs to have less overhead
that contributes nothing to the conversation.
Anybody know anything about InfluxDB on linux systems?
What do you recommend me researching btw?
I wanna learn more about networking
Especially since I plan on doing multiplayer games in the near future
Games and just networking in general, especially those on linux systems
Well. Looking up how to setup UDP connections is handy to know and how you can build on top of it and make use of its throughput should the packets arriving to clients not be critical
TCP: here, please take care of this package, understood?
UDP: here takes this and fuck off
TCP is still really good though and is more than just message acknowledgements
this made me cackle
Do not try to understand HTTP's systems tho. I made the mistake of trying to write my own client based off raw tcp sockets and I wanted to off myself
Start with learning about what network layers are, which ones exist, about how tcp ip works, other protocols etc.
In a few years you should be good to go 
while you're at it, researching micro services is really good instead of going with standard monolithic designs
monolithic meaning? (I know I could google but youre here /s)
now to google what vertically means in this context
Spreading the load across multiple machines is horizontal scaling
Oh right
having everything on the same machine is vertical scaling
Vertical is when you try and beef up the current machine to handle it all right?
I remember someone mentioning that now
they said postgres was horrible at vertical scaling or smth
a monolith is a single large block of stone. Monolithic isn't exactly the best word to use for vertical, but it's what popped in my mind first
latin go brr
English is derived from latin
science periodic table lol
is what i thought of latin for some reason
Periodic table is actually from greece isn't it?

no latin
or at least a lot of the scientific naming are from what I recall
i think
This is getting de-railed
no i think there was a russian scientist
Indeed
german*
yep
Anyways back to the topic at hand
I need to go back to using RabbitMQ actually
Is RabbitMQ what discord uses or do they use something else?
I know they use a mix of different tech
All I know is it's an insanely good messaging broker
Ima try it out for my chatting app
Oh god docker
How the hell does docker work
another thing I dont really understand
I haven't used docker so idk
The basic idea is automating app setup and containing it in it's own space in disk/memory/cpu
@lament rock Installing rabbitmq seems tedious
It was a pain in the ass, but once it's setup, it's good
https://rabbitmq.com/install-debian.html#apt-quick-start-packagecloud should I just follow from here on or?
So wait rabbitmq is not a replacement for a websocket implementation right?
It just works hand in hand correct?
its not a replacement and it doesnt work hand in hand
Well I mean it kinda could be
So how would it work exactly?
Kinda hard to describe other than what I told you
Just a socket of sorts
but websockets are http
Mmmm
So how would i implement rabbitmq in a chatting app efficiently
That is my only question now
Something that involves broadcasting messages to multiple workers
😔
This isn't helping me wrap my head around how it works
Alright so let me put it this way
I would be using a websocket implementation with a rabbitmq implementation as well right?
User Sends Message -> Websocket Transports Message to RabbitMQ -> RabbitMQ process the message -> RabbitMQ sends the message to all clients via the Websocket
This is my understanding of how it works
no websocket
websocket is http
rabbit mq is not http
You are using a UDP socket most likely
There are sockets other than websockets
just call it some network interface
ok then I have a lot to learn here before diving in if I wanna use rabbitmq
const query = require('samp-query');
const AsciiTable = require('ascii-table');
module.exports = {
name: 'serverstat',
aliases: ['player'],
description: 'Lists all online players if players number is lower or equal 100',
run: async (client, message, args) => {
const server = new query('217.106.106.86', 7002);
const getPlayerList = async(message)=> {
try {
await server.open();
const playerList = await server.getPlayers();
const table = new AsciiTable();
table.addRow('Player ID', 'Name');
playerList.forEach(player => {
table.addRow(player.id, player.name);
});
const embed = new MessageEmbed()
.setTitle('Server Players')
.setColor(0xff0000)
.setDescription(table.toString());
message.channel.send({embeds:[embed]});
server.close()
} catch (err) {
console.error(err);
}
}
setInterval(getPlayerList.bind(this), 5000);
}
}```
in this code when is use callback.apply is not a function error
any one please help
please ping me
Show us the full error
wait
The second parameter of samp-query module's default function (you declared it as query) expects a function
bro can you come my dm please
Sure but why?
i have one doubt please come
Alright
samp-query?
I’m getting a Cannot GET /login on my ejs website
<%- include(“./partials/header”); ->
<head>
<title>RocketX Dashboard</title>
<link rel=“stylesheet” href=“/dashboard/public/style.css”>
</head>
<h1>
Title
</h1>
<body>
<h1>Hi</h1>
<button><a href=“/login”>Login</a></button>
</body>
<%- include(“./partials/footer”); -%>```
do you have a page with /login as the path?
for the love of god learn to screenshot
yes
my computer is offline
so, if you go to localhost:port/login
it loads a page?
no
then the issue isnt this part of your code.
idk what’s causing it
how do i make a string option on slash command required?
bc i tried .setRequired(true)) but it says invaild
It's not set as a GET endpoint
did anyone ever work with chakra ui + nextjs before? Im trying to make color switching look smooth but transition-all doesnt seem to work, is there any other way?
This may have happened because you gave the required option, for example, at the very end. Required options must always come before optional ones
You'd need to send the error code and your command code so we can find out more about why it's not working for you
HTML page likes to scroll to 0, 0 after an element was added
How do I make it not scroll to 0, 0
scrollY and scrollX are both 0
No height: 100% css rules
I've got height: 100vh; 
100vh height will make it impossible to ever scroll the page
How many interaction types are there?
does anyone know why this happens in nextjs? it seems like tailwind styles are lagging behind
okok, thank you
modals too
I hope, they will add new types to discord
like pop ups, looks like modals but don't have inputs
what would be the point of that, just send an ephemeral message
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Popout thingy looks better :D
yeah kinda, only if people abuse it (they will)
couldn't really be abused
they could have ratelimits
how would someone abuse them?

