#development

1 messages · Page 2001 of 1

lyric mountain
#

so if I did ```c++
AClass a = new AClass();
AClass b = *a;

does that mean B is not a reference of A but a clone?
cinder patio
#

you can't do that, you'd be moving a out of it's reference into b

#

unless AClass implements the Copy trait afaik

lyric mountain
#

too confusing

split hazel
#

most things you do will result in the object being copied but in this case it will be referenced

#

it does get confusing

cinder patio
split hazel
#

OH YOU MFS TALKING ABOUT RUST LMAO

#

I didn't scroll up

lyric mountain
cinder patio
#

In C++ it's confusing yes 🙂

simple stump
#

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.

lyric mountain
#

/#([0-9a-f]{6}|[0-9a-f]{8})/i

simple stump
#

Ah thank you

lyric mountain
#

that'll also consider 8-char colors (alpha)

simple stump
#

Thanks that's super helpful

sudden geyser
#

still wrong

#

also need to check for hexes that are three characters long

lyric mountain
#

/#([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

boreal iron
#

/#[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

lyric mountain
boreal iron
#

Length not case sensitivity

lyric mountain
#

a-fA-F

boreal iron
#

Doesn’t matter

#

Same amount of steps

lyric mountain
#

freerealestate aham

boreal iron
#

But faster

#

Without the global flag

lyric mountain
#

except you forgot colors with alpha

#

which are length 8

boreal iron
#

Oh yeah true

lyric mountain
#

/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i
now it'll match the entire string

boreal iron
#

/#[0-9a-fA-F]{8}| #[0-9a-fA-F]{6}|#[0-9a-fA-F]{3}/

#

Then

lyric mountain
#

why?

boreal iron
#

It will never match a 8 length pattern

lyric mountain
#

it will

#

note ^ and $

boreal iron
#

As your first pattern check is 3 length

spark flint
#

All I see is keyboard cat lang

lyric mountain
#

because ^ and $

#

it denotes begin and end of string

boreal iron
#

I don’t see that

lyric mountain
boreal iron
lyric mountain
boreal iron
#

Oh lol

lyric mountain
boreal iron
#

Wait

#

That’s even more wrong

lyric mountain
#

why now

boreal iron
#

That’s wrong wrong wrong

#

That won’t even match anything

lyric mountain
#

actually, forgot "tests" exist

boreal iron
#

Yeah single strings of course

lyric mountain
boreal iron
#

Not multiple or multi line

lyric mountain
#

better

#

context doesn't require multiline

boreal iron
#

Oh nvm then

lyric mountain
boreal iron
#

Though he’s searching for hex colors in a string

earnest phoenix
# lyric mountain there

And change the capture group (()) to a non-capturing group ((?:)) since the context doesn't require them to be captured mmLol

boreal iron
#

Doesn’t matter in JS anyways

lyric mountain
willow aspen
#

Anyone got a fancy regex to check to see if it's a discord server invite?

#

I regex dumb

boreal iron
#

He isn’t doing a match replace

earnest phoenix
lyric mountain
#

or simply if it contains discord.gg

willow aspen
lyric mountain
#

discordapp still exist?

willow aspen
#

¯_(ツ)_/¯

boreal iron
#

Just google for it, there’s a regex example

lyric mountain
#

didn't they abandon that url?

willow aspen
#

var match = content.Contains("discord.gg/") || content.Contains("discordapp.com/invite");
Is what I got atm lol

boreal iron
#

Covering all domains

lyric mountain
#

VAR

willow aspen
boreal iron
willow aspen
#

🤣

willow aspen
lyric mountain
#

understandable, have a great day

boreal iron
#

Was already concerned about Contains()

earnest phoenix
#

JavaScript developers when they see var in any source code/snippet

boreal iron
#

Oh god Voltrex

lyric mountain
boreal iron
#

Typing 10 min

lyric mountain
#

regex playground

willow aspen
#

Yeeee I've played in Regex101 for awhile

lyric mountain
#

regexr >>>

willow aspen
#

¯_(ツ)_/¯

boreal iron
#

It’s not

willow aspen
#

C# > JS

#

o.O

#

O.o

lyric mountain
#

can't deny

earnest phoenix
boreal iron
#

I don’t

#

Wtf

#

Bully

willow aspen
earnest phoenix
#

(Copium)

lyric mountain
#

tf fake driving???

boreal iron
#

MOOODDD BAN

willow aspen
#

If ur going to use JS, at least use TS 😛

boreal iron
#

Haha

#

That joke

simple stump
#

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;
}
willow aspen
#

Oh wait I got one in there! : DiscordForm

earnest phoenix
lyric mountain
boreal iron
lyric mountain
#

ah yes, \n in strings are actually \\n

simple stump
lyric mountain
#

since \n is a char by itself

boreal iron
#

\ will always be escaped

simple stump
boreal iron
#

Wut

#

I don’t get that statement

willow aspen
#

Speaking of string escaping. I recently found showdown npm package. Makes discord previews super ez

boreal iron
#

This channel is very confusing today

#

WTF Voltrex

willow aspen
#
    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

earnest phoenix
boreal iron
#

I type faster when I’m driving

willow aspen
#

Made a previewer in like half a second. Worth it

lyric mountain
willow aspen
lyric mountain
#

yk, faulty drivers sometimes cause crashes

boreal iron
#

@earnest phoenix where’s my answer about the capture group?

earnest phoenix
#

Hm?

boreal iron
#

Why would it be important in JS? Tell me, now!

willow aspen
#

Anyone else playing around with the new modal form stuff? Been loving the new modal form stuff

#

Just wish it accepted Menu Selects

boreal iron
#

It’s crap

wheat mesa
#

It’s a shame that it doesn’t support drop downs or anything

boreal iron
#

As long as there aren’t any other field types available

wheat mesa
#

Could be such a cool feature

boreal iron
#

True

willow aspen
#

Yeaaaaaa. Menu selects need to happen

earnest phoenix
# boreal iron Why would it be important in JS? Tell me, now!

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

boreal iron
#

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

earnest phoenix
#

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

boreal iron
#

Yeah

#

I mean you could have simply said, yes FakE you’re right, here take a dollar and be happy

#

But okay

simple stump
#

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());
earnest phoenix
#

Why are you calling .toString() on a string?

simple stump
#

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.

earnest phoenix
#
description = description.replaceAll('\\n', '\n');
simple stump
#

thats prob the problem

boreal iron
split hazel
#

stupid humans need text

earnest phoenix
#

☠️

split hazel
#

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

boreal iron
#

Now changing all my api field types from int to string to fuck you off

split hazel
#

bro that hurts stop

boreal iron
#

I actually did for one field today

#

Didn’t notice it was a bigint

#

Stupid me

split hazel
#

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

earnest phoenix
#

Low-level programming language users when they see a string in a high-level programming language

split hazel
#

bro especially people using strings to for example extract the decimal places from numbers in javascript

#

it hurts so much

boreal iron
#

You better always deal with one only

#

Not knowing anything about the other can’t stress you too much

split hazel
#

i dont think i can make it better than that

boreal iron
#

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

earnest phoenix
timber siren
#

Pls rich

split hazel
#

yes the numbers after the point

earnest phoenix
#

Just split them by the dot and shift the first element, there you've got all the decimals from the separators

split hazel
#

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

earnest phoenix
#

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)

split hazel
#

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

earnest phoenix
#

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

split hazel
#

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

earnest phoenix
#

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

split hazel
#

that is interesting i thought it was all c/c++

#

is it just a language to simplify things with optimisation

earnest phoenix
# split hazel 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)...

▶ Play video
quartz kindle
#

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

plucky imp
#

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

wheat mesa
#

well one of your problems is message.guil.id

plucky imp
#

o h

wheat mesa
#

but I'm assuming that's not what you actually have

#

unless it is

#

in which case that would be an issue

plucky imp
#

it is lol

#

tyyy

#

ofc i am horrible speller

earnest phoenix
#

You run the command in the shell and get the standard output

#
import { execSync } from 'node:child_process';

const spec = execSync('neofetch').toString();
wheat mesa
earnest phoenix
#

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

plucky imp
#

yeah

#

like for me i am over the top so mines is a bit more advanced

boreal iron
#

Still no slash commands

wheat mesa
#

oh dear god I can see the stacktrace from a 1500+ line index.js file

boreal iron
#

All in one file means less tabs to open, so less confusing

wheat mesa
#

idk about that...

boreal iron
#

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

split hazel
#

bro gta samp was the shit

boreal iron
#

It was

split hazel
#

are the servers still up

boreal iron
#

Yeah I noticed they did a graphic rework of gta a while ago

#

Might brought a few players back in

split hazel
#

there's defo still some kiddies on a laptop from the 90s rocking samp because they can't run anything else

boreal iron
#

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

earnest phoenix
#

Any paid developer online ??

boreal iron
#

That was the time to quit that shit

earnest phoenix
boreal iron
earnest phoenix
quartz kindle
#

wdym paid developer lol

boreal iron
#

WOW

sudden geyser
boreal iron
#

Just mentioning money and Tim is here

#

My gosh

sudden geyser
#

europe's too busy getting imperialized for tim to move

quartz kindle
#

lmao

#

gib me money or i report you

#

mordekaiser #1 huehueheuheueh

boreal iron
#

t(._.)

split hazel
#

back in the day I didn't even know about coding

#

I just enjoyed life

boreal iron
#

What tf is that

boreal iron
#

Never heard of this language

plucky imp
#

cs i have

#

mod logging

#

and welcome stuff

sudden geyser
#

even if you go somewhere like london you'll practically be making $0 given how much it costs to live there

split hazel
#

I wouldn't've known that years later I'd be writing my own kernel

plucky imp
#

i hate making event folders cs it'll fry my cpu nd my laptop will lag

wheat mesa
split hazel
#

idk what emotional trauma caused me to be like this

plucky imp
#

so i jus keep my events in my index

wheat mesa
#

???

boreal iron
#

Must have been terrible

sudden geyser
#

can't count how many times I see huge single methods

plucky imp
#

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

sudden geyser
#

I know where everything is since I have two keys on my keyboard

#

a command and an f key

plucky imp
#

it's not that difficult lol

boreal iron
#

Ewww

#

Mac

plucky imp
#

cmd handlers are just to make it more organized

#

but

sudden geyser
#

says the windows user

plucky imp
#

if it would make you feel better

boreal iron
#

lol

plucky imp
#

i'll transfer it to one

#

and recode

wheat mesa
plucky imp
#

45 commands

sudden geyser
#

I don't care what you do with your file structure

plucky imp
#

just so my index is pretty

boreal iron
sudden geyser
#

I like less files personally

plucky imp
#

omg

sudden geyser
#

have a single file for interactions and it's maybe 500 lines long

plucky imp
#

why click when you can scroll

#

wheels > doors ppl

boreal iron
#

Weird statement

plucky imp
sudden geyser
#

doors = files
wheels = scroll

plucky imp
#

like literally

plucky imp
#

just use notes lol it makes it way easier to find stuff

boreal iron
sudden geyser
lyric mountain
sudden geyser
#

you're literally trying to copy us with windows 11

boreal iron
sudden geyser
#

playing catchup on your bad ui

plucky imp
#

now that is humor

boreal iron
#

lol nobody wants w11

plucky imp
#

*+1 ratio klay

boreal iron
#

NOBODY

sudden geyser
#

and that's why your userbase sucks

#

I can't stand windows ui

#

too blocky

lyric mountain
#

now it's too roundy

boreal iron
#

Oh no… no round corners OMG

sudden geyser
#

round is better

lyric mountain
#

I mean, not when EVERYTHING is round

boreal iron
#

Yes that makes anything better

lyric mountain
#

they literally made round round

boreal iron
#

Even adding a border radius to the border radius

lyric mountain
#

exactly

plucky imp
#

lmaoooo

boreal iron
#

We have to agree Klay is crazy

sudden geyser
#

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

boreal iron
#

Indeed

#

Oh no…

earnest phoenix
#

Windows 11 users when their PC blows up from too much random disk usage on start up

boreal iron
#

Yeee I can’t understand how people can use that shit, too

#

Must be too much alcohol

sudden geyser
#

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

boreal iron
#

Wtf

#

Which game takes up to that size

sudden geyser
#

it was a year or two ago

#

but I know it was a popular game

boreal iron
#

Must be the 37. extension for WoW

plucky imp
#

gta

boreal iron
plucky imp
#

5

earnest phoenix
#

Call of Duty: Modern Warfare takes 231 GB of storage

boreal iron
#

lol

sudden geyser
#

yeah call of duty

boreal iron
#

One game one ssd

#

Hopefully people have enough sata ports

sudden geyser
#

I can't even fit that on my machine

#

if it could even run

boreal iron
#

I mean Apple has Thunderbolt

#

To reason to use something slow like sata anyways

earnest phoenix
#

MFs made the game 3 times larger in install size than GTA V

plucky imp
#

LMAO

#

gta 6 gonna be 3.6 gb

boreal iron
#

A bookshelf full of DVDs

#

Please insert CDROM 231

earnest phoenix
#

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

earnest phoenix
#

That game would take me an entire year to download

plucky imp
#

@earnest phoenix you tell me

#

should i recode my bot to a cmd handler?

#

my index is like

earnest phoenix
#

Yeah, command handlers are nice and better to work with, splitting your work into multiple files instead of putting everything in a single file

plucky imp
#

that long

spark flint
plucky imp
#

yes

#

tokem cs token is defined as something else

pearl trail
#

my IDE wont be happy with that

sudden geyser
#

spell checking?

neat ingot
earnest phoenix
neat ingot
#

command/event handlers are also good for easily reloading things 🙂

plucky imp
#

how would i make my help command like how it is now tho qwq

#

like that

earnest phoenix
#

You can just iterate through the map (or map the collection) after you've set the commands to it

plucky imp
#

hmm ok

#

nah

#

discord.js-commando

#

probs

earnest phoenix
#

commando is deprecated and discontinued

sudden geyser
#

plus it won't work if you try to run it

earnest phoenix
#

But I really don't recommend using frameworks for Discord bots

plucky imp
#

lol

sudden geyser
#

I liked using klasa for some time

#

but that got oofed

plucky imp
#

probs gonna make my own cmd handler

#

or sumn

lyric mountain
austere surge
plucky imp
#

actually nah

#

i have experience with commando

split hazel
#

I recommend discord bot designer

plucky imp
#

already used it

austere surge
#

isnt that the $10 app on steam

plucky imp
#

for taco bell bot

split hazel
#

I also recommend bot designer for discord

plucky imp
#

botghost >>

austere surge
#

ew

spark flint
#

nah i know the elite one

#

scratch for discord

austere surge
#

yes

plucky imp
#

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

earnest phoenix
plucky imp
plucky imp
#

cs ian got money rn but i will soon

#

gotta buy clothes

#

and gas

#

yes mf i'm not doing that v13 bs

sudden geyser
#

so you're fine with it dying?

plucky imp
#

sorry excuse my profanity i just hate v12

sudden geyser
#

or is it a small bot / not verified

plucky imp
#

you can update the code to @earnest phoenix

plucky imp
#

:)

#

nope

#

it's just for fun

earnest phoenix
#

Time to do shit ton of refactoring troll

sudden geyser
#

this supposed to be public?

austere surge
#

hmm

plucky imp
#

u h

#

yes

#

it's not important lol

sudden geyser
#

ah okay

boreal iron
plucky imp
#

it isn't secret anyone can use it lol

#

everything that needs to be private is

pearl trail
#

isnt that youtube api key

plucky imp
#

like my genius api key ect

#

^^

boreal iron
#

what can go wrong

earnest phoenix
boreal iron
#

No risk no fun

plucky imp
#

if it was a youtube api key i'm sure i would've out it in my config.json

plucky imp
plucky imp
sudden geyser
quartz kindle
#

lmao

austere surge
plucky imp
austere surge
#

jesus

plucky imp
#

yes

#

cause i'm not coding every

#

single

#

function

pearl trail
#

copy paste?

plucky imp
#

uhhh

quartz kindle
#

jesus christ

plucky imp
#

from my other bots yes

#

most of it isn't though

earnest phoenix
plucky imp
#

only thing i coppied from someone else is like

sudden geyser
#

wait, you're using node fetch and snekfetch?

plucky imp
#

the eval command

#

cause what the actual fuck

austere surge
#

process error events better than try catch

plucky imp
#

LOOK
STOP ASKING QUESTIONS

quartz kindle
earnest phoenix
#

Oh man, rewriting this would probably take years

plucky imp
#

no

#

like 4-5 days

sudden geyser
#

I will ask more and torment you

#

You signed up for this IruSmile

plucky imp
#

lmao

#

i kinda did

#

but aye it runs smoothhhhhh

#

even with

austere surge
#

your eval command looks like a lower level version of mine hmm

sudden geyser
plucky imp
#

yes

#

economy

#

lol

boreal iron
earnest phoenix
#

That bot's node_modules directory must be larger than Call of Duty: Modern Warfare

plucky imp
#

yes

#

very

#

profound

earnest phoenix
#

Discord bot developers carefully typing the n-word in their blacklisted words

plucky imp
#

so i can use iT

boreal iron
#

Reminds me of that one picture about gravity

plucky imp
#

so volt how's the revamp going

earnest phoenix
plucky imp
#

btw if you actually do recode the whole thing with a cmd handler and discord.js v13 i'll be in your debt

boreal iron
pearl trail
earnest phoenix
plucky imp
#

^^ volt only anyone else can just enjoy spaget code

earnest phoenix
#

so much module

#

i am confused

boreal iron
#

I’m sure he has time to

plucky imp
#

god at this point i might aswell become his personal stripper

earnest phoenix
#

i was wondering about the db file and i saw this

plucky imp
#

@earnest phoenix please no slash cmds bt if you do id be pog

plucky imp
#

unlike the rest of my code

#

yes it's not hard to mmLol

earnest phoenix
plucky imp
#

uh

#

are slash commands good

earnest phoenix
#

I am reminded by Luca's source code

plucky imp
#

actually yes pls

tawny lava
austere surge
earnest phoenix
plucky imp
#

pretty soon all cmds are gonna need to be slash

#

so please

earnest phoenix
#

I might have to rewrite this thing to use something like MongoDB or PostgreSQL

boreal iron
#

:P

plucky imp
#

i don't think i have mongoDB

#

idk how it works either cs im just a pog champ

earnest phoenix
#

Btw, why are you creating 2 HTTP servers and listening to them in the main file?

boreal iron
#

Because redundancy?

#

Dumb Voltrex

earnest phoenix
#

FakE news

plucky imp
#

redundency totally

#

i also was gonna link it to a webserver but i forgot css so i left it there

earnest phoenix
#

Anyway, what do I get if I rewrite the whole thing mmm?mmLol

willow aspen
#

I like mysql. . . I just hate the company that owns it

boreal iron
#

And everyone hates Oracle

willow aspen
#

Postgres is good. Sql server is better

boreal iron
#

Haa take that

willow aspen
#

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

earnest phoenix
#

i am using localhost mongodb and is good now

austere surge
plucky imp
#

and nitro whenever i get the money for it

#

:)

boreal iron
willow aspen
#

Naw pretty shite

earnest phoenix
#

Because localhost Kek

earnest phoenix
plucky imp
#

yes

neat ingot
#

evenin' folks 😘

plucky imp
#

i no longer have thigh gap you can have feet pics kek

neat ingot
#

uhh... wth did i walk into... later folks 😗

plucky imp
boreal iron
#

Nothing special

earnest phoenix
boreal iron
#

Common development day

earnest phoenix
#

development to mental-development

boreal iron
#

There you go

#

Best example see above

plucky imp
#

lol

modest maple
boreal iron
#

Don’t you know?

modest maple
#

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

wheat mesa
earnest phoenix
#

Thats not me

wheat mesa
#

good

boreal iron
earnest phoenix
#

i am using localhost mongodb waiting

wheat mesa
#

stop blaming others for your car accident when texting and driving

boreal iron
willow aspen
#

At least the few I live in.

earnest phoenix
#

man I just live in my own

willow aspen
#

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

neat ingot
#

xfer? really? transfer was too long a word? 😛

willow aspen
#

I'm on phone. Fu

neat ingot
#

😂

#

took me too long to figure out what it was 😐

willow aspen
#

Not my fault ur dent head

neat ingot
#

😭

willow aspen
#

Jkjkjk luv u

neat ingot
#

i told you that in confidence! 😭

willow aspen
#

:kisses;

earnest phoenix
#
embed.setTitle("Command List");
    embed.setColor("#7289da");
    embed.addField("The prefix for all commands is `!`");
#

why is this happening?

spark flint
#

You haven’t set a field second line

earnest phoenix
#

oh its description

#

i got it

neat ingot
#

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)

earnest phoenix
neat ingot
#

dont think they are called title and body in the code, but thats what they do 😛

earnest phoenix
#
embed.fields[1].name: This field is required
embeds[0].fields[1].name: This field is required
pearl trail
#

make sure it is a string,
.addField("uwu", variable) wrong

.addField("uwu", `${variable}`)
``` correct
boreal iron
quartz kindle
#

