#development
1 messages · Page 98 of 1
hey in java is it actually possible to return a custom type?
I wanted to create an extended instanceof method, so basically something like:
public Type typeOf(Question x){
if(x instanceof MultipleChoice) return MultipleChoice;
if(x instanceof openQuestion) return openQuestion;
}
Interfaces
no but you can return a class (tho classes are Types) instead
nonetheless, instanceof is always a single-op operator
u cant use variables with it (on the second part)
Create an interface, create two classes that implements it, e.g. MultipleChoice and return them with return type being the interface
What is Type as return type then?
right now, i am keeping a list of all questions, but as you may expect the inputs expected by the logic handler are different, thus i wanted to use like instance of or something to check which input to use
type would have to return MCQuestion and OpenQuestion ig?
No, Question since they both extend it
instanceof checks for hierarchy too, not only the top-level class
so if u did something instanceof Object it'd always return true
because all classes extend Object
i am calling super on the question abstract class, basically the daddy of my other 2 question classes.
is there a way to actually detect how many objects i have added from type "MCQuestion" for example?
iterate
then check for obj instanceof MCQuestion, it it returns true increment a counter
aight thank you it worked!
Would it btw be a good practice to create a interface to hold constant values?
I for example want to use 3 final values in 2 classes, would it be good to set them in that interface? It seems nicer to eliminate duplicate code
Constants? No point in it really, I would just have them as static members of a helper class or something of that sort
alright, thank you
how would I get the latest entry using .get() with better sqlite
there are many ways to do that
each has its pros and cons and depends on how the db is setup
one way for example is select * from table_name order by row_id desc limit 1
but that doesnt work for tables created with the ``WITHOUT ROW_ID " constraint
row_id is a hidden column that sqlite creates by default
I do that sometimes to make it easier to understand what they mean
also, depending on your autoinc settings, row_id is not always guaranteed to be ordered in insertion order
but most times it is
Like, my Drawable interface has HEIGHT and WIDTH constants, so I can access using Drawable.WIDTH for example
Nothing more than convenience
SqliteError: no such column: row_id
☹️
...
i don't think so
Eh, nvm then
if you do it imma do it
Just keep it in context, for misc stuff use a constants abstract class
Static constants get thrown into the same place during runtime anyway, what matters is that you keep it intuitive/easy to understand
yeah got it!
like, i was using a lot of constants over several classes and the only way i knew on how to import those variables so that i didn't have to constantly redeclare was using an interface
For general constants just make a Constants class
Make it abstract so the compiler doesn't need to worry about instantiation
U can also make it final, to tell the compiler there won't be subclasses
https://github.com/OtagamerZ/ShiroJBot/blob/rewrite/src/main/java/com/kuuhaku/Constants.java this is mine for example
is it normal that my bots stop playing music 2 minutes after connect?
no
I suppose ur using lavalink
works normally
any error in lavalink side?
distube
does distube run in a separate process?
which is faster
LavaLink if you care about filters, Volcano otherwise. They're both under the LavaLink protocol so any LavaLink wrapper works
lavalink supports spoti and soundcloud?
But I can guarantee you that trying to do audio yourself will not work
both support spotify through plugins. Volcano comes with one by default, LavaLink you have to download. SoundCloud is a built in source
good event everyone
I am in need of help with the Lracer bot
We need an admin bot for our league races
wait
misread
anyways
this is logging empty, any idea why?
const channels = guild.channels.cache.filter(
(channel) =>
channel.type === "text" &&
channel.permissionsFor(botMember).has("VIEW_CHANNEL") &&
channel.permissionsFor(botMember).has("SEND_MESSAGES")
);
console.log(channels);```
Collection(0) [Map] {}
What discord.js version are you using?
v13
The channel type is called GUILD_TEXT not text
https://discord.js.org/#/docs/discord.js/v13/typedef/ChannelType
thanks ser
But you should definitely update to v14
worked! thanks ser
You're welcome
Here's the migration guide
https://discordjs.guide/additional-info/changes-in-v14.html#before-you-start
dope thanks ser
i found the error https://github.com/skick1234/DisTube/issues/294
const channel = message.channel;
const botPermissions = channel.permissionsFor(message.guild.me);
if (!botPermissions.has(Permissions.FLAGS.SEND_MESSAGES) || !botPermissions.has(Permissions.FLAGS.EMBED_LINKS)) {
try {
await message.author.send({
embeds: [
new MessageEmbed()
...
],
});
} catch (err) {
console.log(`Failed to send DM to user ${message.author.tag}: ${err}`);
}
return;
}
Very sorry :(((
I added await and catch but when I testing on me, this is work only one time, in the next time it still appear mission permission, it still happen until I reset the bot
TypeError [ColorConvert]: Unable to convert color to a number.
at resolveColor (C:\Users\James\Desktop\bots\AlightLineStudiosBot\node_modules\discord.js\src\util\Util.js:486:39)
at EmbedBuilder.setColor (C:\Users\James\Desktop\bots\AlightLineStudiosBot\node_modules\discord.js\src\structures\EmbedBuilder.js:22:36)
at Client.<anonymous> (C:\Users\James\Desktop\bots\AlightLineStudiosBot\index.js:43:2)
at Object.onceWrapper (node:events:628:26)
at Client.emit (node:events:525:35)
at WebSocketManager.triggerClientReady (C:\Users\James\Desktop\bots\AlightLineStudiosBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:385:17)
at WebSocketManager.checkShardsReady (C:\Users\James\Desktop\bots\AlightLineStudiosBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:368:10)
at WebSocketShard.<anonymous> (C:\Users\James\Desktop\bots\AlightLineStudiosBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:194:14)
at WebSocketShard.emit (node:events:513:28)
at WebSocketShard.checkReady (C:\Users\James\Desktop\bots\AlightLineStudiosBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:520:12) {
code: 'ColorConvert'
}
Node.js v18.12.1``` Error
Code ```js
client.once(Events.ClientReady, c => {
const LoginEmbed = new EmbedBuilder()
.setTitle("Logged In")
.setColor("GREEN")
.setDescription("Ready!")
const LoginChannel = client.channels.cache.get("1081441525315158086");
LoginChannel.send({ embeds: [LoginEmbed] });
});```
use the colors enum
then make it not automatically move the vc
😵💫
I met strange situation
which bot has demand on discord?
demand on discord? What?
how long until my bot pfp refreshes?
On Top.gg?
ye
also
does anyone know if it's possible to store true / false in SQLite
i have to save also?
🎉
There's no boolean data type in SQLite, you have to store them as 0 for false, and 1 for true
Time to annoy voltrex and say "just store in a string, then case it in your code"
I'm currently approaching to your location for a secret punishment for you
hi brother, you are here, well if my memory not wrong, I also met this problem once in past and don't know how to solve
Currently away 20 km
19 km
15 km
Approaching rapidly
200 meter
Yes, you'll definitely love the punishment :^)
running
no one here can do anything
Oh
^
INSERT INTO table_name (bool_column) VALUES ((? = 'true'))
...
@hushed robin
const channel = message.channel;
const botPermissions = channel.permissionsFor(message.guild.me);
if (!botPermissions.has(Permissions.FLAGS.SEND_MESSAGES) || !botPermissions.has(Permissions.FLAGS.EMBED_LINKS)) {
try {
await message.author.send({
embeds: [
new MessageEmbed()
...
],
});
} catch (err) {
console.log(`Failed to send DM to user ${message.author.tag}: ${err}`);
}
return;
}
The exact situation I met (I can't fix this even trying 10 + ways is after sending DMS to a user (even success or not), if a user exercute command fail in next time, in each channels the bot missing permissions it won't DMS users (except I reset the bot)
@earnest phoenix Sorry for ping but do you ever meet this case before?
(you can also use Boolean operators like AND, OR and NOT to compare between two Booleans as expressions and return true or false values)
what
for what
for this
⁉️
I don't see the issue there so you might want to send more code, and I would heavily recommend updating to discord.js v14
Here's the update guide from v13 to v14
https://discordjs.guide/additional-info/changes-in-v14.html#before-you-start
No issues with code but issues with user who exercute command 2+ times
That's an issue with the code
the log showing like this instead of it should send to users as much time as errors happened?
yup
If I exercute commands fail in x times there is only a warning
it never change until I restart the bot
As I said, you should send more code
The solution is this but I don't want to do that
I think problem is return is not working right, this should never happen
I think you're misunderstanding what's even happening, if the bot doesn't have those permissions in the specified channel it'll always try to DM the user about or catch the error and log the thing you specified, and return, there's nothing wrong here
I have test on myself, in the first time it work as you say but from the second times, there is no DMS sent
The error you sent here is coming from something else
The log show missing permission? (why it pass the step sending messages to user from 2nd time and exit the process)
I'm quit of this, I will remember this is one of the strangest problem I met in the life, nothing much effect to the user
And because of this error I'm making this (bring bug to feature :)) )
Try putting logs in your command code, and see how many times it logs when you use the command multiple times
one
At the start, at the middle, in the if statement bodies, at the end, and see for yourself
for the case the bot can't send the DMS to user, in the first time it log like normal, in the second time+ "it changing to missing permission log"
I got what you said, but that's not what I'm talking about
I'm quit of this :((
Wasting 1 hours and bring nothing
return is a problem of this, if I put return out everything should be right, working well but the after functions will run
You're not properly debugging your issue and only trying random things to try to fix it, you shouldn't do that
I don't see how the return statement would cause any of this unless you're handling the returned value of the run() function you have accordingly, try putting logs in multiple places and then you'll most likely figure out the issue
Thanks for your reply, actually I try to bring that "return" to everywhere and it still cause problems
I will try to put some console.log();, but I think my problem can't solve like this
It is like that return is making the bot do a time then he will pass that block if user met the error in next time (except reseting the bot)
Because I'm requesting API with a high fee so I can't like remove the return function
Sounds I can solve and can't solve the problem :))
Logged something like this
I blocked the bot and then use commands twice
✅ First reply the log show: Failed to send DM to user Makoto-kun#4120: DiscordAPIError: Cannot send messages to this user
❌ Second reply the log show: [antiCrash] :: Unhandled Rejection/Catch
DiscordAPIError: Missing Permissions
at RequestHandler.execute (/app/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/app/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async TextChannel.send (/app/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:176:15)
....
I quit right now, nothing I think I can do to fix this :((((
You didn't do what I said
hey can anyone please suggest me a good python lib to download youtube audio? Youtube-dl seems outdated and pytube is just very slow
YouTube-DL is not outdated, they only provide an outdated binary, it's repository has lots of new commits and you can clone it using Git and follow the developer instructions
https://github.com/ytdl-org/youtube-dl
Command-line program to download videos from YouTube.com and other video sites - GitHub - ytdl-org/youtube-dl: Command-line program to download videos from YouTube.com and other video sites
the Bot Developer way to fix your problems™️
Fr 💯
literal bogo sort
gotcha thanks, but im still reading some complaints that the download is slow
It's gonna be "slow" with pretty much any downloader given that YouTube doesn't like anybody doing this
And that Python is slow in general
Mm dem, thanks
for some reason my bot stops playing after 1 minute, can u guys help here?
Lemme guess, distube?
^^^^^^^
What package are you using in your bot?
There were a bunch of people here with that exact same issue
wdym what package
i use discord.js
@discordjs/voice for voice thing
Usually, external packages are used to listen to music/radio, which make it easier to manage the radio/music
A Discord.js module to simplify your music commands and play songs with audio filters on Discord without any API key.. Latest version: 4.0.4, last published: 5 months ago. Start using distube in your project by running npm i distube. There are 17 other projects in the npm registry using distube.
Distube is one such package and is quite popular among bots
yeah, ik Distube
What should I write here?
The truth, why you need to have this intent
I have no words to say, 
then why apply for the intent
are u apply for intent ?
what
"plz give intent"
Just describe what you need the intent for. I'd recommend searching what other bot devs entered / needed the intent for so you know what they'll accept and reject (most of which is rejection)
if you dont actually need it, dont ask for it kekw
⤴️if you need it you should know why
[using linux]
ayo, I have a little script named test.sh just containing the the command pdw
when I run this script now this error gets thrown: ./test.sh: line 1: $'pwd\r': command not found
does anyone know why this happens?
does your script start with a shebang?
like #!/bin/bash
ah thanks, it didn't and adding one fixed it 👍
👍
whys this returning undefined
nothing in data was found with that path?
how tho
Because we don’t know your setup and the context behind this question :p
the path is correct
☹️
typing and thinking
are you ok? why are you always saying random things
because they are only random to you
no they’re random to everyone
no it’s not
anyways someone help
:lutune:
how i can display image from url in req res api?
i want to fetch image for my website from my api
please do not ignore warnings
because ur using println with a leading \n
I told u before, println already includes a newline
please hurry
this is disrupting my day a bit and it would be much appreciated
be back in about 50
you want to download the image in your api then send it to the client?
or you want a redirect to the original image?
or you have an image in your api and want the website to display it directly?
app.get("/api/avatar/:id", (req, res)=>{
const member = req.params.id;
const image = await client.users.cache.get(member).displayAvatarURL({ format: 'gif' }) ?? "https://cdn.discordapp.com/attachments/1014351794496884797/1081725502781394994/giphy.gif";
});
İ have this code
Member avatar url and another image url
For example
İf i share image in this channel and copy image url, url display as image automaticly
İ want this system in my api too
İf i added my api url to my website image href then it must display as image
My eng bad sry
one way you can do this is using redirect:
res.redirect(image)
this will make your browser do a redirect to that image url, so it will make two connections, one to the api and another to the redirected url
another way is to download the image inside the api and then send the image data directly, for example using fetch inside the api, or using https.request, and then download the image data inside the api, and then res.send(downloaded image data) with the proper mime type header
you can also download the image by connecting the streams, which is a little more efficient
I've been trying to get dbls to work all day, and I've had no luck. Can anyone help me?
In terms of top.gg, I'm setting the webhook url to something like this (https://domain.webhook)
(I'm not using any authorization right now)
Then, in terms of the code, (I'm in python) I have this:
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/https://__domain__.webhook") #obviously, that's not the real thing, but it's the same thing that the top.gg webhook url is set to.
bot.topgg_webhook.run(500)
@bot.event
async def on_dbl_vote(data):
print("Yay!")
But, whenever I use the send test button, nothing happens. I think I am not understanding something, because I don't know where to put my webhook token that top.gg gives me. Any help would be VERY much appreciated.
yeah your webhook token is missing, you can put it like this:
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/https://__domain__.webhook", webhook_token="your webhook token", webhook_port=5000)
that url don't look right
it's not. I'm not going to release the actual url
thanks. I'll try that
fr
always. You can check their documentation for more information: https://topggpy.readthedocs.io/en/latest/api/webhook.html
Thank you for your help.
Unfortunately, my version of topggpy doesn't seem to like the code.
WebhookManager.dbl_webhook() got an unexpected keyword argument 'webhook_token'
based on their documentation, it's changed:
webhook_manager = topgg.WebhookManager()
endpoint = (
topgg.WebhookEndpoint()
.type(topgg.WebhookType.BOT)
.route("/dblwebhook")
.auth("youshallnotpass")
)
.auth is the new webhook_token
iir
it is yes
oh then
they are the same thing
there is no other token
the only token/auth/pass there is is the top.gg authorization
ic
I think there has to be, because that fix didn't work.
@minor olive u should add a value to the authorization thing
k
to this
I'll try that
yeah, that's still not working.
I'm still confused as to where we're putting the webhook token that top.gg automatically generates.
does anyone know a good package to remove HTML from a string 🤠
import topgg
# This example uses tasks provided by discord.ext to create a task that posts guild count to Top.gg every 30 minutes.
dbl_token = 'Top.gg token' # set this to your bot's Top.gg token
bot.topggpy = topgg.DBLClient(bot, dbl_token)
what token that top.gg automatically generates?
what programming language
but ty
js
too difficult
or the package itself validator
ok
oh, so that token is for setting the server count and such, but not for webhooks. Those are separate. Right?
yes
yeah, it's still not working. This is my code:
bot.topgg_webhook.run(500)
@bot.event
async def on_dbl_vote(data):
print("Yay!")```
check the documentation
can a que be changed from one array to another easily?
Perhaps I'm setting up my webhook wrong. How do you actually create a webhook url? I mean, what I've done is I've gone to my website server, created a new file called webhook, and I've just been using that (https://domain/webhook).
Do I need to do something special?
i wish i could help here but im not the best to answer this
i can try to find the answer in a bit
@hushed robin any ideas on this for cypress?
or are you distracted
no
are you ok though?
why are you friending me
very much
hahaha sorry by bad man
i am just using the term battleless for a project
i thought you were a bot
???
please leave me alone sir
will do
thx
i apologize
while i'm here
confused
why does https://api.steampowered.com/ISteamUserStats/GetNumberOfCurrentPlayers/v1/ work in the browser
but when I try to request it with axios I'm getting a 404
the same url with the same parameters?
response.statusCode or .status or something like that
Yes
it's returning undefined 😵💫
Then you’re doing it wrong
oh wait
nvm
yeah
i just realized
that i'm not returning the full response
only the data
⁉️
how is it undefined
show the surrounding code
the request?
oh wait
i just realized test is returning undefined
how can i get the status code
if the response won't return it
☹️
can't u just use fetch?
?
don't think cjs would force u to use a heavily bloated library
what should i use then
but anyway, your answer is this
what's wrong with it
it's response.data to get the body
also, u don't need { return ... }
nor .then if ur gonna return the very thing it's passing as argument
what ur looking at in the image is the response body no?
what was it?
well
catching the error and returning it to check the status
nvm
that doesn't work
only works when it errors ☹️
so what library should i use if axios is bloated
node-fetch
or @aero/http
which i love
const http = require("@aero/http")
const test = await http("url").json()```
so does this work the same as node-fetch
aero/http examples ```js
// POST
const test = await http("url").post().json()
// text
const test = await http("url").text()``` etc
yes
Ah yes because swapping libraries will definitely fix the issue caused by your lack of attempting to debug things before asking in a server
I'm pretty confused as to why it wasn't accessing response tbh
yup
hm, what's the line before this?
it fixed it
but thanks for your input waffle
🥰
👍
i can now get the status code
whats this
your image
which one
^
my guess is that it wasn't test.response.status because it had another parent
but u never send full images anyway
im not dumb
👀 man, typescript would make these things so much easier 😉
i can read it very clearly
why
waht is types cript
☠️
statically-typed values is always great for debugging
anyways
lol
that's also part of the reason I think js/python aren't good for beginners
simply because they let u ignore proper value typing, which makes it harder when switching to static languages
and builds pretty bad habits
I mean, ts was very easy to learn from js.
but yeah, the habits are awful
until they learn about : any
then it's js all again 
Thats one thing I thankfully dont do
That also just defeats the purpose of ts
It’s useful sometimes if you know what you’re doing but most of the time it leads to bugs
But I certainly have a couple dozen type errors in my dev environment right now that I'll have until I try going to production.
Which is also an awful habit I need to fix 👀
Just one file.
https://i.imgur.com/BmjiHK2.png
lmao
In dev yeah
typescript is just javascript with types
u forgot to respect types
I'm not sure how to do properties on an event target
Which I'll have to look into at some point.
Which is about 19 out of the 21 errors here
This is why people should learn statically typed languages first
“Oh no type error!!! I cannot solve this as I have never directly worked with types :(“
I dislike the C family, but C itself ain't bad as a first language
how many rows does it take for sqlite to get slow
i have 110k rows and it's pretty fast still
110k is nothing
fr?
a speck of dust in a beach
good to know
so unless i work with very big databases i won't have to worry about indexing n stuff right
no, u always have to worry about indexing
the topgg library should create a webhook server for you running on a specific port, in your case you're using port 500.
the dbl_webhook option should not be the full website, it should be the desired path only.
the webhook url you should write in the top.gg website should be an url that can reach the server where the topgg script is running
it's just that you'll never have enough data for the size to become a concern
yah
but having a bad structure is still a problem
so no need to worry
you have to worry
bruh
just not about size
because it'll compound when u have enough movement
Where on earth did you manage to get 110k rows from??
"a little bit slow" becomes "a huge pink elephant in a tunnel" when you start making many operations per second
A few days ago you said you had 300 rows
this is a different project
Ah
i have all steam applications in the db
how long is it taking to retrieve a single entry?
run using SELECT * FROM <the table> WHERE <the id> = ?
^
why
because I want to know about a single entry
ok
well, it seems i calculated the above wrong
it takes like
70ms
on average
i don't think that's too bad
That’s terrible
it should be around 1-3ms at most
That’s like slower than a fast api response on the internet
indexes
and pkeys
70ms might not seem big, but that's because ur the only one making a transaction
when u have like, 100 requests per second (which is low) it'll start compounding into a bigger issue
i'm confused
how is SELECT id, name FROM applications WHERE name LIKE ? LIMIT 25; quicker than SELECT * FROM <the table> WHERE <the id> = ?
its all about the position in the table
without indexes it does a full table scan
more = less time ⁉️
if the id you want happens to be near the end of the table, it will take longer to reach it
sql size doesn't matter for performance
u can have smaller queries that are much slower than bigger queries
if it finds 25 names like ? near the beginning of the table, it will be faster
since u don't have indexes, I imagine u also didn't make the id unique, so it'll go till the end of the table regardless whether it found one or not
the IDs are unique
since it'll suppose there's the possibility of having more than one row with the same id
theres not
u made them unique?
yes
if the id is the primary key, then its indexed by default
you have to set a primary key right
also guys
what's the best way to store things in cache, i haven't really worked with it before. is there any good guides.
well
Caching can be complex or it can be as simple as a hashmap
i wanna store data in cache from an API so if someone repeatedly runs the same command it won't repeatedly send requests to the API
but i wanted to make it so there's a refresh time, so if it's past that time, it'll fetch new data
okay
with it u can set a ttl (time-to-live) based on insertion
so when it "dies" it gets removed from the map
hm, look for another lib then
just search "expiring map npm" or "ttl map npm" in google
ok
should pop a bunch of results
you talking about this? https://www.npmjs.com/package/expiry-map
github?
npm
Yes, thank you. I've been doing some digging, and I think I was mis-understanding how these webhooks worked. I didn't fully understand what webhooks even were, but now I think—with this information—I should be able to figure it out soon.
Thank you for all your help.
ah this seems good https://www.npmjs.com/package/map-age-cleaner
well thank you guys 👍
You can also use https://www.npmjs.com/package/lru-cache
ok, now that i'm looking into those, i don't think they actually cache anything?
how do i store something in cache? is there like a mozilla page or something with all the information.
"cache" is just a collection that holds temporary data
Anything can be a cache
When they say "cache data" they just mean holding onto it for a while in case someone requests it again
A ttl map is a good option because it automatically removes old entries so you only have to worry about checking if the entry exists or not in it
yeah but
idk how to set cache
You don't "set cache"
You simply add the received data onto the map
And return it whenever someone requests that specific data
It isn't automatic
I don't really understand
when I think of cache
I think of a database but temporary and stored in memory
is that not what it is?
but how do i make it cache?
"cache" isn't a thing, it's a purpose
A folder can be a cache
A box can be a cache
A discord channel can be a cache
You simply put recently used stuff in it and reuse it until it expires
You're not understanding because you lack the necessary experience that'd be gained from studying programming
Because you're thinking of cache as an object
Cache is a concept, not something material
Just like you say "that car is red"
You can say "that map is a cache"
Because bad configuration
Idk how to put it in a dumber way, you literally put shit inside the cache when you first access it, then reuse that specific shit until it expires
hm ok
but this
Was answered by this
What is the extension?
what
File extension
Then it's bad configuration
what is "bad configuration"
Configurations that weren't done properly
that's entirely dependant on how u set up your editor
Which I can't help
doing this
...?
is there a better way to do
Mind to explain what you want to achieve?
what i'm doing in the image
well
Don't ignore this btw
what it does is exploit something with discord to allow multiple images in an embed
You're using a global variable for it atm
You're just sending multiple embeds
no i'm not
read
Yes?
Not from what I see from the code
Discord just coalesce them into a single message
It ain't no exploit, it's just what they added after the last update
well
why doesn't discord just allow you to send an array of images then
instead of this
Because embeds can only have a single image
then why does my embed have multiple
Because the front end coalesce them
No, it's still 4 separate embeds
it's not
The front end just shows as 1
yeah so my point is
if you can do that to make it look like there's multiple in one embed, why not just allow people to send an array of images
Because as I said, embeds can only have a single image
That's not a single embed, it's multiple embeds coalesced into one
But in the back side it's still multiple embeds
You see it as one, but it's not one
Me? You're the one with impossibly dense understanding skills
😁 seems like u do too
How hard is it to understand that what you see in the net isn't necessarily how it is from the back side?
Embeds can only have a single image, period.
What it happens is that discord shows them as one but they are still separate embeds
If you retrieve the embeds from the message, you won't get 1 embed
You'll get 4
yeah but
No but
Doesn't matter
it does matter
It doesn't
it very much does
What you see isn't constrained to what it really is
You could edit discord page background color and make it pink
It wouldn't mean discord is pink
Discord could show messages as audio files, wouldn't make messages audio files
A very simple example, discord shows YouTube links as embeds with video
It doesn't make embeds support videos, it just shows like that
🙈
Yeah go on, for someone who can't even understand what a cache is after many examples I was expecting too much of you
I don't even know why I bother interacting with you at all, it always end with the same moronic statements
my bad bro, i will force my brain to understand next time 🧠💪
what is going on here today
im quite confused battleless
looks like it sliped out of your hands again
just kidding
youre trying your best
and thats what counts
@hushed robin pallendromes
😳😳my bots finally in the verification server
[CMD Ran] - Embed Command Ran by TW rblx, Title: hi, Message: hi, Server: LLRP | Blaine County Sheriffs Office, Color: null
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const clc = require("cli-color");
module.exports = {
data:new SlashCommandBuilder()
.setName("createembed")
.setDescription("Staff+")
.addStringOption(option =>
option
.setName("title")
.setDescription("Embed Title"))
.addStringOption(option =>
option
.setName('message')
.setDescription('message for embed'))
.addStringOption(option =>
option.setName('color')
.setDescription('Color')
.addChoices(
{ name: 'GREEN', value: 'Green' },
{ name: 'RED', value: 'Red' },
{ name: 'YELLOW', value: 'Yellow' },
)),
async execute(interaction) {
const msg = interaction.options.getString('message') ?? 'No Message provided';
const title = interaction.options.getString('title') ?? 'No Title provided';
const color = interaction.options.getString('setcolor');
//const embedchannel = interaction.options.getString('channel');
const embed = new EmbedBuilder()
.setTitle(title)
.setDescription(msg)
.setColor(color)
.setFooter({ text: `Server Name: ${interaction.guild.name}, Ran by ${interaction.user.username}` });
await interaction.reply({ embeds: [embed] })
await console.log(clc.blueBright("[CMD Ran]"), clc.greenBright("-"), clc.yellowBright(`Embed Command Ran by ${interaction.user.username}, Title: ${title}, Message: ${msg}, Server: ${interaction.guild.name}, Color: ${color}`))
}
}``` for some reason it wont set the color
And it got verified 
because the name is color
and your trying to get the option named setcolor
im so stupid thank you
it's ok i'm stupid too
LOL
😝
Heya,
I want my bot to reply if a user has an already open ticket. But instead it creates another one.
Plz tell me why it isn't working?
Because there's no channel with that name, note that usernames can have capital letters, spaces, and more that are not allowed in a channel name
Oh yea
hey so im using ngrok and safari doesnt seem to be setting cookie
but it works on chrome
any solution for this?
(await client.users.fetch(userID))?.displayAvatarURL({ format: 'gif' })
it giving .webm format
how i can fix. i think its about v14
it not work
oh it work but format not changes
The format option was renamed to extension in v14
but if avatar not gif it gives http error 415
in v13 its works well
how i can make if member avatar png then png if gif then gif
in my old code if member avatar is not gif but i writed format gif. then it display as .gif url but its png
u can do it like this:
const extension = avatarURL.substring(avatarURL.lastIndexOf('.') + 1);
iirc
it gived avatarurl not defined
ofc you need to change the variable
it works but
now
if bot cant fetch member avatar
it brokes my code
(await client.users.fetch(userID))?.displayAvatarURL({ extension: 'gif' }) ?? another;
give me ur code
another is image url
wdym "brokes"?
as u can see
some avatars are not displaying
bcs bot didnt fetched their avatar from client
so in my code
"?? another;"
means
if bot didnt fetched then display this image
but your code brokes it i think
no it doesn't
yep i see now
i console logged these
your code works well but
i dont know why it not use "another" variable if member avatar null
because it is never a null
your extension: 'gif' won't work
instead place the const extension above the resim
then change 'gif' to extension
maybe the member's avatar url isn't a gif
The extension option cannot be gif, it must be either one of jpg, jpeg, webp, or png
ah I see
never used the extension or format option before so
There's the static option which you can use to set whether or not the GIF avatar should be returned if any is available instead, ignoring the extension option
Try { static: false, extension: 'png' }
thanks now works fine
but again "?? another" doesnt work
if member avatar is null
const another = thisgifimage
if member avatar = null then this image displaying but not wrks
The displayAvatarURL() method never returns null nor undefined
It either returns the avatar the user set, or their default avatar
If you want it to return null when they have a default avatar, use the avatarURL() method instead
its not about default avatar
for explain
if member doesnt in server. bot cant fetch member data right?
so i want if bot cant fetch this member data then .....
You're using the <Client>.users.fetch() method, it fetches any Discord user regardless of them being in the server or not
oh
then
ill tryed ur code but it gived avatarurl is not function
i fixed
works now thanks
hi everyone,
I realise that the policy is worse than I thought for bots (bot live matter),
I really didn't know that a link was a security breach
so I wonder, is an image a security breach too? do I have to specify everywhere that it generates images?
besides that, my bot has a model that allows it to talk with a user (when the user @ it), the context of the discussion doesn't follow but the fact that it can answer is serious?
sorry if this is the wrong channel by the way, tell me I'm not sure
no
hey how would we parse a \/ b /\ c?
A what?
where the first operator stands for or, second one for c
i thought that it would be a or (b and c)
because or has a higher priority than the and
Tf ur talking abt
it's discrete math
talking about boolen algebra or whatever it was called
Parens always has priority according to bodmas
owh fr
Brackets > order > division/multiplication > addition/subtraction
so we work from inner parantheses to outer?
Yes, like programming
so a or b and c would basically become: (a or b) and c
brevv i am fucking stupid
i took this course 6 months ago and i forgot everything already
yeah, i got confused tbh'
especially with the presedence of the operators above
for example a implies b and c or d
that would become (a implies ((b and c) or d))
8 in binary is 1000 right?
How would we get 08 then?
-8*
two's complement and then a yielding of 1 bit?
eventually extension to 8 bits to value it's binary comprehension?
negatives can only be done with signed integers
and a signed integer needs to know its total size
for example if its a 16 bit signed integer, then -8 would be 1000000000001000
if its an 8 bit signed integer, it would be 10001000
the bit that tells you that the number is negative is always the left-most bit
ill get it working down in the commands
Sorry im not sure how to answer this, but i know there are people here who would like to help you with that!
that was not a question lol
message.member.voice is a VoiceState not a VoiceChannel
the value isn't nullable either
you want .voice.channel
member.voice isn't null or undefined nor can it be those values so it's always coerced to true
why am I getting 402 Payment Required with nginx when about 4000 Clients per second access the same page? I have checked everything, its 100% from nginx
wtf
are you using php?
nope, reverse proxying nodejs app
when accessing it directly with 5000 clients / sec it works fine
weird
the only thing i found about it was that it was being caused by a php logging extension
this is the config
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
include /etc/nginx/errors.conf;
server_name test.paperstudios.dev;
server_tokens off;
client_max_body_size 120m;
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://de-01.paperstudios.dev:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
ssl_certificate /srv/certificates/paperstudios.dev/fullchain.pem;
ssl_certificate_key /srv/certificates/paperstudios.dev/privkey.pem;
ssl_trusted_certificate /srv/certificates/paperstudios.dev/chain.pem;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
}```
do you use ngrok?
1 -> #topgg-api
2 -> Read the channel description there
ok thx
TypeError [CommandInteractionOptionType]: Option "user" is of type: 6; expected 3.
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("warn")
.setDescription("Warn a member for a reason")
.addStringOption(option =>
option
.setName("reason")
.setDescription("Reason to warn"))
.addUserOption(option =>
option
.setName("user")
.setDescription("to warn")),
async execute(interaction) {
const user = interaction.options.getString("user") ?? 'No User Provided';
const reason = interaction.options.getString("reason") ?? 'No Reason Provided';
const embed = new EmbedBuilder()
.setTitle(`${interaction.guild.name}, Staff Warning On ${user}`)
.setDescription(`The User ${user} has been warned for ${reason}`)
.setColor("Red")
await interaction.reply({ embeds: [embed] })
await console.log(clc.blueBright("[CMD Ran]"), clc.greenBright("-"), clc.yellowBright(`Warn Command Ran by ${interaction.user.username}, User Warned ${user}, Reason: ${reason} `))
}
}```
getUser or getMember
thanks
A quick 10 second search can save you time though
mentions don't work in embed titles
ah
Ye
doing js ${user.username} fixed it
warned for hi 😇
lol its a test
does anyone know if It's possible to get a Steam users ID from username through the API?
I found something from 7 years ago saying it's not possible may be outdated though.
Reading documentation helps
i have
No you clearly have not
i have
Took me 10 seconds
GET
http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/?key=XXXXXXXXXXXXXXXXXXXXXXX&vanityurl=userVanityUrlName
Arguments
key
Your Steam API Key
vanityurl
The user's vanity URL that you would like to retrieve a steam ID for, e.g. http://steamcommunity.com/id/gabelogannewell would use "gabelogannewell"
ty
Next time actually search
No, you can not get the Steam ID by the username, there's no available endpoint
The vanity URL basically is the profile name you can set as unique profile ID
yeah just to say, it has nothing to do with the username at all
You can use and resolve other IDs/types of URLs, too
Such as the Steam URL, Steam Vanity URL, Steam Invite URL, Steam ID 64, Steam ID 3 and Steam ID
Usernames are not even existent
?
There are steam IDs and steam account names
ist hier ein Deutscher und kennt sich mit ilove bot aus?
As well as nick names, some consider these as usernames though internally not, which can be changed anytime and are not unique
inb4 they didnt even set a vanity url and its their ID anyway
yup
well what I'm planning on doing is storing their display name and ID in the database and autocomplete them that way they won't have to type it every time
kinda like a search history
Question, what happens if they change their display name?
ik people who change the name all the time
weird people
it'll be updated when they search it
How
If you plan on refetching to see if its changed every time they use the cmd that will use a lot of api calls
So you do plan on fetching every time they do that
no
no i didn’t
when you search it’ll check if the data is the same, if not it’ll update it
You sure?
If you are fetching from the api just to verify every time they search that the name they gave is correct that sounds inefficient
No I can read
then where are you getting that I’m refetching the data everytime
by you saying that you will search and check if the data is the same. Kind of hard to do that without fetching up to date data and comparing it against what you have saved
when they search their profile I’ll check it against the cached data, if they’re different I’ll update it
yes why not
If so, what happens if they use a display name that now does not exist because its been changed
Do you fetch cached data first before checking steam api? Now if you do this, thats cool but the cached data is still out of date
well
Just use steam ids man
less headache
no point in saving data that constantly has the possibility of changing
Im recaching the data every 12 hours so if they’re updating it more often than that it seems like a them issue
you yourself just said you have to refetch every 12 hours just to update their data
I am storing their steam ID
no
Using cache when it's not needed is absolutely useless


it is necessary
And here you clearly just need to store the user ID with their relative discord ID and then do the requests
FakE I give up on these kinds of people
No need of any cache
don't even know what u're all arguing about
I don’t think you understand what I’m doing krypton

