#development
1 messages · Page 18 of 1
Yo for slash commands, if i have my commands registered for all servers (global) do they get registered automated for new server that add the bot or i need a script to reregister the commands each time a bot gets added into a guild?
tbh, I'm also quite busy lmao, but now you have a project to gather people for it
still rewriting my bot
Those are global which means they been pushed to guilds adding your bot automatically
It doesn't look like I can invite people to the crowdin project tho
the option to invite is grayed out
weird
Yes yes but i mean if they get added into new guilds while the bot is online sir
My answer literally answers that
[…] they been pushed to guilds adding your bot automatically
Ah cool cool, just wanna be 100% sure. Thanks sir
No matter your bot is online or not
🤝

// First of all, let's try fetching our member
let memberHackBanned = false, member = message.mentions.members.first()
|| message.guild.members.cache.get(args[0])
|| message.guild.members.cache.find(r => r.user.username.toLowerCase() === args.join(' ').toLocaleLowerCase())
|| message.guild.members.cache.find(r => r.displayName.toLowerCase() === args.join(' ').toLocaleLowerCase());
if (!member) {
await client.users.fetch(args[0]).then((fetchedMember) => {
member = fetchedMember; memberHackBanned = true;
}).catch((err) => {
memberHackBanned = false;
}); if (!member) return message.reply({
content: `I was unable to fetch the mentioned member.`
});
}; const hackBannedMemberTag = !memberHackBanned
? member?.user?.tag
: `${member.username}#${member.discriminator}`;
``` third variation (most likely a version that won't break)
I had to rewrite it like 3 times because something kept breaking
this should fetch properly
if the member is in the server, it will work with ID name and mention properly, will check for permissions etc.
if the member isn't, we just create a ban, and send confirmation with the fetched details
no need to check for the members permissions since they are not in this server
that code makes me angry and sad at the same time
why?

😭
the proper question would be "why not"

I fully tested it, no errors at all, now it only hack bans if the user isn't in the guild
it's perfect

I will also update the guild.ban.create function a little bit
to make it safer and avoid errors
const id = args[0];
const parsedArgs = args.join(' ').toLowerCase();
const condition = r => r.user.id === id || r.user.username.toLowerCase() === parsedArgs || r.displayName.toLowerCase() === parsedArgs;
const member = message.mentions.members.first() ?? message.guild.members.cache.find(condition) ?? (await client.users.fetch(id));
if (!member) {
return message.reply({ content: `I was unable to fetch the mentioned member.` });
}
const hackBannedMemberTag = (member.user ?? member).tag;
much better
how in the hell did you manage to get the user propety with users.fetch¿¿¿
did u test this code?
That is when you
ah wait
ye it's going to error

there
Can't always rely on the end user being correct
so if you can fix it, fix it yourself
still won't work
if u use fetch there isn't a tag property anywhere
How won't it work
Tf
you are 100% wrong
.tag is a prop all users have
so if you fetch a user
ofc it will have it
(member.user ?? member) will try to get .user, if it doesn't exists it will get member
u have to do member.username + # + member.discriminator
Wrong
bro
it exists in user
I'll prove u wrong
sure
(A ?? B) will grab A if it exists, or B otherwise
that's how null-coalescing operator works
also called elvis in other langs
...
no tag property
^
Reading
it's basically a getter
docs
are
important
with getters u can makeup any value you want transparently to the end user
also why stuff like private fields exist
how the fuck are u going to get the tag then
tag is a getter
Are you actually ignoring everything I said?
I'm just not understanding
Discord.js does it for you
wdym
on the raw data*
but it does exist as a property on the user object itself
Internally djs casts the raw data into a user object
and then they do stuff internally to make your life easier
such as forming the tag for you
by doing user.username#user.descriminator
as you can see here
if you actually read my fucking messages
bro ur not going to get the fucking d.js user property when doing client.users.fetch?????
it returns RAW data as you said
🤔

Wrong
Fetch returns an user buddy
it returns a Promise of the User
I get it if you really don't know
but you seem like you don't even bother checking docs
so it pisses me off when you try and say it doesn't
const member = client.users.fetch("714962308631101500"); member.user.tag;
where is the user proprty?
just cause you call it a member
doesn't mean it is
client.users.fetch
you are fetching a user
not a member
so therefor member.user isn't a thing
it would be member.tag
client.members.fetch isn't a thing in d.js
well obviously
Okay I refuse to help further if you ignore what I say
doing member.tag returns undefined also
const user = client.users.fetch("714962308631101500");
user.tag;
returns undefined
cause
tag
does
not
exist
Okay lets walk through this
I just evaled that
Client is your client class right
yes
Client#users returns a UserManager
fetch is a method of UserManager
and what does fetch return?
yes?
the user property, but it does not have a tag property in it
just come, I'd be better to explain it with actions rather than words
Have you tried logging what user is
So the result of you fetching is a raw user object?
yes
Then you are doing something majorly wrong
Cause it gives me the correct thing when I fetch
literally not
sureeeee
@ancient nova without code I can't help you further
I already have proven what you need to do works
So at this point you are just doing something else wrong
Why are you awaiting and then using .then
@lyric mountain join my server i will show you and then u tell that to Misty since she clearly does not underatand
Modifying variables inside promises is never a safe thing
without that also tag property won't exist
bro I'm doing NOTHING wrong
Got a stupid question, in args we can do
const name = args.join("underscore")
How can i do that for a slash command option? To hoin the string spaces with "underscore"
You are if you can't even get a proper user
I literally did the exact same thing of fetching a user and I can access all the fields a user has
Also
You can just set the result of fetching to the variable since you are awaiting it
why use .then
Anyone can help pls
Can slash command names even have special characters
Look, you're referring to the way I rewrote ur code right? The only scenario where tag wouldn't exist is if both member.user and member are null, thus making the coalescing return null
If member is an user, it'll return null and fallback to the second option
can you give an example
If member is indeed a member, I'll return an user and go with that
of what you want to happen
Well i want it to merge for example
User inputs cets on creck
i want a value of cets_on_creck
So .replaceAll?
alright, sure
Just wanna add an underscore between the spaces of that string
(member.user ?? member) works for both scenarios, same as if u did ```js
if (member.user) {
member.user.tag
} else {
member.tag
}
Yeah, so <input>.replaceAll(" ", "_") should work.
guess you're just unlucky
Return user.tag instead
You could be getting a partial user ig
You'll see it
It works for normal string correct?
If yeah thanks alot sir
works on any string
it doesn't exist tho
Partial doesn't contain username does it?
Idk anymore
please for our sanity use the ?? form
djs is fucking weird
Did u try?
Thanks🤝
yes
which version are u on?
I'm on 12.8
13.8****
v14
and don't say it is a difference in version
cause
it has been around nearly as long as djs has
then idk
Show the code u tried when getting tag
ok what
Whatever u tried that returned the error
I tried running the same thing again and it returned the tag
why does it now show in the user property tho
So basically
it is a getter
I don't think getters show up in the data
but it does existt
If they do you're doing something really wrong
or you just kept saying it doesn't work cause yyou didn't see it in the data
it's weird
but then if I save it later in a different variable it won't work
Changing variables from inside a promise is never a good option
Oh also, is ur eval command awaiting the supplied code?
no that's why I added an anon async func on top of what I wrote
That's the issue
how??
Async runs on its own time, you can't expect it to return before your outer scope finishes
ah I see the error I made in my code
If you need to extract a result, you need to await all the way to the top
it's cause I set the member property up and the updated it
that's why the tag property didn't exist
is there anything else hidden like that?
I see
async function nonAnonFunc() {
//code
await something
}
await nonAnonFunc() is going to wait tho
Yep, but is your eval command expecting an async function?
Then it doesn't know it has to await for a promise result
You can't really "resolve" a promise