it will increase the chances of showing [object Object]

#

:^)

boreal iron
#

I don’t like template strings for one var anyways without concating the var with another string

#

That’s why the toString() method exists

pearl trail
#

longer code

boreal iron
#

Aye that byte or two could blow up the RAM freerealestate

#

Also longer is better

#

Don’t you know that?

pearl trail
#

idk that

neat ingot
#

any emoji's other than those featured, that you guys keep note of to use in your bots? 🙂

boreal iron
#

Yes, no emoji is missing

neat ingot
#

hmm, thats fair. i dont have those from any server im in 😢

boreal iron
#

no emoji like in I don’t use a single one at all

earnest phoenix
#
        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

neat ingot
#

but what about error messages?!

boreal iron
#

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

neat ingot
#

hey, you leave shuckle out of this!

boreal iron
#

Only icons I like to use are the ones I can use in an embed title

neat ingot
#

you dont have any commands to like, paginate?

boreal iron
#

Using SVGs exclusively to have high res on mobile and desktop devices

neat ingot
#

you can also use emoji's in dropdown menu things

#

tbf, a lot of emoji look terrible on mobile

boreal iron
neat ingot
#

buttons can have emojis 😄

boreal iron
#

With WORDS

neat ingot
boreal iron
#

Like really chaining characters to each other building words

