#development
1 messages · Page 2001 of 1
you can't do that, you'd be moving a out of it's reference into b
unless AClass implements the Copy trait afaik
too confusing
most things you do will result in the object being copied but in this case it will be referenced
it does get confusing
In Rust things get copied instead of getting moved only when the struct which is getting moved implements the Copy trait

In C++ it's confusing yes 🙂
How would I check if a String is a hex color?
Ex.
function checkHex(str) {
if (!hex) {
return false;
} else {
return true;
}
}
...
checkHex("#f2445"); // true
checkHex("javascript"); // false
This is for an embed command.
/#([0-9a-f]{6}|[0-9a-f]{8})/i
Ah thank you
that'll also consider 8-char colors (alpha)
Thanks that's super helpful

/#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})/i
btw how doesn't regex have a match EXACTLY N characters OR EXACTLY M characters
like, all it has is {N,M} which is match ANY amount between N and M
you got an issue here
/#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3}/
You need to check for the larger length at first
Or any value matching the first pattern will always be true
note /i
Length not case sensitivity
aham
Oh yeah true
/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i
now it'll match the entire string
Still wrong
why?
It will never match a 8 length pattern
As your first pattern check is 3 length
#ff000000 will fail the first two
because ^ and $
it denotes begin and end of string
I don’t see that
Oh lol

why now
actually, forgot "tests" exist
Yeah single strings of course
there
Not multiple or multi line
Oh nvm then
^ it's to validate a single word
Though he’s searching for hex colors in a string
And change the capture group (()) to a non-capturing group ((?:)) since the context doesn't require them to be captured 
Doesn’t matter in JS anyways

Anyone got a fancy regex to check to see if it's a discord server invite?
I regex dumb
He isn’t doing a match replace
It does
just check if string starts with https://discord.gg
or simply if it contains discord.gg
There is discordapp.com too
discordapp still exist?
¯_(ツ)_/¯
Just google for it, there’s a regex example
didn't they abandon that url?
var match = content.Contains("discord.gg/") || content.Contains("discordapp.com/invite");
Is what I got atm lol
Covering all domains
VAR
lugtfm
let u google that for me
Might be in browser
🤣
C#
understandable, have a great day
Was already concerned about Contains()
JavaScript developers when they see var in any source code/snippet
Oh god Voltrex
just experiment in https://regexr.com
Typing 10 min
regex playground
Yeeee I've played in Regex101 for awhile
regexr >>>
¯_(ツ)_/¯
can't deny
Oh god FakE, driving 24/7
MY MAN
(Copium)
tf fake driving???
MOOODDD BAN
If ur going to use JS, at least use TS 😛
For my embed command, I'm attempting to parse \n to actually create a line break. However, when i send the embed \n doesn't create a line break.
if (description.includes("\n")) {
let result = description.replace(/\n/gi, function (x) {
return x = "\n";
});
description = result;
}
Or... Just be me... And make ur file names .ts and then don't use a LICK of ts xD
https://chicksgold.gyazo.com/b4737270b453088654fc657e53df872c
Oh wait I got one in there! : DiscordForm
(?) it already creates a newline without you replacing them, what are you doing?
I don't really se WHAT you're trying to achieve there
Because it’s being replaced as \\n
ah yes, \n in strings are actually \\n
Ah I see. Didn't notice that thanks.
since \n is a char by itself
\ will always be escaped
For slash commands, you can't press enter without sending the command.
Speaking of string escaping. I recently found showdown npm package. Makes discord previews super ez
getMarkup(content) {
const converter = new showdown.Converter({ strikethrough: true });
content = content.replace(/(\r\n|\r|\n|\\n)/g, '<br>');
let html = converter.makeHtml(content);
html += '<script>console.log("injection")</script>' //Keep this in here and look for this in the output. Should be sanitized out.
return sanitizeHtml(html);
}
https://chicksgold.gyazo.com/9400697de0493d3f28beae9bae2376be
You're replacing actual newlines by using \n in the regex since that's a pre-defined special character, you must escape them as /\\n/
I type faster when I’m driving
Made a previewer in like half a second. Worth it
Ah I see. Thank you!
the car needs a driver update
KNEE SLAPPER
yk, faulty drivers sometimes cause crashes
@earnest phoenix where’s my answer about the capture group?
Hm?
Anyone else playing around with the new modal form stuff? Been loving the new modal form stuff
Just wish it accepted Menu Selects
It’s crap
It’s a shame that it doesn’t support drop downs or anything
As long as there aren’t any other field types available
Could be such a cool feature
True
Yeaaaaaa. Menu selects need to happen
Oh yeah, the capturing matters in any case no matter if you're calling String.prototype.match(), RegExp.prototype.exec() or even RegExp.prototype.test() methods, so it takes time for our regexp engine to parse them as it stores the values in an internal slot
Not capturing them only passes on and does not store values
Ok you’re referring to optimization then
Which hasn’t any noticeable effects on such a small search
But yeah okay I agree
But it technically isn’t required
The performance difference is negligible, but as the capturing groups get larger or more are used, it takes time and memory away to capture them
Yeah
I mean you could have simply said, yes FakE you’re right, here take a dollar and be happy
But okay
Parsing \\n to be a different stream that escapes line breaks (\n, \u200b for Java/C, etc.) results in setting the description of the embed to pause/not work. The command keeps on deferring for some reason.
if (description.includes("\\n")) {
/*
let result = description.replace(/\\n/gi, function (x) {
return x = "\n";
});
*/
let result = description.replace("\\n", "\u200B");
console.log("replaced");
description = result;
}
embed.setDescription(description.toString());
Why are you calling .toString() on a string?
Oops I forgot to mention that was for testing.
Removing .toString() results in the same thing.
The commented code was also for testing.
I also tried the method you mentioned above, although there's a possibility I misinterpreted it.
description = description.replaceAll('\\n', '\n');
Thanks! I just realized the description variable is a constant whoops
thats prob the problem