Imagine it as throwing a ball to the sky
You don't know when it'll fall unless you wait for it
No matter what u do, the ball WILL fall, but the exact time is unknown
So like, if you try to kick that ball, you'll fail because the ball hasn't fallen and grabbed yet
Thus undefined
But if u wait the ball and grab it, now u can kick
I'm actually kinda weirded out by this rn, but then how did a .then break the entire thing and not give me the .tag property?
if I await it, and after it's done I do .then?
I don't know the exact reason, but weird things happen unless you have thread-safe variables (or atomics)
Js doesn't have them afaik
(nor threads)
So the safest is to just await the value and manipulate it afterwards
Like I did
okay thanks for the explanation then 0_0
Async goes a long way, and is reeeeally hard to debug if you don't know what ur getting into
I'll rewrite the ban command to tomorrow since it does work, just less efficiently ig
I thought I knew

Ironically, it's easier to handle async stuff in statically typed langs since they'll not allow u to compile
like what lanuage for example?
for some reason the first thing that popped up in my mind was lua

I can only speak for java
But pretty much any other static lang
Lua isn't static
never actually tried much async stuff when making mobile apps with java so I don't have much to say either
yeah
ExecutorService exec = // Initialize executor pool
int value = 0;
exec.submit(() -> {
value = 1; // Compilation error
}).get();
Logger.info(value);
U gotta do ```java
ExecutorService exec = // Initialize executor pool
var value = new AtomicInteger(0);
exec.submit(() -> {
value.set(1);
}).get();
Logger.info(value.get()); // Logs 1
I can kinda agree kotlin is more useful for mobile apps sometimes
I swear many issues would be prevented if people paid attention to java/C classes
sometimes
Even tho college uses rock age java
Kotlin, java, groovy, scala, etc all compile down to bytecode, so it doesn't matter much which u use for mobile
Unless you care about syntax
JVM is quite eclectic
depending on the use case writing with a different lang can be easier
I love groovy for that reason
did u guys know u can actually write a mobile app with lua
Makes writing card effects way easier
never used groovy for mobile apps so can't confirm
you can write mobile apps with js
oh that's quite cool
Groovy is a superset then
are they cross compatible
Java is valid groovy
java and groovy?
but groovy isn't valid java
But u get stuff like 5.times { println it }

Which will print from 0 to 4
0 to 4?
0 based index
Exclusive
probably
Yep
If it printed 5 it'd be 6 times
me when + 1
1++

wot
if you tell it to print 6 times

it will start at 0
and go up
and starting from 0 will always end up being a less number than what you start with
that's why I had to recalculate my pagination at least 6 times before it worked properly
If u want inclusive u can do (0..5).each { println it }
I kept adding and subtracting 1 in random places until it worked
this will print from 1 to 5?

0 to 5
1..5 then?
If u want to start at 1, yes
okay good
There're online groovy compilers, you could see how it feels
It's a non-typed java basically
me when print 5 = 6
it is the default iterator btw, if u don't declare one
Also u can override operators which is noice
I don't use java
I prefer C#
Matter of fact
Why don't I make my bot in C#
tf am I doing it in ts for
Does C# have a superset btw?
F?

At this point Microsoft owns the # suffix
pretty much
A self-encrypting one, yes
why did i think prefix and suffix where reversed so prefix was latter and suffix was first
Xharp
That's no fun
It would've been better if it had Se at the front
Objective C > C
Objectively speaking, that's true

I feel like you just wanted to say a pun
indeed
I mean, it is indeed bigger
Ur mom

Btw, another "only in groovy" moment:
use (TimeCategory) {
println 3.hours.from.now
}
So it prints 3 hours from now?
any rsx enjoyers
ayo? using rust?
I'm amazed yet scared.
What shocks me the most are these two lines
As for the inline HTML, I have mixed feelings about it in general personally.
why am I here. Just to suffer.
Have you tried deleting your account?
Nope
The closest thing is F#, but that’s more of a sister functional language version of C#
yo setStatus doesn't seem to work for me
general question to y'all:
what do you prefer: accuracy or speed?
that was essentially a question I had thought for myself when making image generation associated with a Webserver and had to decide between caching or only fetching the data and if it's the same, resend the cached image
accuracy as in what?
accuracy is probably the wrong word, but lets say the following:
I'm generating images that contains data that updates often (such as a spotify player with the time per-se). Would you prefer the accuracy of the timer or would you cache the image it sends if nothing much has changed
So timer as in how far it is into a song?
essentially yes
i'd honestly go for accuracy
If so Id value accuracy
And what about if your spotify playing service starts to get more used by people? When's the break-off point where you'd prefer speed? Since generating these images will always take a lil more resources and will start to become slow in loading
I'd say value having the timer in real time
At a certain point don't even bother with the image
If it comes to be too resource intensive that is
You could also compress the images ig
It'd make em smaller and faster to serve
that is true
What
Ask your question instead of saying you need help. Those who can help will answer if they can

You can have a look at how it's done through the HTML parser of the Chromium project's Blink rendering engine
HTML tokenizer:
|_ header: https://chromium.googlesource.com/chromium/blink/+/refs/heads/main/Source/core/html/parser/HTMLTokenizer.h
|_ C++ source: https://chromium.googlesource.com/chromium/blink/+/refs/heads/main/Source/core/html/parser/HTMLTokenizer.cpp
HTML tree builder:
|_ header: https://chromium.googlesource.com/chromium/blink/+/refs/heads/main/Source/core/html/parser/HTMLTreeBuilder.h
|_ C++ source: https://chromium.googlesource.com/chromium/blink/+/refs/heads/main/Source/core/html/parser/HTMLTreeBuilder.cpp
Hmm, which programming language do you understand the most then?
i don't think looking at google's C++ code will help - considering the amount of macros it has
and how vast and advanced their C++ codebase are
It would absolutely help if they understand C++, but unfortunately they don't seem to
no, it still doesn't help if you understand C++ either
like i bet you don't understand what that C++ code does
It's not too complicated to understand the code, and you can already see where everything is located just by going back and worth
Here we go again with arguments like this, featuring null; episode 500
Voltrex pretending he's smart; episode 500
thanks, i will need this to parse arknights rich strings
Yeah go on, I'm not even gonna argue with you
then tell me what the macros HTML_BEGIN_STATE, END_STATE, HTML_ADVANCE_TO and HTML_RECONSUME_IN do
@carmine topaz try to make an XML parser first before going for HTML
so you get the idea
of it
assume var input: string
var currentTags: string.None
var currentTree: string[]
match tokens...
for token of tokens {...}
so example i would parse it into something like```
{
"tag.child": "all content before the another child"
"tag.child.anotherchild": "content"
}
I don't think you understand how parsing anything really works, there are almost states like this in every advanced parser where they call between each other back and forth to not only check the characters they need to consume, omit, or advance to; and this is exactly what's happening here, if you look around the code just a little bit, and the source of the functions and macros that are being used, you'll understand it, in this case it checks for the current character (cc) and depending on what it equals to, in most of the statements it converts the current character to a buffer character which then tells the parser to either advance to another state or the same state, or reconsume a state to check the aforementioned state again
alright then - though this approach results in lots of spaghetti code
since we're utilizing lots of goto calls
back and forth
<desc>
For <number>2</number> seconds, increase the <stat>ATK</stat> by <percentage>180%</percentage> while also cause <fx><i>Stun</i></fx> to <number>3</number> enemies
</desc>
parsing XML is easy through recursion
Nope, infact it's one of the best ways to approach this, calling functions back and forth does not necessarily result in "spaghetti" code, there are so many places in almost every huge codebase where the same type of thing occurs
Even the Linux kernel recommends doing this
they are both the same - considering they are both markup languages
it's basically the same
You can just have a look at https://github.com/AngleSharp/AngleSharp/tree/devel/src/AngleSharp/Html/Parser to get a simple idea of how it works, so you can advance through to make your own
You don't need to look at the whole thing just to get an idea of how to implement whatever you're looking for, just some simple aspects of it
this will result in follow order
[
{"desc": "For "},
{"desc.second": "2"},
{"desc": " seconds, increase the "},
{"desc.stat": "ATK"},
{"desc": " by "},
{"desc.percentage": "180%"},
{"desc": " while also "},
{"desc.highlight": "cause "},
{"desc.highlight.fx.i": "Stun"},
{"desc.highlight": " to "},
{"desc.highlight.number": "3"},
{"desc.highlight": " enemies"},
{"desc": "."}
]
then uh i will parse it in the tree by tracking those orders
looking at the code, it's actually not a function or a goto label, but a huge switch statement
It doesn't matter, not only are most of it optimized at the end but most parsers utilize huge switch statements all over, literally
then i loop again which result in ```js
{
desc: {
[
"For",
{ seconds: ["2"] },
" seconds, increase the ",
{ stat: ["ATK"] },
"by",
{ percentage: "180%" },
" while also ",
{
highlight: [
"cause ",
{ fx: [{ i: ["Stun"] }] },
" to ",
{ number: ["3"] },
" enemies"
]
}
]
}
}
so i just check the type
if it's a string, it's text
if it's an object, the key shall be the key
and the array shall be its children
no
this model contains tags and what contains in it
so like ```js
{
tag: [content_in_between_said_tag]
}
it's very inefficient
but atm it's what i could think of
you can store object wise to target something to
we use array to track deepness
so when we encounter a closing tag, we pop the tag of the array
that's why you see the following output in my code
think of it like this
whenever you find a new element, call the current function again to handle that element - it's easier when you utilize recursion
the main concern is the data structure of this
but i think it looks similar to domtree
just dumber
you can store it through an array of token objects, which acts as a token tree
someone help?
pretty much
how can i do an animation counter with VueJS 3?
I tried using gsap but it gives error
then check for tag names that does that, like meta
alright
so
assume we have this
<parent>a <child>b</child></parent>
parse
<parent>a <child>b</child></parent>
^
currentTag: ["parent"]
currentChild: "a", "text"
...
<parent>a <child>b</child></parent>
^
currentTag: ["parent", "child"]
currentChild: "b", "text"
...
<parent>a <child>b</child></parent>
^
currentTag: ["parent"]
currentChild: ""
basically treat every element as the same, an element can have a child and a parent
we can pop the tag out when the closing tag matches the last element of currentTag array
which results in this array
from said array i can construct this tree
for a list of tags
you can use RegExp
i would embrace it
my xml parser uses regexp
you should never use regexp whenever you're tokenizing