#

Ewwww

#

That color that resolution

#

It’s so ugly

neat ingot
#

lol

#

i dont have the time to be creating and uploading full custom emojis, so i gotta use whats available 😄

boreal iron
#

If those would be just white I could think of it being okay

neat ingot
#

yea tbh white would probably be better

#

could just use ascii arrow type characters 😛

boreal iron
#

But still the resolution sucks hard

#

Can’t compare that to a neat SVG icon

neat ingot
#

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

boreal iron
#

Looks at the sharpness

#

Impossible to reach with a stupid emoji

earnest phoenix
#
    @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?

neat ingot
#

😢

earnest phoenix
#

am i supposed to subclass the class bannedmember inside the commands.Cog

neat ingot
#

ooowww my eyes

#

such venomous code

earnest phoenix
pearl trail
boreal iron
#

No

#

Not that I know

neat ingot
#

so how do you use them as such?

boreal iron
#

That’s the reason I’m bitching about that low resolution emoji shit people are willing to pay money for KEKW

boreal iron
#

Just a few commands have a svg as icon in the title for reasons

outer niche
#
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

boreal iron
#

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

outer niche
#

To where it is being used after it's successfully logged in

boreal iron
#

Move your presence update to the ready event listener

outer niche
#

Lol that was a easy fix

