#development
1 messages ยท Page 2047 of 1
DSharp
Serenity ๐
You don't need to be advanced to read docs
Isn't that a rust lib?
That's the point
writing discord bots in statically typed languages rubs me the wrong way
Fair
discord is very dynamic
it would only make sense for the language to also be dynamic
I was trying to write a bot in java but the idea behind it is a bit annoying
My head hurts trying to understand the stuff I need to use

good luck trying
there is no lib for java
You are wrong
you're gonna have to use raw api
very very wrong
wdym
uncooked api
๐
didn't know about it
This is what happens when people who don't know shit try and talk on a topic they know nothing about
you're lucky I wasn't a noob
So, half of DBL? Got it
If you don't know shit don't talk about it
relax I just didn't know it existed
use express
how long was it out for
JDA has been around for a LONG while lol
well it must've been smaller and I didn't notice it before
hell
hardcore discord.js and c++ developers trying to comprehend someone having a different opinion than you: ๐ค๐ฅต๐ฅถ๐ญ๐ค๐ค๐ค๐คฌ๐คฌ๐คฌ๐คฌ๐คฌ๐คฌ
ยฏ_(ใ)_/ยฏ
I think they were even out when user accounts were being used as bots
Don't forget us Python devs
No it was fairly popular
seems how it was the only discord lib in java at the time
not popular enough it seems
-_-
๐คทโโ๏ธ
It's okay we make a point not to forget you guys
who else would we make fun of
:)
I'm supposed to be filtering URLs in Python but I'm too lazy to write a proper regex or check for them
something like this?
blacklist.includes(word => {
if (message.content.toLowerCase().includes(word)) message.delete() && message.author.send("Keep the use of Profanity out of our server!")
})``` like this?
lmfaoooo
NO
jesus christ
im new ok
Read more on how to use array.includes
I mean still not half as bad as what you write
if (blacklist.includes(word)) { true } else {false }
I just want to export it from blacklist.js
I actually write decent code thank you very much
๐
Could be simplified into return blacklist.includes(word)
just because I use regex doesn't mean I'm bad
amm, stupid question: can I somehow make my bot to create and assign role to himself when he join some server?
-_-
so it takes the words from blacklist.json and deleted them with blacklist.js
Two contradicting statements in the span of few seconds
IT WAS AN EXAMPLE
ima just start spoonfeeding code explaining it is harder
return !!blacklist.includes(word) 
An example that could use improvement
if I wrote what misty here has written the dude would prolly be confused
he just said that he is new
If it gets the Manage Roles permission through OAuth2 URL the user uses to invite the bot, sure
listen to the event of users joining servers, then assign a role
Aurel what are you doing here
no shit sherlock

u supposed to lurk
Trying to literally avoid the pain from recoding this shitty verification thing I did in python

Because I didnt plan ahead
never let the bad guys know ur here how else will you catch em

You really think I am the only one lurking

First issue is u used python
kthxbai
No
just use what I've done it's the easiest to understand
if you want u can use what @sharp geyser wrote but it's more "advanced"
I feel that
Ima be real I have no idea what I wrote even works
Now I'm literally writing some sort of "Program Process Plan"
So I dont fuck up shit again
Seems like it does tho
it does, true false is just gonna be inverted
But I don't really know if there is a reason to do it this way
(blacklist.includes(word)) { true } else {false }
if (message.content.toLowerCase().includes(word)) message.delete() && message.author.send("Keep the use of Profanity out of our server!")
})``` like this?
ยฏ_(ใ)_/ยฏ
why
Learn basic js plez
I am shocked you didn't see an error trying that, unless you ignored it to ask here
I did the second one
you don't even know how if statements work
Ignores the "learn basic js" message utterly
๐ฟ
and just so you know the message author send code wont execute
Good luck getting hit in the face with the same broom more than once at this rate @earnest phoenix
thanks
can I spoonfeed?
I'm really not surprised
go for it
You'll just make them believe they can depend on you to fix their shit constantly
If that's what you want, I'm not stopping you
If you spoonfeed em they won't learn to try and solve it themselves
I mean
Not like they are trying right now...
Let them suffer consequences of their own actions
Ah but the key is we are actually giving them advice
whether they listen or not is on them
i'd say its fine to spoonfeed if you explain the code
Which they can't understand
^
trying to make them solve and make something they dont understand is hopeless
It isn't they can't understand they don't try to
I have issues trusting Bae to write a clearly explained code snippet that can be understood by a beginner
lmao
shhh just let me try
Sure thing. I'll be watching as well