i don't have alot of tags
so it's totally safe
imagine this scenario: <troll inner="<trolled>yes</trolled>"></troll>
a regex can't tell a string from an element
yeah i know
but
the thing is
input is controlled
for that case it's totally safe
that's fair
HTML tokens jumpscare
mmmm
mmmmmm
that's good, just needs parsing on the element attributes
you tryna import a nodejs module
in a web page
💀
where's your build tool
parcel, vite, webpack, snowpack, any?
oh
just check if an element contains a key="value"
then how do i use this without using vite, webpack or any?
import from static url
@versed shoal
https://greensock.com/docs/v3/Installation
check this
then you insert script tags
after that GSAP is a global object
remove the import in the this
thanks
what exactly do vite, webpack etc. do?
what can not i do without these?
@civic scroll
they are programs that "build" the website files for you
it transpliles and includes all the node dependencies for you in a single js file
for example they take all the things you import and pack them in a single light weight js file
you were faster this time, but well see next time :^)
its more for productivity than optomization
it does a lot of stuff that you would need to do manually
see, the thing is
the code you use in frameworks are server-side code
so when you specify relational paths in the browser it turns to client-side
unless you include those files in the assets directory, those files won't be available
so what those packers do is that they analyse your code, determines what it uses, then combine them all and minifies them in a single js file
so your web app would behave on the browser like the way it would on a nodejs environment
plus the thing is it only includes parts of the code that you actually use
for node_modules, you include everything
so packers essentially reduces the size of required files for you
makes the web page loads faster
it also does things like cache control, for example when you update a js file, it appends a hash to the file name in all your html files to make sure the browsers fetch the updated file and dont use the old one
oh cool, thanks for the answers
and has a billion plugins and extensions, for example to transpile typescript into browser js, minify css, etc...
Error: Expected token to be set for this request, but none was present```dafuck?
await rest.put(
Routes.applicationGuildCommands(n.clientid, n.guildid),
{ body: commands },
);```it's coming from here
You might wanna use djs inbuilt functions to deal with the registration
In your case <client>.application.commands.create(<commands array>);
In your case you might forgot to construct the REST class passing your bot token to it
is it possible to do something when a person has voted for a server? (discord.py)
like is there a way to track server votes?
You have to use the #topgg-api
a folder is present in my directory and i mentioned right path but bot unable to get it!
guildCommands.find((cmd) => cmd.name === loadedCommand.name || loadedCommand.localeName.includes(cmd.name));
While editing my command initialization code I'm now going to support name localizations, too
As we were talking about yesterday and you asked, how would you even check for a localized name, I responded with code snippet above
Actually that's redundant...
You will always retrieve the registered command name by the API
The command name is not the localized executed one but the registered one
The command interaction you're recieving in your event also includes the name_localized property, which indicates a localized command name have been executed
https://discord.com/developers/docs/interactions/application-commands#localization
https://discord.com/developers/docs/interactions/application-commands#retrieving-localized-commands
... so finding the command name for the localized name, as mentioned above, actually doesn't seem to be required atl all
The command interaction you're recieving in your event
of course same goes for fetching the (guild) commands
Github stopped updating the codes I was editing, does anyone know how to fix this?
like, the page is giving an error and doesn't update when I start
happened after i switched to private repository
and I went back to the public and it continues like this
What's the error?
https://discord.com/developers/docs/interactions/application-commands#application-command-object
So... default_member_permissions accepts a serialized permission bitflag
That means it's not possible to specify if a member has a permission A or B?
How am I supposed to know then which permissions include each other?
Let's say I wanna define if the member either has Administrator, ManageGuild or ManageChannels permissions...
Would I just need to create a bitfield for default_member_permissions representing the ManageChannels permission value?
what
like, if u have the bitflags u can just extract which ones are true or false if u know their indexes
Also you don't need administrator
Just 1 << 4 | 1 << 5 will do
Discord already accounts for administrator
Did you just test that out yourself already?
The client expects the member to have both permissions
Not just one
Or the command wont be shown
The question is not what I can do with the bitflags... the question is what the Discord client does with 'em
Once the default_member_permissions field is defined, the Discord client will only show up the slash commands if the member has this permission(s)
yes?
what the heck you don't understand?