boreal iron
outer niche
#

That should not have taken me an hour and a half to figure out

boreal iron
#

lol

outer niche
#

My other question is is that it's still not changing the presence

#

And I still think my commands are not syncing

boreal iron
#

Yeah well like I said I’m the wrong guy for snakish code pepowot

outer niche
#

You good

#

It's not even running that part of the code

simple stump
#

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);
}
quartz kindle
simple stump
quartz kindle
#

yes node-fetch can give you a stream

simple stump
#

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
  });
}
wheat mesa
#

there’s probably a good way to use ffmpeg to do that but there’s probably an even better way somehow

bright hornet
pearl trail
#

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
bright hornet
#

worked thanks!

rocky hearth
#

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
copper cradle
#

good job ccls, of course iostream and filesystem don't exist

stiff dust
#

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 👀

rocky hearth
#

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

cinder patio
#

else if not elseif

cinder patio
# rocky hearth Feud

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

rocky hearth
#

should work ig

modest maple
#

Which is, let's face it, not a hard choice to make

#

Unless you dont want to pay for the propriety license of mssql

rocky hearth
#

it does, remove first element from the tuple

cinder patio
#

removes the first parametr

rocky hearth
#

yes, now it works. thx

bright hornet
bright thorn
#

How can we check that a channel already following same news channel which one we want to follow again