doing anything with strings is slow af 💀
stupid humans need text
☠️
whenever i see strings as built-in types now in languages it hurts me because i know how they work low level
well in reality they probably deal with string hashes rather than the characters themselves in most cases
bro that hurts stop
by the way did you know hash maps in my os deal with strings by calculating the hash of the string and throwing the string away and just comparing the hashes instead
very cool
Low-level programming language users when they see a string in a high-level programming language

bro especially people using strings to for example extract the decimal places from numbers in javascript
it hurts so much
You better always deal with one only
Not knowing anything about the other can’t stress you too much
i still dont know how to do this effectively - how i do it is i first subtract the whole number by the target number to zero the whole number then keep multiplying by 10 until the set precision or until theres nothing left to grab the decimals
i dont think i can make it better than that
I see
We gotta kidnap that Microsoft dev for you for real this time
While thinking about it a non-Microsoft boy would be better ig
I'm unsure what you're referring to here as "decimal places", you mean their separators? aka 1.45235 -> 45235 or (this may be invalid in certain ways) 500.43264324.3476328 -> 43264324 and 3476328?
Pls rich
yes the numbers after the point
Just split them by the dot and shift the first element, there you've got all the decimals from the separators
yeah bro the thing is in an environment without any libraries or effectively any operating system this isnt really possible
i think theres complex algorithms to tackle this problem accurately and with great precision but i just wrote a simple way to do it
It does not need any libraries to accomplish such thing, and it effectively not having an operating system in the environment is really just another story, you must have such thing to really run anything at this point, unless you're trying to implement that in extremely low-level programming languages, which JavaScript isn't one (which I may have misinterpret you as trying your best way to do it in JavaScript)
yeah didnt mean javascript lmao i meant bare metal
its still quite inefficient though
converting number to a string, then splitting it by a specific character (whole string lookup) creating a new array (new heap placement + array overhead) and then converting the string to a number again (additional overhead)
cant v8 just add a function to simply extract the decimals
they do that during number to string conversion so it should be as simple as making a function
We can add a method to the number/bigint prototypes to extract the decimals, but IMO, that's an extremely specific use-case rather, I have barely seen any projects trying to extract decimals in that way but the functionality may be demanding, I'll try to let the others know and tell you the results maybe
v8, or rather the ecmascript specification adds a bunch of pointless functions anyways that can be easily accomplished without it so i dont see why they wouldnt add such a performance enhancing function
i can find examples if you dont see what im talking about
like very simple and verbose methods
I see what you exactly mean, I mean most programming languages also ship built-in methods that are either mostly useless or just pretty simple to implement, I meant like making a built-in method like that is not that easy on the engine side as we use Torque (custom programming language made inside the V8 engine) such as the Array.from() method (https://chromium.googlesource.com/v8/v8.git/+/refs/heads/main/src/builtins/array-from.tq), and optimizing it would take a while rather than making it in the JavaScript land and trying to optimize it
But you do make a fair point
I'll definitely let others know about that
that is interesting i thought it was all c/c++
is it just a language to simplify things with optimisation
Yep, and for the general things commonly used throughout the whole engine, here's a YouTube video explaining it in detail
https://www.youtube.com/watch?v=YcroNGHHqtU
Jfokus VM Tech Summit 2020 https://www.jfokus.se/vmtech #jfokus #V8 #javascript
When implementing a language VM, there are a number of choices on how to implement the runtime and standard library. For the V8 JavaScript engine, we have tried many different approaches over the years: handwritten assembly, C++, self-hosted (i.e., using JavaScript)...
yes thats what i do
although it depends
if you're using double precision, you will have some issues
its better to multiply by 10, 100, 1000 than to multiply by 10 and then the saved value by 10 again
although i dont know if other langs do the same thing with double precision as js does
this method is orders of magnitude faster than converting to string
okay so my afk command isn't working properly or i'm not defining something right
it sets you as afk in the db but when i sent a message to see if it would send the message it's supposed to it doesn't even register
even when i ping myself
ima send code ina sec
message.mentions.users.forEach((user) => {
if (db.has(user.id + 'afk')) {
let reason = db.get(message.guil.id + `${message.author.id}afk`)
if (!reason) reason = 'No reason';
let embed1 = new Discord.MessageEmbed()
.setColor('RANDOM')
.setAuthor(client.user.username, client.user.displayAvatarURL())
.setDescription(`<@${user.id}> is afk for: ${reason}`)
message.channel.send(embed1)
}
})
if (db.has(message.author.id + `${message.author.id}afk`)) {
let embed = new Discord.MessageEmbed()
.setColor('RANDOM')
.setAuthor(client.user.username, client.user.displayAvatarURL())
.setDescription(`${message.author} welcome back, i have removed your afk.`)
message.channel.send(embed);
db.delete(message.guild.id + `${message.author.id}afk`);
db.delete(message.guild.id + `${message.author.id}messageAFK`);
}
for message and ping detection
if (command === "afk") {
db.set(message.guild.id + `${message.author.id}afk`, 'true')
db.set(message.guild.id + `${message.guild.id}messageAFK`, args.join(" "))
let embed = new Discord.MessageEmbed()
.setColor('RANDOM')
.setAuthor(client.user.username, client.user.displayAvatarURL())
.setDescription(`${message.author} you are now afk!`)
message.channel.send(embed)
}
afk command
well one of your problems is message.guil.id
o h
but I'm assuming that's not what you actually have
unless it is
in which case that would be an issue
You run the command in the shell and get the standard output
import { execSync } from 'node:child_process';
const spec = execSync('neofetch').toString();
tbh I'm surprised that didn't cause an error
Yes
Well it's just the output of the command, so you can show it off in a codeblock
noefetch also has CLI flags/options that you can use to get a certain output format
oh dear god I can see the stacktrace from a 1500+ line index.js file
idk about that...
Yeah 1500 lines might be a bit confusing…
15y ago when we code for gta samp an average gamemode had around 30k lines or more
Most of it in a single file
It’s actually not that much of an issue if your editor is able to show all created functions in a list you fast navigate to
bro gta samp was the shit
It was
are the servers still up
Yeah I noticed they did a graphic rework of gta a while ago
Might brought a few players back in
there's defo still some kiddies on a laptop from the 90s rocking samp because they can't run anything else
Aye

Actually was a great time tbh
Still know like it was yesterday that I was working a new gamemode which I accidentally deleted after like 10-12k lines done, like 1/4 was completed
Any paid developer online ??
That was the time to quit that shit

You’re wrong here

wdym paid developer lol
WOW
clearly you haven't met our java bros in the corner
europe's too busy getting imperialized for tim to move
t(._.)
What tf is that
Never heard of this language
even if you go somewhere like london you'll practically be making $0 given how much it costs to live there
I wouldn't've known that years later I'd be writing my own kernel
i hate making event folders cs it'll fry my cpu nd my laptop will lag
java files that long are usually at least organized into functions, I'm highly doubting that a js file with 1500 lines from a djs bot would be as organized :p
idk what emotional trauma caused me to be like this
so i jus keep my events in my index
???
lmao
you'd be surprised
Must have been terrible
can't count how many times I see huge single methods
oh it is
i have alot of \ so i know where is what
line 2808 is the end of my help command
line 818 is the start of my client.on(message)
ect
I know where everything is since I have two keys on my keyboard
a command and an f key
it's not that difficult lol
says the windows user
if it would make you feel better
lol
what the fuck
I don't care what you do with your file structure
just so my index is pretty
You can’t bully us 98% market share, bitch
I like less files personally
have a single file for interactions and it's maybe 500 lines long
Weird statement
doors = files
wheels = scroll
like literally
^^
just use notes lol it makes it way easier to find stuff
THANKS FOR EXPLAINING
Without you I wouldn’t get it
yes I can
I mean, I literally can't believe how js enforces NO structure
you're literally trying to copy us with windows 11

playing catchup on your bad ui
lol nobody wants w11
*+1 ratio klay
NOBODY
now it's too roundy
Oh no… no round corners OMG
round is better
I mean, not when EVERYTHING is round
Yes that makes anything better
they literally made round round
Even adding a border radius to the border radius
exactly
lmaoooo
We have to agree Klay is crazy
yes I'm crazy
went from intellij to vsc to sublime to maybe neovim one day
I'll go back to textfile
simple ui
rounded corners
less is better
Windows 11 users when their PC blows up from too much random disk usage on start up

guys will be downloading games that take up 256 gb of storage but will get mad when a react dev adds a animated banner that takes up 10 kb
Must be the 37. extension for WoW
gta

5
Call of Duty: Modern Warfare takes 231 GB of storage
lol
yeah call of duty
MFs made the game 3 times larger in install size than GTA V
How tf do you sell that?
A bookshelf full of DVDs
Please insert CDROM 231

(Call of Duty: Modern Warfare is also the game with the largest install size in the market)

That game would take me an entire year to download
@earnest phoenix you tell me
should i recode my bot to a cmd handler?
my index is like
Yeah, command handlers are nice and better to work with, splitting your work into multiple files instead of putting everything in a single file
that long
tokem
my IDE wont be happy with that
spell checking?
I legit have a 240gb ssd that i used to have only cod installed on it 😄
Having both a command handler and an event handler is a must nowadays for maintainability, re-usability, workloads to minimize things and put everything into a map/collection for better handling of said commands/events, and much faster instead of going through an if statement chain/switch statement, since they're burnt into the memory @plucky imp

command/event handlers are also good for easily reloading things 🙂
lol
how would i make my help command like how it is now tho qwq
like that
You can just iterate through the map (or map the collection) after you've set the commands to it
commando is deprecated and discontinued
plus it won't work if you try to run it
You may want to use something like https://github.com/sapphiredev/framework
But I really don't recommend using frameworks for Discord bots
lol
laughs in train simulator
you dont have your own?
I recommend discord bot designer
already used it
isnt that the $10 app on steam
for taco bell bot
I also recommend bot designer for discord
botghost >>
ew
nah i know the elite one
scratch for discord
Make your own discord bot in 5 minutes using blocks with no coding required. Try your bot online and export it on your computer or server.
yes
nvm
uh
a month of nitro classic

i don't really need to lol i know where my code is it's mainly just to see how clean i can get it
if you want you can go to my github and do it yourself
repo should be open
I can do it for you if you want
sure
cs ian got money rn but i will soon
gotta buy clothes
and gas
yes mf i'm not doing that v13 bs
so you're fine with it dying?
sorry excuse my profanity i just hate v12
or is it a small bot / not verified
you can update the code to @earnest phoenix
Time to do shit ton of refactoring 
this supposed to be public?
hmm
ah okay
Imagine asking publicly if that super secret security key is important 
isnt that youtube api key
what can go wrong
No risk no fun
if it was a youtube api key i'm sure i would've out it in my config.json
THANK YOU
yes lastest and greatest until it explodes

"the latest and greatest djsv12 has to offer"
lmao
cant you just set it to 0 or something lmao
LMAOOO i forgot about that
jesus
copy paste?
uhhh
jesus christ
MF <EventEmitter>.setMaxListeners(Infinity)
only thing i coppied from someone else is like
wait, you're using node fetch and snekfetch?
process error events better than try catch
reasons
LOOK
STOP ASKING QUESTIONS
and superagent and node-superfetch
Oh man, rewriting this would probably take years
your eval command looks like a lower level version of mine hmm
Then you get here https://github.com/moonieqt/Merumu/blob/032913eaf37878466680023f819b9daea5c985de/index.js#L331-L438
That’s the reason bot reviewers need to be 18, to handle that sort of physical pain

nice ifs
That bot's node_modules directory must be larger than Call of Duty: Modern Warfare
Discord bot developers carefully typing the n-word in their blacklisted words
lmao
well i am part black lol
so i can use iT
Reminds me of that one picture about gravity
so volt how's the revamp going
Even the creator of Node.js AKA Ryan Dahl reviewed that meme in JSConf
btw if you actually do recode the whole thing with a cmd handler and discord.js v13 i'll be in your debt


I'm gonna be rewriting the whole thing (may Allah help me), I'll let you know how it goes
ty babes
Add it to @quartz kindle s list of projects
I’m sure he has time to
god at this point i might aswell become his personal stripper
i was wondering about the db file and i saw this
@earnest phoenix please no slash cmds bt if you do id be pog
it's actually really well coded
unlike the rest of my code
yes it's not hard to 
I can convert them into slash-commands if desired, but only if you want 
I am reminded by Luca's source code
actually yes pls
it's pretty based ngl
good but unfun imo
They're pretty nice
f u
:P
Btw, why are you creating 2 HTTP servers and listening to them in the main file?
FakE news
redundency totally
i also was gonna link it to a webserver but i forgot css so i left it there
Anyway, what do I get if I rewrite the whole thing mmm?
I like mysql. . . I just hate the company that owns it
And everyone hates Oracle
Postgres is good. Sql server is better
Haa take that
Mongodb is good... but not for all solutions. I usually run 2 db contexts. One Mongo and one mysql
Logs and shit I dump to mongo
i am using localhost mongodb and is good now
uh
me

mongodb local is epick
Heard localhost has a good latency

Naw pretty shite
yes
evenin' folks 😘
i no longer have thigh gap you can have feet pics 
uhh... wth did i walk into... later folks 😗
LMAOOOO

This channel usually goes from normal to escalating quickly
Nothing special
Mmm, we may take that to DMs 
Common development day
development to mental-development
lol
Im sorry, in what world?
This is the same database that as part of their licensing forbids you to compare it's performance against other databases
It's not a bad database, but it definitely isn't to the same level as postgres
please tell me you're not using json as a database
Thats not me
good
Stop blaming others Java user
i am using localhost mongodb 
stop blaming others for your car accident when texting and driving

man I just live in my own
I actually had to xfer from mysql to sql server for a project recently. Thankfully we use entity framework so ez pz swap
Had some large db problems. Sql server resolved them.
Only cost us like 20k to contract a dba to tell us that
xfer? really? transfer was too long a word? 😛
I'm on phone. Fu
Not my fault ur dent head
😭
Jkjkjk luv u
i told you that in confidence! 😭
:kisses;
embed.setTitle("Command List");
embed.setColor("#7289da");
embed.addField("The prefix for all commands is `!`");
why is this happening?
You haven’t set a field second line
We need to make a second field?
oh its description
i got it
the embed.addField method takes upto 3 arguments, two are required. the title, and body for the field. then its optional arugment for if you want the field inline (defaults to false)
ohh got it! Let me try it
dont think they are called title and body in the code, but thats what they do 😛
lol
embed.fields[1].name: This field is required
embeds[0].fields[1].name: This field is required
make sure it is a string,
.addField("uwu", variable) wrong
.addField("uwu", `${variable}`)
``` correct
There’s nothing wrong with case 1 if you handle your vars properly
I don’t like template strings for one var anyways without concating the var with another string
That’s why the toString() method exists
longer code
Aye that byte or two could blow up the RAM 
Also longer is better
Don’t you know that?
idk that
any emoji's other than those featured, that you guys keep note of to use in your bots? 🙂
Yes, no emoji is missing
hmm, thats fair. i dont have those from any server im in 😢
no emoji like in I don’t use a single one at all
const request = ctx.switchToHttp().getRequest();
if (!request.session.user)
throw new BadRequestException('You are not logged in.');
const id = Buffer.from(
request.session.user.token.split('.')[0],
'base64',
).toString();
if (id !== request.params.userId)
throw new BadRequestException("You can't ");
return true;
So I am saving a token to the session which is just the ID, timestamp and random junk encoded in base64. I am wondering if anyone has any better ideas to make sure that when a user is making a request to a route that either uses PATCH or DELETE that the data they are updating/deleting indeed belongs to them. Right now I am just comparing the decoded ID from the token and the id being passed in the request params
but...
but what about error messages?!
N O E M O J I S

Wtf that looks like crap
If you would use high res icons, okay
But those damn low res pixel emojis
hey, you leave shuckle out of this!
Only icons I like to use are the ones I can use in an embed title
you dont have any commands to like, paginate?
Using SVGs exclusively to have high res on mobile and desktop devices
you can also use emoji's in dropdown menu things
tbf, a lot of emoji look terrible on mobile
Nope I’m using buttons
buttons can have emojis 😄
With WORDS
Like really chaining characters to each other building words
Ewwww
That color that resolution
It’s so ugly
lol
i dont have the time to be creating and uploading full custom emojis, so i gotta use whats available 😄
If those would be just white I could think of it being okay
tbf, i do have fa5-pro
that has tons of svg's
i'd still have to upload them to some server and blah blah blah
@commands.command()
@commands.has_permissions(ban_members = True)
@commands.cooldown(1, 2, commands.BucketType.user)
async def unban(self, ctx, member: BannedMember):
user = discord.user
await ctx.guild.unban(member.user)
unbanmsg = discord.Embed(color = 0x2ecc71, description = f":msuccess: {member.user} has been successfully unbanned by {ctx.message.author.mention}")
await ctx.send(embed = unbanmsg)
class BannedMember(commands.Converter):
async def convert(self, ctx, argument):
if argument.isdigit():
member_id = int(argument)
try:
return await ctx.guild.fetch_ban(discord.Object(id = member_id))
except discord.NotFound:
raise commands.BadArgument("This member has not been banned before.") from None
ban_list = await ctx.guild.bans()
entity = discord.utils.find(lambda u: str(u.user) == argument, ban_list)
if entity is None:
raise commands.BadArgument("This member has not been banned before.") from None
return entity
i have this command inside a cog i have the class to but the comman disn't working?
😢
am i supposed to subclass the class bannedmember inside the commands.Cog
..
wait discord emoji can be a svg?
so how do you use them as such?
That’s the reason I’m bitching about that low resolution emoji shit people are willing to pay money for 
As I said I don’t.
Not a single emoji anywhere
Just a few commands have a svg as icon in the title for reasons
Traceback (most recent call last):
File "C:\Users\culan\OneDrive\Desktop\echo slash\echo.py", line 40, in <module>
asyncio.run(new())
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete
return future.result()
File "C:\Users\culan\OneDrive\Desktop\echo slash\echo.py", line 36, in new
await bot.tree.sync(guild=discord.Object(479997589790523405))
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 861, in sync
raise ClientException(APP_ID_NOT_FOUND)
discord.errors.ClientException: Client does not have an application_id set. Either the function was called before on_ready was called or application_id was not passed to the Client constructor.```
```py
async def main():
async with bot:
await bot.load_extension('cogs.botut')
async with bot:
await bot.start("")
async def new():
async with bot:
await bot.tree.sync(guild=discord.Object(479997589790523405))
await bot.change_presence(status = discord.Status.dnd, activity = discord.Game('/help | echobot.xyz/testing'))
I'm struggling to figure out how to fix this issue I'm running the new version of discord.py I can't find any examples or anything on how this is actually supposed to be done can someone please help me
Well not that I know py but regarding your error you’re trying to change its presence before the bot is logged in successfully receiving the ready event
So I need to move that one
To where it is being used after it's successfully logged in
Move your presence update to the ready event listener
Lol that was a easy fix

That should not have taken me an hour and a half to figure out
lol
My other question is is that it's still not changing the presence
And I still think my commands are not syncing
Yeah well like I said I’m the wrong guy for snakish code 
Is it possible to retrieve the message attachment as a stream?
message.attachments.forEach(async attachment => {
const imageLink = attachment.proxyURL;
if (imageLink.toString().toLowerCase().endsWith(".mp3") || imageLink.toString().toLowerCase().endsWith(".m4a") || imageLink.toString().toLowerCase().endsWith(".wav")) {
console.log(attachment.attachment);
playAudioOrSmth(stream);
}
});
function playAudioOrSmth(stream) {
let resource = createAudioResource(stream.stream, {
inputType: stream.type
});
// Play the resource.
player.play(resource);
}
yes its possible, but you need to create the stream
Ah I see. I looked online (should've done that first my bad) and saw that using node-fetch I can get the file. Thank you!
yes node-fetch can give you a stream
Alright I'm attempting to fetch the audio file from the message and can do so successfully, but when playing the audio the stream type isn't the same as the YouTube downloaded stream (which is a SeekStream, but I'm not sure what that means). Playing audio from the file results in the type "Readable", but I'm not sure how to convert the stream into something that can be played.
async function playFile(channel, guild, quality, file) {
await fetch(file).then(async (response) => {
playAudio(channel, guild, response, quality, "file"); // Plays the audio
}).catch((err) => {
console.error(err);
});
}
function playAudio(...) {
let resource = createAudioResource(stream, { // Results in the error that [object] [Object] doesn't exist
inputType: stream
});
}
there’s probably a good way to use ffmpeg to do that but there’s probably an even better way somehow
https://sourceb.in/9GZiGIpgi2 why the amount not adding on data? did i missed something?
because you are actually setting the amount instead of increment it, use $inc from mongo_ose_
economy.findOneAndUpdate({
guildID: message.guild.id,
userID: member.id
}, {$inc: {wallet: amount}}, your callback)
``` this should work
worked thanks!
How can I make a Utility class called RemoveFirstPara here like this?
type A = (a: number, b: string) => void
type B = RemoveFirstPara<A> // should be (b: string) => void
good job ccls, of course iostream and filesystem don't exist
Hi i request for bot verification and i deny because of ToS and i create new bot and read all the docs few times and made some changes in my bot but i want to know can someone help me to re-check my bot before Discord check it 👀
u came from python?
add space b/w else and if
use blocks {...} with if's
u can only omit {} if there's a single statement after if, for, while etc
else if not elseif
Feud
change the book
Not sure,
I thought something like this would work:
type RemoveFirstFromTuple<T extends [...els: any]> = {
[IND in keyof T as IND extends "0" ? never : IND]: T[IND]
}
type RemoveFirstParam<F extends (...args: any) => any> = (...args: RemoveFirstFromTuple<Parameters<F>>) => ReturnType<F>;
type A = RemoveFirstParam<(a: number, b: string) => string>;
But the RemoveFirstFromTuple isn't working properly
when it should, imo
should work ig
Thats mysql and sqlserver though
Which is, let's face it, not a hard choice to make
Unless you dont want to pay for the propriety license of mssql
Someone gave me this, from ts server
type RemoveFirstFromTuple<T> = T extends [infer F, ...infer R] ? R : never;
it does, remove first element from the tuple
ok now you can use this:
type RemoveFirstParam<F extends (...args: any) => any> = (...args: RemoveFirstFromTuple<Parameters<F>>) => ReturnType<F>;
removes the first parametr
yes, now it works. thx
https://sourceb.in/qaliEbCIBz how can i return if the member wants to deposit higher than the balance in wallet?
How can we check that a channel already following same news channel which one we want to follow again
Just call the findOne command before sending the increment. Also, why're you assigning a constant to a function with a callback?
I'm trying to upload bot, but the reviewer says, "Your bot has a function / command (/ command name) that sends spam or abuses the Discord API." What is considered to be a abuse of the Discord API? The documentation says that I can make up to 50 requests per second. Also, is this considered as discord api call
user.cache.get (user.id) request. Variable = "content"
nope, it's something like mass ban, etc...
What is the command, @halcyon ridge? Also the 50 req/second is not a hard and fast limit for all endpoints.
Its not that, its something like "unbanall" or some shit
unbanall, massban,
yeah
Then i think i don't abuse discord api i don't have many interactions. Could the problem come from this code?
interaction.user.send({ files: [buffer], components: [componentName] })
.then(res => {
interaction.reply({ content: "Check your DM", ephemeral: true });
})
.catch(error => {
interaction.reply({content : "You have disabled DMs, you can't play" , ephemeral : true});
})
is that the command that said is "abusing discord API"?
This code is in the file which abuse discord api
I don't see how that abuses the API
I don't have other code that interact with discord api just this one and users.cache.get(user.id).variable= "content";
why do you think it is abusing the api?
Reviewer said that my command abuse api and i am looking into the file where is this specific command.I don't have much interactions in this file so i am just guessing where may be the problem.That's why i am asking what is considered as spam/api abuse
which command? if you dont know or he doesnt provide the name try dm-ing your bot reviewer and ask about it
One message removed from a suspended account.
When you edit and send messages you also interact with the API. Your bot edits messages way too fast and results in your bot getting rate limited.
Next time come in the reviewer's DMs by yourself instead of getting someone else to come in their DMs for you, thanks.
what would be considered editing messages too fast? Tons of bots have paginated embed messages, or minigames that edit the message multiple times during the course of a minute. so why arent those api spam?
You should refer to Discord's API documentation for this. And the situations you're talking about do not fall under API abuse as most developers ensure reasonable measures are taken to avoid API abuse.
I guess I was more wondering how the guy from above could have been flagged for api abuse from just editing messages. like, how often are you editing message contents for that to occur
iirc, the only time i was ever rate limited, is when i was using nodemon to auto reboot when files changed, and i had logged in too many times within a day 😄
There are no api docs for this
It's just "please don't spam us and wumpus will be happy this afternoon :D"
lol
lmao, best docs 😄
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
That doesn't tell you how to properly space out your requests
It tells you how to implement rate limits
And I think dynamic rate limits are better imo
But it doesn't tell you if sending five messages in a burst is a good or bad thing
But people will tell you it's a bad thing
All bots can make up to 50 requests per second to our API.
That's global
It still doesn't tell you if sending five messages in a burst is a good thing
But they'll still rate limit you
ah
Personally what I don't like is they punish you for getting rate limited
Since if you send too many (even if your client does acknowledge the error and waits) you'll get blocked
be nice if they said something about what to do if your bot was that large that 50 per second was not possible to maintain
I cant imagine how many requests bots like dankmemer or mee6 make per second
Definitely over 50
for sure lol
They're probably exempt
I'd imagine there is something in place for if your bot is that large, they can increase your limits or w.e
You can contact Discord to get different rate limits for massive bots.
yea, i was just thinking you'd probably have to contact them to initiate it
So you shouldn't rely on how 'Mudae' or other big bots on how they edit messages or sends them.
hoo dat? (mudae?)
Some anime bot
ahh ok lol
But their rate limits are roughly applied the same
well, my bots in 1 server. 
They probably can't send 10 messages in a second in the same channel
But can make 500 requests a second easily
what about like, welcomer bots though that send messages on new members. those must be in some guilds which have insane activity
and like, not being able to send the message defaults the purpose of the bot
i guess you could probably discuss your bots needs with discord when applying for increased limits
but... then who will make me feel welcomed 😢
you'd just batch them up into a single request
Discord!
if it's more than like 1 every 2 secs just batch them up into sets of 5
oohh yea true, could easily cache them for a few seconds and send in bulk
Note that they mostly use webhooks, same for logging bots.
Webhooks which have a rate limit of 1'000 requests per 60 seconds.
some big logging bots are so high quality
https://capy-cdn.xyz/V4CfbgiM.png
Now: [object Object]
Was: [object Object]
made by eva™️
How to setup reply in js ?
Nah... you gotta use an element inspect in your browser and find the class names and elements yourself
Like this
One tip the user content should be in the element with the class .content
I saw a picture of how CSS is structured but I am not sure if it is up-to-date
We'll see, thanks
Well just ask if you wanna know something
You gonna wrap your css code in style tags
Broi
I can give you an example...
Would be cool if there is something to orientate 😅
<style type="text/css">
html[data-theme*="dark"] .content .my-wrapper
{
/* properties for dark theme */
}
html[data-theme*="light"] .content .my-wrapper
{
/* properties for light theme */
}
html[data-theme*="dark"] .content svg
{
fill: #ffffff !important;
}
.content .rounded
{
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
</style>
<div class="my-wrapper">
<h1>Big big header</h1>
Text and content in here
<br />
<h4>Smoll header</h4>
Woo very stinky...
</div>
<img src="https://converter.tools.dedns.org/src/img/bans/vac.png" alt="" class="rounded" /><img src="https://converter.tools.dedns.org/src/img/bans/be.png" alt="" class="rounded" /><img src="https://converter.tools.dedns.org/src/img/bans/eac.png" alt="" class="rounded" />
Ofc it requires at least some knowledge how CSS works but actually isn't too complicated
That looks interesting 😄
I have some knowledge in HTML and CSS, some things look familiar to me
Thanks!
Like I said the class content should be your entire description box
If you wanna edit other static thing on the site, things are getting a little bit tricky
Because most of the class names are dynamic
But there are a few css "tricks" to get some
For example the login or vote button...
I just looked at the code and will try to understand the things done here, should not be too hard 😄
Err yeah
nothing is offtopic in this channel 
wut?!
can't be my site lmao
or do you speak about the topgg site?!
Yes
you made a steam bot? @boreal iron
ahh lol, yeah it's very simplified
I don't like things being too colorful or "overstructured"
Can you pass me the link via DM?
errr need to get it myself, too
Nope, just wanted to invite the bot xD
Nah, I kind of like it
but since I'm close to publish a new one I'm not gonna update the old one
Save some work hehe
well I hate frontend...
but compared to the old trash the new one will look like being from another world
espacially on mobile
On mobile it is horrible...
I'm aware yeah... but at least it scales accurate instead of heaving no mobile version at all
someone in here the other day said you dont need to have the message intent to listen for messageCreate events. but im testing atm and not getting any message events without the intent 😦
even when i at the bot
that's the whole point of the message intent
i know this. but people in here said you still got the events, just not the message content
Did not mean your site, coding it in general for mobile is terrifying 😅
ah lol
nvm then
Looks clean
was about to say things are getting a lot cleaner
and ofc for all bitches out there crying about dark mode
Will it just look in the preview like this? I am sure I said it should be in one row 😅
lmao
Just a picture to test things
just use to display them as inline-block
they will still pop in a new line if you don't have a space in between the img elements
or use flex
shhhhhhhhhhhhh
which is definitely the better option
go away you css3 devil
I will see what I can do, thanks 😄
sure... just throw questions in if you have some
I brb in 20 mins
And don't listen to those css3 freaks
they wanna take your soul
css is cool 
I'm good at it, though. (atleast people say that)
is hard but very cool
See my discord UI clone
https://curios.vercel.app/discord
css is pretty lame
wow
very blue
but cool
oo theres the the
characters are a lot bigger than they are on the discord client
type Dispatcher<E extends Record<string, (...params: any[]) => void>> = {
[Key in keyof E]: RemoveFirstParam<E[Key]>
}
function useFunctionalReducer<
S = Record<string, any>,
A = Record<string, (draft: S, ...params: any[]) => void>
// @ts-ignore
>(actionMap: A, initialState: S): [Readonly<S>, Dispatcher<A>]
function useFunctionalReducer(actionMap, initialState) {
const cachedReducer = useMemo(
() =>
produce((draft, action) => {
actionMap[action.type]?.(draft, ...action.payload)
}),
[]
)
const [state, reactDispatch] = useReducer(cachedReducer, initialState)
const dispatch = useMemo(() => {
const dispatch = {}
for (const type in actionMap) {
dispatch[type] = (...payload: any[]) => reactDispatch({ type, payload })
}
return dispatch
}, [actionMap])
return [state, dispatch]
}
export default useFunctionalReducer
// Example Usage
const initialState = { count: 0 }
type IState = typeof initialState
const ActionMap = {
increment(draft: IState, value: number, allowNegative = false) {
draft.count += value
},
}
function Counter() {
const [state, dispatch] = useFunctionalReducer(ActionMap, initialState)
dispatch.increment(-5, true)
return (<p>{state.count}</p>)
}
Feud, can u make it so I dont need // @ts-ignore
What's the error without the @ts-gnore
its not that blue. Y looks like that for u
@cinder patio
Type 'A' does not satisfy the constraint 'Record<string, (...params: any[]) => void>'.ts(2344)
Why are u using overloads there in the first place? Not sure if that's the cause but
I removed one. To make it short
That's this
function useFunctionalReducer<
S = Record<string, any>,
A = Record<string, (draft: S, ...params: any[]) => void>
>(
actionMap: A,
initialState: Partial<S>,
initialAction: (initial: Partial<S>) => S
// @ts-ignore, same error here too
): [Readonly<S>, Dispatcher<A>]
initialAction is passed to, useReducer as 3rd param
No clue honestly. I've only seen this type of error in call sites, no clue why it would appear there
might be an extension
hmm , sed 😕
@cinder patio Oops, there's this Dispatcher type too. I update above now.
well that makes much more sense now
The job of the Dispatcher is to remove all draft: IState, from ActionMap, event functions
replace = with extends, so
A extends Record<string, (draft: S, ...params: any[]) => void>
= just gives it a default value, A can still be pretty much anything
Ooh, its magic
I tried that before, but it didnt do anything. Now it does.
Ok now, can I make it so it shows error, when ActionMap has methods that doesnt hv, IState as first param.
It not required, but, if it could be done. I would like to
Well… nobody actually said something else 
Possible but difficult, give me a sec
if (!(args[0] instanceof IState)) throw new WrongParamException();
oh wait, u mean the actual signature
type WithState<T, B> = {
[IND in keyof T]: T[IND] extends (...args: any) => any ?
Parameters<T[IND]>[0] extends B ? T[IND] : (...args: [B, ...Parameters<T[IND]>]) => ReturnType<T[IND]> : T[IND]
}
converts all methods which don't have B as their first parameter
@rocky hearth ^
holy that looks almost on-par with c++ readability
yeah it's not the prettiest
i have no idea if this fits the channel (i mean it should do) but i'm writing a bot and i'd like your criticisms of this page (ignore the emojis on there), especially the wording. apparently the last card about cross-server calling was worded pretty badly
here's the page in all of its glory
Looks too texty
I think the Features text should be smaller
And the footer could use some styling to look more like how footers are decorated on most sites
Spaced out and maybe even separated into categories
totally agree
And maybe some alignment like making sure they all share the same border (titles and cards specifically)
How can I shift enter on Regards?
<p>Hello there,</p>
<p>I'd like to thank you for reaching out to my email.</p>
<p>This is a really simple email template. Its sole purpose is to get the recipient to click the button with no distractions.</p>
<p>Regards</p><br /><p>Mohammad Hajjiri</p>
Well, unfortunately, it doesn't shift enter.
What do you mean by shift enter?