it doesn't seem to be possible to specify multiple permissions where the guild member only requires at least one of it
am I that confusing? 
Yes
Ok explain that:
no :)
console.log(command.defaultMemberPermissions, command.defaultMemberPermissions?.toArray());
TypeError: command.defaultMemberPermissions?.toArray is not a function
How tf is that possible
I mean how can the optional chaining FAIL?
command.defaultMemberPermissions logs a djs permissionbitfield
because in the end it's undefined if doesn't exist?
so you're calling undefined
wait... it comes undefined not null?
I still see no viable reason to localize command names. It seems like a step that isn't worth taking. While the names don't really mean much as the description itself if written correctly can do a better job of saying what the command does. I feel keeping it in English is the better choice as it is a commonly used language now a days and it is less of a headache to do.
it's the same case if it's null
why tf is it calling toArray then?
defaultMemberPermissions: command.defaultMemberPermissions?.toArray() ?? null
if mean it's called optional chaining
so if the defaultMemberPermissions property is null or undefined the last property or method in this case shouldn't be called at all
how can i ignore the "e"? i am using input number
where is that?
onst { COLORS, PREFIX, ROLES } = require('../../settings/config');
module.exports = {
name: "i",
cooldown: 2,
run: async (client, message, args) => {
const roles = message.guild.members.cache.get(message.author.id)._roles;
if(roles.some((role) => ROLES.includes(role))) {
message.channel.send(`Hello`)
} else {
message.channel.send("Premium")
}
}
}
how can I make the premium role take over from the support server and give the premium permission to other servers as well
and give the premium permission to other servers as well
Well you would be required to create your "premium role" in every other server, then check if the member is part of that group
which is an horrible idea tbh
Or you gonna save the user ID in your database along with the premium status and check once a "premium command" is being executed if the user has the premium status by querying your database
this one
ok
hey guys, how do i actually return in a for loop?
for(const key in shopdata){
if(key === 'test'){
return
}
// this return should completely stop the for loop instead of exiting the first key
}```
like that?
It doesn't work. It keeps on logging the rest as well
I agree but still implemented support for it in the new command init function
gonna share that later
are you sure he enter the if statement?
yup
Weird... use the break keyword then
idk but you can always create an aux variable and then set the value you want and use break
that works lol
Strange asf
const winnerembed = new MessageEmbed()
.setColor("RANDOM")
.setFooter({text: `Treasure Cove | Admin Configuration`})
.setTitle(`⚠️ | Shop System changes detected`)
.addFields(
{ name: 'Type:', value: 'Added an item' },
{ name: 'item:', value: interaction.options.getString('item')},
{ name: 'Price:', value: interaction.options.getNumber('price') },
{ name: 'Admin:', value: interaction.member },
{ name: 'Used in:', value: interaction.channel },
)```Uncaught DiscordjsError RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.
wha
interaction.options.getNumber('price')
is not a string
the value must have the type STRING
Owh shit how would i fix that
Either use template strings or toString()
well take a look at your last two fields
interaction.member and .channel will both return an object
Won't it just ping the member and channel?
wut
like @eternal osprey
no
huh i always did that
It's just a field value
If so you need to turn the member object into a mention
You can use the util (now importable from the global scope) userMention(<user ID>)
const { userMention } = require("discord.js");
or simply write the field value yourself
Like so:
value: `<@${interaction.member.id}>`
Or just call the .toString() method on the guild member, which returns the mention
oh does it?
Yeah
Ahh... same applies for the channel, I see
For roles as well
Another question, js for(const key in shopdata){ row.addComponents( new MessageButton() .setCustomId(key) .setLabel(`${key}`) .setStyle('PRIMARY'), ); }Would there be any way to actually add multiple buttons using a for loop
rn it tells me that it exceeds the maximum width
I thought you already knew
yee 5 is the maximum per row
Just create a new row every time the maximum amount of buttons is reached, AKA 5
owh that's fucked. How would i code in that if one row is full, it should write it into the next row called wo1.
Return just stops the current iteration no? It still keeps the loop going so I won't just stop or is that not right?
That;s what i was trying to do, but not sure how
Yeah you are right, i just verified it myself.
Break stops the whole loop while return only returns the current cycle.
Yeah i do
Do you know PHP supports scopes for continue and break? like continue 2, continues the outher loop
should be a thing in JS
Okay php man
How would i implement this?
Also isn't using a loop here not a good idea?
Can't you just map it into an action row
Or wait no
Nvm
Ignore me
I need to create buttons based on the amount of items in a certain array
I was thinking you could just map it and make an array of buttons
But
That won't work unless you were not using a builder
you literally use a simple loop and an index value, ones 5 buttons are created, you increase the index value by 1
which is the array index of your next row
Right now it does work, but after it hits the max it ofc errors. So i need to know a way on how to write the next keys into a new row if it's full
How many hours a week do you work btw?
Unrelated but interested
You have a job no?
lmao
You always talk about it
I see, thank you fake. I will try to implement it
I'm talking about your actual job
that depends very much how much I need to do, how many times I assist others since people/employees are currently missing anywhere, and how much money I wanna earn that month
Ah I see
mo, thu, wed are each 13h this week
What's min wage where you live?
I'm running my own business so... I'm the one making the price
I never complained about money tbh, but I'm far away from being considered as rich and I also have very bad times and of course good times as well
but I can actually live a nice live, at least that's what I consider to be nice of course
opinions are very differently about that
That's good
Well my main branch is logistics and transportation as well as doing accounting for others and me
has a wide range from planning, organizing, booking, executing and driving myself if nobody else is available
You can do something similar to that in Java with labeled breaks 😉
shhh move on with your Java stuff
Question, overall difference between MongoDB and MySQL?
I mean, I know for a fact that Mongo is all based on JSON objects and how you're only storing information to access later, however, what makes MySQL special (other than it being mostly used in websites, and etc.).
Biggest difference is that mongo is a nosql db and MySQL has SQL in the name
Other than that.. I mean, that's well known difference. 😂
but I'm sometimes also assist others as a craftsman, since I'm quite talented with my hands
it depends as I said
Well, most SQL databases are table-based (I don’t know how to describe it) compared to mongo which is document based
Other than that, is it that SQL databases are based on tables and such?
the more you know and can the better your chances are to have a well payed job
I mean, each is better depending on scenario, correct?
It’s more based on what you’re comfortable with. I believe that mongo is quite a bit slower than most SQL databases
Most sql databases are faster than nosql tho
MySQL is still a shit sql db tho
is there an SQL database that's not table-based?
I mean, it's Structured Query Language after all
but its a language, it can be adapted/transpiled to work on anything
pretty sure there are a few multilanguage dbs that work with sql
without necessarily storing data in tables
would a command to show information about a certain token be against ToS?
any, user, bot
I would refrain from doing so
and by info I mean like the date it was created, who it belongs to
I see
Yes but to get that information you'd have to use their token to do so
and that is a no no
If you wanna display information on something just do it the normal way
Only limitation would be whether the bot shares a guild with that user/bot
misty I actually took ur advice and gave my bot a specific purpose
What purpose is that?
mod / automod or anti raid bot
Then do things focused around that
One thing you can do is look at your current commands and think of how you can make it better
They were talking about users giving tokens and the bot using them to get information on them
giving... what tokens?
user and bot tokens dingus
that is the worst idea I have ever heard
I think I added everything i could
I got
no more ideas
It doesn't matter what you added
it matters how you can improve on what you added
You can always improve on it
Why would people even give it their token
That's just dumb
That is the point I already made waffle
You know damn well he gonna be storing them in plaintext too, there's no reason to ever give your token away to anyone else
you are late to the conversation
I know I'm just baffled
On another note
ima make a bot in C# cause I am bored and now have little time to do anything else