atomic kindle
halcyon ridge
#

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"
pearl trail
#

nope, it's something like mass ban, etc...

atomic kindle
#

What is the command, @halcyon ridge? Also the 50 req/second is not a hard and fast limit for all endpoints.

spark flint
#

Its not that, its something like "unbanall" or some shit

pearl trail
#

unbanall, massban,

spark flint
#

yeah

halcyon ridge
#

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});
        })
pearl trail
#

is that the command that said is "abusing discord API"?

halcyon ridge
#

This code is in the file which abuse discord api

spark flint
#

I don't see how that abuses the API

halcyon ridge
#

I don't have other code that interact with discord api just this one and users.cache.get(user.id).variable= "content";

dry imp
halcyon ridge
#

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

dry imp
sage bobcat
#

One message removed from a suspended account.

earnest phoenix
neat ingot
#

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?

atomic kindle
neat ingot
#

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 😄

sudden geyser
#

There are no api docs for this

#

It's just "please don't spam us and wumpus will be happy this afternoon :D"

boreal iron
#

lol

neat ingot
#

lmao, best docs 😄

pearl trail
sudden geyser
#

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

pearl trail
#

All bots can make up to 50 requests per second to our API.

sudden geyser
#

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

pearl trail
#

ah

neat ingot
sudden geyser
#

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