const blacklist = require('pathToBlacklistFIle')
if(!blacklist.includes(word)) return false
return true
Ez
Misty I'm gonna murder you
lmao
What this does is use what you were already doing, but checks if it doesn't include the word, if it doesn't it returns false else returns true
They don't need returns here
Do it I wanna feel something for once
You're just gonna confuse them even more
THEN WHY THE FUCK WERE YOU GUYS TELLING THEM TO
// cache the json
const blacklist = require("./blacklist.json");
// compare "word" string to the blacklist json
if (blacklist.includes(word)) {
// delete the message. make sure "message" is defined
await message.delete();
//notify the author
return message.author.send("Keep the use of Profanity out of our server!");
} else {
return;
}
so only thing I need to do is add
if (foundInText) {
message.delete();
it's hard writing code without vsc
No idea who you're talking about here lmao I didn't give any advice apart from judging
Well true
if(!require('pathToBlacklistFIle').includes(word)) return require('pathToBlacklistFIle').includes(word)
return require('pathToBlacklistFIle').includes(word)
I know that ty for judging
I was reading baes message
Oh
lmfao
๐ญ
Why the fuck
go back to writing your black magic java code haku

wouldnt it better to loop through the blacklist array and check in message content if it contains that word. like with what u doing rn it will only work if only a word is sent. what if the word is in a sentence
btw haku
i think y'all started coding yesterday
and how does the exports work?
I tried making a cmd handler with reflections and failed miserably
u can convert to string and use .Contains to check for a specific line
module.exports?
read up on module
.contains is a thing in js?
it does what it says
yeah
no includes needed
idk too first time hearing fr
my internet is so fucked it looks to me like chat is dead and im just talking to myself then a burst of 20 messages pop up
contains supposed to compare string
lol
grey moment
== ?
okay I was wrong contains doesn't exist in js weirdly enough
lmao
Difference between includes() and contains()
The includes and contains both methods search for a substring within a string or find elements within an array. The includes() is a method present in JavaScript, whereas contains() is not present in JavaScript. It is used in other languages such as Java.
How does anyone still assume you to be a credible source for information, I wonder
sorry for asking but how do I read that up
it's like indexOf, I think I got mixed up with c
"stringthis".Cotnains("this") // true
but I could've sworn I ued it before
i see
Probably in Java
maybe
they need to add a .has() method for 50% more confusion
๐
google "javascript module documentation"
Haku explain reflection to me I don't understand how you did your blackmagic cmd handler
var string = "foo";
var substring = "oo";
console.log(string.indexOf(substring) !== -1); // true
ok so, usually you have everything accessed during compile time right? with reflection it's the opposite
you don't know what something is during compile-time, only during runtime
Ye
Sad you are using var

reflection is awesome when you understand how it works
var is still useful
What is it used for?
even though it's buggy the bugs can be helpful
hmm is it possible to disable "more like this" using css?
Only when you know what you're doing
for example, getting class methods (not calling, getting them)
I understand the basic concept of how reflection works
But I have no idea how to practice using it
or locating classes by @Annotation
Oh true
you could also invoke them when you need to tho right?
I know this is a change of topic but do you guys like onions?
in my command handler I just annotate command classes with @Command, the runtime finds them automatically
select through class or id and set the display to none
ye
Unrelated to dev channel
go away
:C
reflection is meta-programming basically
no >:c
Can you tell what id or class does it have? Im phone so i cant inspect
you use the context itself instead of the content
How does one write a basic URL filter?
const tf = require("@tensorflow/tfjs");
const profanityModel = tf.sequential();
profanityModel.add(tf.layers.dense({
inputShape: [200],
activation: 'relu',
units: 320
}));
profanityModel.add(tf.layers.dense({
inputShape: [320],
activation: 'sigmoid',
units: 60
}));
profanityModel.add(tf.layers.dense({
inputShape: [60],
activation: "softmax",
units: 2
}));
profanityModel.compile({{ optimizer: tf.train.adam(0.01), loss: 'meanSquaredError' });
const trainingData = tf.tensor2d([ ... ]);
model.fit(trainingData[0], trainingData[1], {
epoch: 5000,
shuffle: true
});
Preferably without using regex
I can't believe you said that
talk to bae he knows all about that
don't lookup the whole url regex
same i am on phone too but i wouldn't prefer doing that tho its against the rules ig
use a lib for sanity
he uses it in 90% of his code
for a good reason ๐
where are rules for this
there is no good reason to use regex for nearly everything that can be done simpler
My main issue is that I'm trying to detect a URL in a message that could contain anything. I'm not sure if running a regex for each message is a good idea...
idk i saw somewhere but forgot where
This feature is bad idea tbh
1 line of regex code >>>>>> 50 lines of normal code
It only show big bots there
#([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\xE000-\xF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?#iS
1 line of regex code is worse than 100 lines of normal code
ah yes, regex
'use machine learning
... is that the full URL regex?
imagine knowing how to write a regex
isn't using regex a performance hitter

you're exaggarating
Always
the only thing more cursed than url regex is email regex
discord mobile uses regex for code highlight
performance go brrr
You clearly don't know how regex operates behind the scenes
Why do you think discord is shit
lmao
well...
And it shows
he has a point
Literally uses 200mb idle
๐ญ
I was joking
I guess it just wasn't funny then
Why do you think so many people go out to find lightweight modded clients for discord
Anyhoo, back to my question
oh regex is easy, but it automatically encrypts itself so only who wrote it can understand
discord claims to be for gaming but uses up a fuck ton of ram
to be fair somehow I made my game use a GB idle
never cared to learn it fr just copy through net
you used regex everywhere?
You reckon a "http" in msg.text.lower() will be a good enough check to actually get to the regex? ๐
regex is damn useful, I recommend learning
nah surprisingly not
^
useful when used correctly
ye
regex be like ยฃ%Qยฃ%&ยฃ(Q%&Qยฃ%$/426'246';2'462867236ยฃ%&ยฃ(%ยฃ(%
i dont use it very much tho if i need for something i just find it on the net
Hello, World
comparing strings is also easy with it
I never bothered to learn regex I hardly find the need to use it
helped me solve many issues
well yes.. it's a good way to use regex
my new command handler uses it for parsing command syntax
bros gonna achieve at most 10fps with that
in some cases
it works better than discord slashes, except for the UI part
it also allows a command to have many forms
๐
I tried reading ur code but I am too small brain in the java language rn to even attempt to understand it
not the master branch, the rewrite branch
I'm rewriting my entire codebase
try reading a compiled version of java
smali
it's cleaner
My head will explode
imagine java
I swear
it is surprisingly intelligible
more than the actual language
once you learn it, that is
it looks like machine code to a person who doesn't know smali
@sharp geyser
module.exports = async (prefix, client, message) => {
const blacklist = require("./blacklist.json");
let foundInText = false;
for (let i in words) {
if (message.content.toLowerCase().includes(blacklist[i])) foundInText = true
}
if (foundInText) {
message.reply("Please don't use that word here")
await message.delete()
}
}
does this look better :/
better, but why do you insist on making it less performant
i mean the resemblance with labels is there
^
compiled java is surprisingly more readable than asm
I think it is
Is blacklist an array?
If so just use blacklist.includes
well that's obvious
optimization suggestion! break the loop after you find the word
what do u mean
const blacklist = require() this part, is blacklist actually an array
If it is an array then you have no need to loop
where do I put this then
๐
yes
getting there slowly but surely
module.exports = async (prefix, client, message) => {
const blacklist = require("./blacklist.json");
let foundInText = false;
for (let i in words) {
if (blacklist.includes(word)) {
await message.delete();
}
if (foundInText) {
message.reply("Please don't use that word here")
await message.delete()
}
}
}
like this?
no need to loop
oh
no need for the global bool either
just the if statement is needed
blacklist.includes returns a bool already for u
If it does include it you delete and send your message, if not do nothing
we wont talk about that require inside the function
^
I want it to delete and send message
one step at a time speedy
Then do so in your if statement
bad idea
it can easily be used to ratelimit ur bot
so instead of this:
add some kinda timeout
module.exports = async (prefix, client, message) => {
const blacklist = require("./blacklist.json");
let foundInText = false;
for (let i in words) {
if (blacklist.includes(word)) {
await message.delete();
message.reply("Please don't use that word here")
}
}
}
I need to delete message.reply
NO NEED FOR LOOPS
If your bad word filter has a timeout doesn't that defeat the point tho
make it like, delete up to 3 messages withing X time, then timeout the user for Y time
you're telling me one step at a time for the require inside the function but y'all want them to add a timeout ๐
During that time out people can spam blacklisted words
oh yea..
Don't lump me in with that dood
:c
lmao ban
module.exports = async (prefix, client, message) => {
const blacklist = require("./blacklist.json");
if (blacklist.includes(word)) {
message.reply("Please don't use that word here")
await message.delete();
}
}
``` like this?
yes lol
๐
One of the reasons blacklisted word filters are never done
aaaaaa i got it now
calm down satan
there is countless ways to get around them, and it will be hard to try and create a check and balance for all of em
doesn't dyno have that
yeah but it sucks
Yes, but they literally just check the word and delete
Cause that is really all you can do
I was joking
Up to how you wanna handle it
with the ban
machine learning is the only hope for filters
I dont have experience with it
ban them for it
Speedy lets make a bot that relies only on machine learning /s
permanently
two messages sent at once? ban
sends a message? ban
remove the /s
i'd enjoy to colab on a machine learning project with someone
i dont know it much either ๐
Do you care if I have 0 clue about machine learning

i only know the barebone basics
a machine learning can be simple sometimes believe it or not
module.exports = async (prefix, client, message) => {
const blacklist = require("./blacklist.json");
if (blacklist.includes(word)) {
message.reply("Please don't use that word here")
await message.delete()
then(() => message.member.kick('User kicked for sending spam links.'))
}
}
I don't even know the basics
I use perspective API
based on what you're trying to do ofc
what
if im gonna ban or kick I can remove message.reply
right?
there is no need for that
no tutorial will properly explain how popular ml algorithms work under the hood because if they did i'd already be a master at it
if the kick messages includes it
then() isn't even proper syntax
are you using notepad++ to code how are you not seeing errors
let me try to run it
you will see issues
I regret making the error handler
because .then only works with promises
and you're using .then on literally nothing as if it was a method
not even using a .
also delete does return a promise
but using await and .then is useless imo
If you want to set an welcome message for new members example:
how do we mention the user and guild?
automatically
to mention the user you can write <@USERID>
there is no guild mention
thanks buddy
I'm going in the rabbit hole wish me luck
smooth
the concept of raytracing is pretty simple
for every light source you shoot N rays at all directions, the pixels hit by it get their lightness calculated
or reflection in the case of glossy surfaces
I'm using useState for React in order to create a search function. However, whenever I use setResult, result get's overridden and not updated. Either that, or it says that result is null (because I set it to that of course, but I'm not sure how to approach useState).
const [result, setResult] = useState(null);
let types = ["array_of_links_here"];
for (let type of types) {
const requestOptions = {
...
};
// Fetching works fine.
fetch(config.api_server + "/search", requestOptions).then(async res => {
let json = await res.json();
console.log(result); // Always null. Never a JSON object.
setResult(json); // Overrides result.
}).catch(err => {
console.error(err);
});
}
// Display the results if there are any. Works fine, but since result is overriden, the results that are displayed are innacurate sometimes.
{result ? result.map(item => <Feature key={item.id} title={item.title} link={item.id} path={item.path} views={item.views} likes={item.likes} cover={item.cover} />) : ""}
I'm not quite sure what you're trying to do, but why not await the fetch or double then?
fetch(...).then(res => res.json()).then(data => {
const json = JSON.stringify(data);
console.log(json); //output as json
});
at least that's how I would do it
I'm trying to use useState to store the results of a search, then display it.
The problem isn't the output more-of just having issues with useState. But thank you fetch(...).then(res => res.json()).then(data) is a lot more efficient actually then what I have right now.
that's great then. I'm not quite sure what useState is, so can't really help you with that
Ah nw. I'm learning React atm so I'm quite confused myself haha
hope you resolve it! gl with learning
you're using setResult() inside a loop, that'll overwrite any previous type
is that what you want?
you should use arrays instead
useState([])
setResult(previousValue => [...previousValue, json])
Oh no no no no no
Why are you require()ing the json every time the function is ran ๐ญ
does it really matter when it's cached
No but the problem is still the same
lmfao hi luke
hi
No need to require it every time the function is ran
I mean
Just makes it more confusing
it literally doesnt matter and not really
That's the issue I'm having atm. Just switched to an array, but unfortunately now the array just stays empty.
const [result, setResult] = useState([]);
let types = ["array_of_links_here"];
for (let type of types) {
const requestOptions = {
...
};
// Fetching works fine.
fetch(config.api_server + "/search", requestOptions).then(async res => {
let json = await res.json();
console.log(result); // Array is always empty.
setResult(result => [...result, json]);
}).catch(err => {
console.error(err);
});
}
{result ? result.map(item => <Feature key={item.id} title={item.title} link={item.id} path={item.path} views={item.views} likes={item.likes} cover={item.cover} />) : ""}
json returns an array of JSON objects:
[{ id: "something", cover: "something", title: "something" }]
what happens when you log json? does it log the proper object?
It does
i see
i honestly never used fetch without useEffect(), maybe try wrapping that whole code inside a useEffect()
Ah okay. I'll try that.
I think it might be more of an issue with joining the two arrays together, so I'll first see if setResult(json) does anything
All right
it's also not asynchronous
it continues the loop without waiting for the previous type to be done fetching/setting
setResult(json) doesn't seem to work either. And also I forgot that I updated my code:
fetch(config.api_server + "/search", requestOptions).then(res => res.json()).then(json => {
...
});
ah yea. that's fine i just want the results to be shown. doesnt matter what order
yeah you definitely need a useEffect()
it will rerun ALL the loops when it gets rerendered
it's a mess
and make sure it runs once too
and you also have to wait for all the requests to be done first
doesn't useEffect just make it easier to make outside calls from the current react app?
I can't remember entirely what useEffect does
it's a hook for componentdidmount i suppose
it could be used for that
but it also can be ran if one of the dependencies provided gets updated
in this case it runs once since i provided an empty array
I see
Thank you! The issue though is that I only want to send a request when the user clicks the button. I believe useEffect is called on render.
wait nvm
oops
actually wait yea i thought i was missing smth. useEffect is only called on render. i cant call it on click
been rocking with dracula soft for a while
I use default dark ^_^
Or do what I did
Get the dare
Date
Compare to one in a text file
If different, send the message and update the date
And check every 0.5 seconds
that works too
Very badly
if you want a consistent time each day though then use cron jobs
This was really bad at coding era
then make it a function and use onClick attribute on a button
you can use a cron job in a discord bot...
@lyric mountain got my cmd handler working thanks to ur code
Nice, reflections?
questionably so
I am using reflections to the best of my ability
(to the best of your ability ;))
That's good, you'll eventually get the hang of it really well
I honestly didn't expect it to work at first
me when his command handler looks the exact same as yours moment
Another good usage of reflection is getting variable data without referencing the variable
a good usage of reflection is completely breaking all java semantics and repurposing the language for something completely unsafe ๐
Like, let's say u have
public enum Stuff {
A, B, C, D, E
}
var aColor = new Color(255, 0, 0);
var bColor = new Color(0, 0, 0);
var cColor = new Color(255, 255, 0);
var dColor = new Color(0, 0, 255);
var eColor = new Color(255, 255, 255);
What are enums?
you could get the proper color using the variable name as in <enum>.name().toLowerCase() + "Color"
@wheat mesa the piggy told me they are different from ts enums
Pr something like that
In ts enums represent values, in java enums ARE the values
They're basically final variables that can represent stuff like states, bitfields, keys, etc
wtf is this
https://github.com/OtagamerZ/ShiroJBot/blob/rewrite/src/main/java/com/kuuhaku/model/enums/Category.java
"Look at his category enum"
Misty: "ok... wh-What the fuck?!"
Enums are also O(1) access
Legacy code 
But well, those are command categories
With some additional info
Enums can have variables too, like classes
never knew java had a Function<> generic class in the standard lib
Is that relatively new?
Nope
Thought I tried to look for something like that sometime and couldn't find it
It's from the same batch as Consumer and Callable
Consumer gets a value, Callable returns a value, Function is the fusion of both
Ah it's java 8 then
explains it, I think we use an older version in my cs class somehow
no stream api :C
Imagine taking a CS class that actually teaches you something
It literally represents a function, as in void aName(int n) = Function<Integer, Void> aName
All mine did was teach me how to be more of an idiot
my CS teacher didn't even know what an algorithm is
Yeah ik
Used that same concept in a scuffed math parser I made in C# before I made a proper parser
Ah
let's just say it was... not a very good codebase
hence why I have since private-d it
Didn't work after I tried adding boolean expression support into it
Triple booli check is valid in c#?
wdym
a = b > c < d
that's lambda
A
c# uses lambda syntax similar to js
Thank you! That worked for me.
ok my brain is dying trying to understand rust lifetimes
this syntax looks like shit and I don't understand it at all rs pub enum Something<'a> { Something(&'a str), Nothing } like what does 'a even do
Somethingn<'t> 
I have a question about something dealing with command arguments.
Sure
My idea was to use generics to give types to what my arguments could be. e.g
package dev.misty.interfaces;
import net.dv8tion.jda.api.entities.Message;
public interface Executable<T> {
void execute(Message msg, T args) throws InterruptedException;
}
package dev.misty.commands;
import dev.misty.interfaces.Executable;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
public class TestingCommand implements Executable<TestingArgs> {
@Override
public void execute(Message msg, TestingArgs args) {
msg.getChannel().sendMessage("Hello " + args.target.getUser().getAsTag()).queue();
}
}
class TestingArgs {
Member target;
}
But when passing the stuff to the execute method in the message received event I have no idea how i should parse the args to be what they should be
try {
Main.cmdManager.getCommand(cmdName).command().execute(event.getMessage(), content.substring(prefix.length() + cmdName.length()).trim().split(" "));
} catch (InterruptedException e) {
System.err.println(e.getMessage());
}
Right now this is how it looks.
I know if I want to use Member as a type for the argument i'd need to properly parse what the args given to into a Member but that is just an example
really i'd want to support any type for arguments
I'd likely need to make a parser of some sort
Look at my rewrite branch command handler
It's hard to explain without some example backing it
Are you talking about the SignatureParser?
Basically you want to use regex to validate and parse the input into the proper type
Ye
It indeed is lmao
But well, you can either use space-delimited positional args and throw an error if the type doesn't match
Or use regex which can validate without attempting a cast
The first thing you need to do is isolate the prefix
After that, the very first word before space will be your command name
Anything after that should be treated as arguments
Yea
My parser basically works based on a pattern matcher declared in the Signature annotation
I see
Based on that pattern, it can extract named parameters, and allow optional arguments too
Which is noted by :R on it
I see
This is just how I do it, you have a myriad of ways to parse your input
I like the pattern structure because it feels easier to read and work with
(also I spent 3 hours writing a custom linter for it)
This all does seem a bit more complex for me to handle rn
Start for the bottom, simple space-delimited params
Waffle was right about this being a complex situation aha
Thrn work your way to the top
Space delimited?
!!command param param param
Ah yea
Btw, if you were to use a command in ur bot that took in input how would it look?
Say the kick command
The pattern?
like how would the use of the command look
Idk, like s!kick @user
I see
I was wondering cause I am not entirely sure how you actually use the @Signature annotation when parsing
Like, let's say I have a mute command
s!mute @user time
Patterm would be
<user:user:r> <time:text:r>
user:user:r
The parser would look at the command's signature and see if the input matches
first I assume is the name of the argument, second is the type, and r is required?
Ye
That in the case of my parser
Yours can be any structure u want
But as I said, no need to write a whole parser yet
Start simple
String input = ...;
String prefix = <get from db>;
if (!input.startsWith(prefix) return;
String[] args = input.replaceFirst(prefix, "").split(" ");
String cmdName = args[0];
args = Arrays.copyOf(args, 1);
Something like this
Obv u need to case-proof it, but that's just an example
(note: it might be worthy to use \\s+ in split in case of multiple spaces)
An easy way to do a type-checking (only for primitives) would be an array of classes
Like [String.class, Integer.class, Integer.class] for 1 word param and 2 int params
Just compare the arg index with the type array entry
There are really a ton of ways to check types
Yea I might make an actual parser though as I want to support any types, primitives, JDA's or my own
Jda gives u the regexes for all mentionables btw
I don't remember in which class tho, but they're constants
Oh nice

I kind of like your method of parsing arguments
Lul ty
but ima try and come up with my own way to challenge myself
If u want I can give u a commented version of SignatureParser
So u can understand what each line is doing
Sure, I'll resume the rewrite tomorrow anyway, so I can do it befote I start
is there anyway to trim the length of a string?
because I want to post my console error to discord webhook
but max char is 2048
.slice(0, 2048)
๐

server perfomance
but it is good?
like the perfomance?
yeah I don't know why u guys are laughing lmao
because I think it would be unefficient
loop through first 2048 charas of string and concat them 
It's definitely more efficient than whatever you'd write
because it's an in-built method
okk
-needdev @round crow
@round crow
You seem to be asking for something you don't have experience for or something that hasn't been done yet, but really need for your bot/server.
You can hire developers from Fiverr or Freelancer to code the things you need for your bot/server.
Ty! 
does ephemeral response only work with slash command?
isn't this a place for active devs? I see most messages here are of people trying to dev their own bot,
That would class as advertising
Because you were trying to recruit users for your platform
Yep, this isn't right place to advertise
If you have any problems related to development you can ask here 
got it ๐
any ideas where could I reach out for fellow discord developers? looking to work closely with some builders giving them the platform for free in turn of quality feedback
post on reddit or something
or a forum
just not in discord servers, as it would count as advertising
thanks!

๐
is it possible to await a component from an interaction reply?
const msg = await interaction.reply({content: "..", components: [...], ephemeral: true});
msg.awaitMessageComponent(...)
it says msg is undefied if i do that
maybe i should fetch the reply first
yeah set fetchReply to true
await interaction.showModal(modal);
const collector = interaction.channel.createMessageComponentCollector({
componentType: 'TEXT_INPUT',
time: 15000
});
collector.on('collect', i => {
if (!i.isModalSubmit())
return;
// .... more code ....
}
i have this code, but the collector isnt listening to the values typed in the modal and im not able to submit the modal itself, any help?
(using a seperate interaction listener did work but i want to know if its possible to listen to the submit within the same code where it is sent)
Not sure if a modal is treated like a normal component
Await the reply sending the modal then use the following method
oh thanks
await interaction.showModal(modal);
const filter = i => i.customId === 'embedModal';
interaction.awaitModalSubmit({ filter, time: 15_000 })
.then(async i => {
const name = i.fields.getTextInputValue('nameInput');
const title = i.fields.getTextInputValue('titleInput');
const description = i.fields.getTextInputValue('descriptionInput');
const color = i.fields.getTextInputValue('colorInput');
const image = i.fields.getTextInputValue('imageInput');
console.log({ name, title, description, color, image });
await i.reply("Modal submitted!")
})
.catch(console.error);
``` this is my code now
but awaitModalSubmit doesnt register the submit and ends automatically after 15s
have you given it the slash commands intent in the oauth developer portal?
not just 'bot'
you will need to regenerate/re-add from URL too
does the custom ID match the custom ID you set in the modal you sent?
bro really made a bot that reminds him when his birthday is
whens your birthday
so i can confirm the cron
ah daily
but yeah that cron looks good
you can set it to a minute to test it
do you not use code blocks for evals??
why lmao
this is much nicer```
like i do
b!eval js //code here
also u get highlighting
which djs version are you using
๐ค
can you post your code showing what member is?
๐
Isn't mentioned already a Member?
Why not getMember directly?
I've not used interactions much so I might be wrong, but don't you need to edit the interaction command itself aswell?
ah, yeah https://discord.js.org/#/docs/main/stable/typedef/ApplicationCommandOptionType
no members just users.
I'm not sure why getMember wouldn't work for you.
whats logged in that console.log(mentioned)?
I doubt timing out a member already existed when djs 13.1.0 was a thing
You should check the docs selecting that specific version and make sure
Well to the latest tbh
There are quite a lot bug fixes and changes
I doubt there are breaking changes between 13.1 and 13.7
lowest version with timeouts 13.4.0, but yeah latest makes the most sense.

Like I said I donโt think there are many changes between those versions
huh 13.8
Did I miss something
Hmm
Published 19 hours ago
Huh not even a changelog yet
@sharp geyser here
here's the ban command in case u need an example of it being applied
what language is that ๐ฟ
the programming language is java, the pattern language is shirosig (my own)
๐
at least I get real threads u.u
real enums?
I think ur confusing java with ts, java does have enums that are enums
so I installed everything I needed as I'm on a new machine and
- D:\bot\Main.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (D:\bot\Main.js:2:17)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'D:\bot\Main.js' ]
}
๐
Did you copy your node_modules folder from somewhere?
god please at least use Kotlin
Java is so shit and verbose
Tell me you don't code in java without saying you don't code in java
There is none 
Debugging is stupidly easy because of that
10 minutes to write a hello world program
public class Main {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
vskt fun main() { println("Hello, world") }
ain't no way you prefer the former
besides, the latter's literally "fun" 
Ok, now what's the name of the class, and how u get cmdline args?
there is no class :P
What is its visibility?
But what if I want one?
you can write it the same way if you really want
Ok, then use proper examples
???
you're a skid
Lul tf is this?
You come out of nowhere, with baseless arguments and call me a skid?
baseless arguments, you just can't understand basic things lmao
I told u to use comparable examples
that was one
it's the same code behavior
if you can't see that, I don't know what to say
The top code has visibility info, class info and cmdline argument access
do you need those in the example? no
are they required? yes
That's a shitty argument tbh
C++ is outdated af, yet it can't be replaced
whatever bro
blocked
not worth my time
any actual developers here or does everyone use Java lmao
i'd say its too modern for its own good
never thought i'd say that about something
C++?
it's kind of a mess
low level roots with modern stuff that doesn't really fit built on top
even though its born from c i think it still couldve been a great language
Rust is a lot nicer imo
its mainly the std library thats a problem
some of the features are too modern and aim to make things simpler instead of faster
Java meets C 
Actually it's not the same behaviour
They do the same thing
the first one prints Hello, world! while the second one prints Hello, world
big difference
ok I'm back
typing on iOS
bet
ios programmer opinion immediately disregarded
lmao do u code as a hobby?
and what you're gonna be paid in crypto ๐
I'm working 30hrs/wk rn
wait, there's a meme for this scenario
nah
lemme see if I find it
irdc
1 dogecoin payment
oh no no no overconfident dev moment 
how so
god complex
how so
lol
every c++ dev
I mean you basically have to be god to write good C++ code
(they sometimes dont write good code)
lmfao
shared_pointer everywhere
cringe
smart pointers ๐
LOL
you give: performance and speed
you receive: sanity
nah cant find it, don't know exactly what to type to search for it
skill issue
unique_pointer is most likely just as fast as the regular pointers
and it prevents so many issues
unique as in borrow checked or what
unique as in one owner only
ah like it can't be copied
dollar store rust rip off
sounds harder to make a major mistake with
imagine thinking c++ has memory safe borrow checking ๐
I tried C++ for a while and just switched back to Rust
anything can be fucked with if you try hard enough
couldn't handle the spaghetti
rust developer realizing some things just cant be performed safely and you have to use unsafe code sometimes
When 90% of the rust std is inside unsafe blocks ๐
I'm fine with unsafe code
It's just the language itself I dislike
rust making you mark operations to a static global integer as unsafe just because of race conditions even though you dont use any threads
I understand when variables go out of scope and are therefore destroyed but I have no idea what this 'a syntax does
tells the compiler how long a variable is alive
I know but I have no idea how to use it
someone told me to do this ```rs
pub enum TokenValue<'a> {
String(&'a str),
Number(f64),
}
the str reference lasts as long as the enum itself
It means the string will live at least as long as TokenValue lives
This seems almost like the async await curse in c# where it spreads throughout your code like a disease
you can also just use String if you don't want to use a reference
Yeah it's a little annoying but it's only in type definitions so eh
rust users when you turn a reference into a pointer: ๐
Oh you don't need to bother with actually doing anything special once the struct is instantiated?
Raw pointers kinda defeat the purpose of the borrow checker if you don't need them
yeah the compiler handles it
rust doesn't have safe pointers
rust out here making you define every field of a struct with no way to assign default values
Ok so what I'm understanding here is the reason I need to use a lifetime here is because the reference to the string could potentially be dropped in the code and when I try to reference it in the struct for say a function or something, it's unsafe?
yes
That makes the struct have a default value you still have to pass it as a field
And this is a practice I should follow for all reference fields in a struct?
in some cases the compiler infers that though
yeah it'll require you to generally
but you can reuse the same lifetime parameter
you can ..Default::default()
any data in the struct cannot be freed before the struct itself
but that's still specifying the value
Yeah that makes sense
I didn't understand it because last night was the first time I actually tried to understand what lifetimes do
wdym
c developers realizing rust has no malloc: ๐ฑ๐จ๐ฐ๐ญ๐ญ๐ฎโ๐จ๐คฌ๐คฌ๐คฌ
I've been learning Rust bc of the Bevy game engine
c developers realizing they don't get to cast 30 different void pointers to 20 different types in rust
it's a pretty based language
C developers realizing Rust doesn't pollute the global namespace
it's actually not recommended to namespace std
that's not a Rust nor C thing