It indeed is
I was going to make Gwent
but I don't know any graphic libraries
so
no idea how to make the cards
and all the ones I found were from ages ago and have poor documentation
idk what to add
Okay here's an idea that might be viable or not as I have never tried it
You can make a ban command that can list a paginated select menu of all the people in the current guild and when you select a user(s) a modal will pop up asking for a reason and bam it bans those members
Again probably not viable
but
It is a spitballed idea
ImageSharp?
That's the most popular one for that use case
Might work
my bot is in a server with 25k people in it
inb4 "how to make paginator"
that definitely won't work
IT could
You can easily do 25k

Cake has an emoji listing command and it still works with like 10 thousand pages
If you don't wanna do it

It is a good idea though
That could easily work
You can have a embed showing the users, and a select menu allowing you to select the users on the page
basically use some emoji listing site's API to fetch emojis by name like that command above, BUT you can select a specific emoji and the bot will automatically add it
how does that sound 0_0
actually nvm I got no way of embedding the images
Sounds usless for a mod bot
since u can't do more than 1 image
Untrue
Just have pages of them..?
^
it's still multipurpuse, just focuses more on moderation now
It's a good idea
1 emoji per page tho? 
want my spotify
No

using var image = Image.Load("original.jpg");
image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2));
image.Save("result.jpg");
@wheat mesa wtf is this syntax
using var image = Image.Load("original.jpg");
why is using here
It automatically calls .Dispose() when you're finished using it
Ah
It's syntactic sugar so you don't cause memory leaks
Makes sense then
I also gotta not embed my token in the file directly if I am making this bot open source