neat ingot
#

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

sudden geyser
#

Definitely over 50

neat ingot
#

for sure lol

sudden geyser
#

They're probably exempt

neat ingot
#

I'd imagine there is something in place for if your bot is that large, they can increase your limits or w.e

earnest phoenix
#

You can contact Discord to get different rate limits for massive bots.

neat ingot
#

yea, i was just thinking you'd probably have to contact them to initiate it

earnest phoenix
#

So you shouldn't rely on how 'Mudae' or other big bots on how they edit messages or sends them.

neat ingot
#

hoo dat? (mudae?)

sudden geyser
#

Some anime bot

neat ingot
#

ahh ok lol

earnest phoenix
#

In 2'698'416 servers

#

So they have different rate limits.

sudden geyser
#

But their rate limits are roughly applied the same

neat ingot
#

well, my bots in 1 server. ShuckleCool

sudden geyser
#

They probably can't send 10 messages in a second in the same channel

#

But can make 500 requests a second easily

neat ingot
#

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

sudden geyser
#

Okay crazy idea but

#

What if we

#

Ban welcome bots IruSmile

neat ingot
#

but... then who will make me feel welcomed 😢

modest maple
sudden geyser
#

Discord!

modest maple
#

if it's more than like 1 every 2 secs just batch them up into sets of 5

neat ingot
earnest phoenix
#

Note that they mostly use webhooks, same for logging bots.

#

Webhooks which have a rate limit of 1'000 requests per 60 seconds.

spark flint
#

Now: [object Object]
Was: [object Object]

atomic kindle
#

made by eva™️

spark flint
#

nah

#

i wouldn't bother with logging bots personally

whole knot
#

Is there any documentation or examples on how CSS works on Top.gg?

hoary apex
#

How to setup reply in js ?

boreal iron
whole knot
#

Easy... 😭

#

Thanks!

hoary apex
boreal iron
#

One tip the user content should be in the element with the class .content

whole knot
#

I saw a picture of how CSS is structured but I am not sure if it is up-to-date

#

We'll see, thanks

boreal iron
#

Well just ask if you wanna know something

#

You gonna wrap your css code in style tags

hoary apex
boreal iron
whole knot
#

Would be cool if there is something to orientate 😅

boreal iron
#
<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

whole knot
#

That looks interesting 😄
I have some knowledge in HTML and CSS, some things look familiar to me

#

Thanks!

boreal iron
#

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...

whole knot
#

I just looked at the code and will try to understand the things done here, should not be too hard 😄

boreal iron
whole knot
#

By any chance: Are you the developer of a Steam bot?

#

Off-topic question though