I just have not gotten to the point of grabbing from json files in C# yet
Or just use env like a normal person
json is INCREDIBLY easy to use in C#
It's practically built for it
Yes but how 😢
class ModelClass
{
[JsonProperty("key_name")]
public string Value { get; set; }
[JsonProperty("another_key")]
public int AnotherValue { get; set; }
}
var myModelClassInstance = Json.Deserialize<ModelClass>(jsonDataHere);
easy as that
I see
The stuff online was telling me all sorts of things
Okay dumb question, but I forgot how to inherit a class that takes in something
using DSharpPlus;
namespace Gwent.Structures;
public class GwentClient : BaseDiscordClient()
{
public GwentClient(DiscordConfiguration config) : base(config) {}
}
iirc was this not how you do it?
I think that's how you do it
Why are you using some obscure C# lib
Use D#+, Remora, or D.NET
Oh

Okay
I am wanting to attaching a config option to the client
so I don't have to get deserailizing my config if I need it
Then again I just won't bother tbh
So if I go the env route I can't use a env file right?
Cause it wouldn't load the token variable in time or at all
What?
Using an env file the variable I specify in there isn't being loaded in time or at all
so my project can't usei t
Now supports anything the API also supports...
The structure (djs like)
{
name: "name",
nameLocalizations:
{
"fr": "fr-nameLocalization"
}
description: "description",
descriptionLocalizations:
{
"fr": "fr-descriptionLocalization"
},
options:
[
...
],
defaultMemberPermissions: ["Administrator"],
dmPermission: false,
guilds: ["264445053596991498"],
disabled: true,
async execute(...)
{
...
}
}
disabled: true removes global/guild commands
deleting the entire command module would only remove the global command, as due rate limits you can't fetch all commands of any guild to check if the local one still exists or not
no matter the depth of the options or choices it will be flattened and gets formatted
The push_guild parameters of initCommands() is available to call the function inside your GUILD_CREATE event to push possible guild commands to the guild without fetching/reloading the global commands (again)
I wanna say that's actually a pretty nice command handler
I have a pretty bad issue in my database that i can't find out how to fix-
whitelisted = fields.ManyToManyField("Bot.UserModel", on_delete=fields.SET_NULL, null=True, related_name="whitelisted")
vanity_whitelisted = fields.ManyToManyField("Bot.UserModel", on_delete=fields.SET_NULL, null=True, related_name="vanity_whitelisted")
The issue is coming from those 2 lines that are associated in the UserModel
class UserModel(DiscordDBModel):
"""Base User model, meant to be reference by extensions"""
def discord_get(self, bot: discord.Bot) -> discord.User:
"""Returns the associated ID for the given user."""
return bot.get_user(self.id)
They are inside the same file, the issue is that using ManyToManyField i will have to reference inside the UserModel where to put the user IDs and that's what i don't know how to do, i looked up for some examples but i can't find a good logic for it.
This is the traceback that i get from the code when i try to init my database - https://hastebin.com/yerafaciri.rust
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
||i don't even wanna read that whole thing||
fields.ManyToManyField("Bot.UserModel", on_delete=fields.SET_NULL, null=True, related_name="whitelisted")
is this the unholy child between sql and nosql?
I don't even know what exactly I'm looking at
IF I understood right, you DEFINITELY doesn't want to have a M <-> M field, make instead a middleman table
but other than that, I can't see what exactly ur trying to achieve