boreal iron
#

Err yeah

whole knot
#

Ah, I remembered the pictures correctly hehe

#

Very good site! 👍🏽

boreal iron
#

nothing is offtopic in this channel KEKW

boreal iron
#

can't be my site lmao

#

or do you speak about the topgg site?!

whole knot
#

Yes

neat ingot
#

you made a steam bot? @boreal iron

boreal iron
#

I don't like things being too colorful or "overstructured"

whole knot
#

Can you pass me the link via DM?

boreal iron
#

errr need to get it myself, too

whole knot
#

Oh, got it

#

Was right in front of my eyes

boreal iron
#

You better DON'T WATCH the code

#

just throw it in without any structure xD

whole knot
#

Nope, just wanted to invite the bot xD

boreal iron
#

ah lol KEKW

#

the website is just a big trash junk

whole knot
#

Nah, I kind of like it

boreal iron
#

but since I'm close to publish a new one I'm not gonna update the old one

whole knot
#

Save some work hehe

boreal iron
#

well I hate frontend...

#

but compared to the old trash the new one will look like being from another world

#

espacially on mobile

whole knot
#

On mobile it is horrible...

boreal iron
#

I'm aware yeah... but at least it scales accurate instead of heaving no mobile version at all

neat ingot
#

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

cinder patio
#

that's the whole point of the message intent

neat ingot
#

i know this. but people in here said you still got the events, just not the message content

whole knot
boreal iron
whole knot
#

Looks clean

boreal iron
#

was about to say things are getting a lot cleaner

#

and ofc for all bitches out there crying about dark mode

whole knot
#

Will it just look in the preview like this? I am sure I said it should be in one row 😅

boreal iron
#

lmao

whole knot
#

Just a picture to test things

boreal iron
#

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

cinder patio
#

or use flex

boreal iron
#

shhhhhhhhhhhhh

cinder patio
#

which is definitely the better option

boreal iron
#

go away you css3 devil

whole knot
#

I will see what I can do, thanks 😄

boreal iron
#

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

rocky hearth
wheat mesa
#

no fuck css

#

Frontend sucks change my mind

rocky hearth
#

I'm good at it, though. (atleast people say that)

austere surge
rocky hearth
cinder patio
#

css is pretty lame

austere surge
#

very blue

#

but cool

#

oo theres the the

cinder patio
#

characters are a lot bigger than they are on the discord client

rocky hearth
#
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

cinder patio
#

What's the error without the @ts-gnore

rocky hearth
#

@cinder patio

Type 'A' does not satisfy the constraint 'Record<string, (...params: any[]) => void>'.ts(2344)
cinder patio
#

Why are u using overloads there in the first place? Not sure if that's the cause but

rocky hearth
#

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

cinder patio
#

No clue honestly. I've only seen this type of error in call sites, no clue why it would appear there

austere surge
rocky hearth
#

@cinder patio Oops, there's this Dispatcher type too. I update above now.

cinder patio
#

well that makes much more sense now

rocky hearth
#

The job of the Dispatcher is to remove all draft: IState, from ActionMap, event functions

cinder patio
#

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

rocky hearth
#

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

boreal iron
cinder patio
lyric mountain
#

oh wait, u mean the actual signature

cinder patio
#
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 ^

lyric mountain
#

holy that looks almost on-par with c++ readability

cinder patio
#

yeah it's not the prettiest

earnest phoenix
#

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

sudden geyser
#

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

earnest phoenix
#

totally agree

sudden geyser
#

And maybe some alignment like making sure they all share the same border (titles and cards specifically)

earnest phoenix
#

also I think the site needs more coloring

#

maybe even some cool CSS

feral aspen
#

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>
earnest phoenix
#

use <br> to break a line

#

I think that's what you mean

feral aspen
#

Well, unfortunately, it doesn't shift enter.

boreal iron
#

What do you mean by shift enter?

earnest phoenix
#

is that all your code?

#

if that doesn't work use <br> multiple times