#development

1 messages · Page 1821 of 1

modern patrol
#

wat this

#

anyone here

errant flax
#

presence intents gives u data about statuses of users and events
server members intents gives u guildMember data and events for eg. guildMemberAdd (im reffering to djs)

#

only choose the intents u need

candid cypress
#

how to embed my dashboard page on top.gg website?

errant flax
earnest phoenix
vagrant sedge
#

not seeing anything in the api reference about embed buttons, where could i find that? using dpy

proven lantern
#

why cant i do this?

#

i can use that feature everywhere else so i must be using it wrong here

worthy ivy
proven lantern
#

it's happy with this

errant flax
wheat mesa
#

Basically if the left hand side is null or undefined it’ll use the right hand side instead

near stratus
#

isn't that what || does

#

like

const b;
const a = b || "No"
wheat mesa
#

|| is different

#

If the left hand side evaluates to 0 or false it’ll use the right hand when using ||

#

Or NaN

near stratus
#

yes

wheat mesa
#

Null coalescing is just null or undefined

copper cradle
#

that's pretty much the only difference

near stratus
#

so false dosen't count here I see

copper cradle
#

|| checks for any falsy value, not only null and undefined

wheat mesa
#

^^

copper cradle
#

?? only checks for null and undefined

near stratus
#

I get it now

copper cradle
#

so it's kinda useful

wheat mesa
#

Yeah

#

Especially for false values

#
const myVar = false;

let result;

result = myVar || true; // result = true here

result = myVar ?? true; // result = false here
nova basin
#

Hello I would like to add a video on the page of my bot but when I add a video it is extremely large how can I make it decrease in size?

earnest phoenix
#

Use css to change the width and height

split cipher
#

Is there a way to check whether a server has enabled two factor moderation or not using djs?

pale vessel
knotty zodiac
#

can anyone help me?
I am making a website and with a body how do i make it so the font can change on the same line?

pale vessel
#

Use the style tag or attribute

knotty zodiac
#

how would i make it so one body is a different font to another?

#

im quite new to html

north jewel
#

can i ask a question about mongoose?

small tangle
#

just ask LULW

timber mountain
#

What should I search on YouTube to make this?

near stratus
knotty zodiac
#

is it possible to edit the style of this sort of thing: <a href="page.html"> Page</a>

hexed sedge
#

Anyone have some basic docs of how to use the new v13 discord.js menus?

#

Or do I just go in blind?

pale vessel
long crow
#

which menus?

pale vessel
#

Context menu

amber thistle
#
app.use(cookieParser())
app.use(cors())
app.use(express.urlencoded({ extended: true }));
app.use(express.json({
    type: ['application/json', 'text/plain']
}))

    app.post("/api/user/submit", async (req,res) => {
        ....
        res.cookie('user_id', "123456")
        res.json({ success: true })
    })

this does not set the cookie in my browser, im using localhost rn

my frontend:

                    fetch(' ... /api/user/submit', {
                        body : JSON.stringify({
                            user_id: response.id
                        }),
                        headers: {
                            'Content-Type': 'application/json'
                        },
                        method: 'POST'
                    })
long crow
#

If you talking about selectmenu

amber thistle
#

cookies are confusing the hell out of me

hexed sedge
#

Helped me a boat load

long crow
#

You just eat them waitWhat

amber thistle
#

does anyone know how to work with cookies

pale vessel
#

You need dough

#

Maybe try js res.cookie('user_id', "123456") .json({ success: true })

brave garnet
pale vessel
#

Not sure if it makes a difference

amber thistle
#

im trying to do it from the backend

brave garnet
#

eee

#

idk then

amber thistle
pale vessel
#

Oh nope it won't make a difference

#

Nm

amber thistle
pale vessel
#

Ah right

#

You can't set cookies in localhost

#

Test it on a proper server with a domain

timber mountain
pure lily
#

What is this error about?
(node:114481) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(Use node --trace-warnings ... to show where the warning was created)

long crow
#

11 message listener might be you making client.on('message',...) 11 times

#

Which is bad idea

hexed sedge
#

I do be learning

long crow
#

This is what you can do if all good

hexed sedge
#

Really fun

#

But I dont think users would really like a random package like that

long crow
#

discord-button doesn't support mster branch I think, and yeah. 3rd party is not good.

hexed sedge
hexed sedge
#

Will also have to switch the db thing, because I dont think keyv really likes node v16

long crow
#

keyv got vurnabilities, switched to enmap

#

I think enmap have much more features for discord bot than keyv

hexed sedge
#

Not really, all the average discord bot dev needs is add, remove, and fetch

#

Dont exactly see the need for more functions

#

But then again enmap was created with discord.js in mind

long crow
#

The math function make me easy to navigate back and forth result of images from duck duck go

split hazel
#

you realistically shouldn't even be using them as production databases

#

by using them you're completely ignoring the power of your database

#

(and optimisation)

hexed sedge
#

Well, Im young and dumb and just want to do it the easy way

opaque seal
#

Can anyone give me the steps that I need to follow to implement Discord login in a website.
Atm I can't understand when and where to do the code challenge

split hazel
opaque seal
#

I use kotlin for my backend btw

split hazel
#

the code challenge? do you mean it literally or do you mean the code discord sends you

opaque seal
split hazel
#

challenge would be the wrong word to use but I understand

opaque seal
#

Can you just explain me the flow I have to follow

#

Cause I'm not understanding how should redirect back users to the website in the backend

split hazel
#

can you access the code from your backend?

opaque seal
#

I mean yeah I should

#

Just what's the usual way to do it

split hazel
#

I never really dove into client side rendering much with states like this but you should be able to send the code to your backend via http, the backend then needs to make a request to the discord api (I'll get the relevant urls in a minute) to perform a token exchange (a token is what will let you grab the users info) from the code and then you make another request to grab the user details and send it back to the frontend

#

there's discord api libraries for java that let you query the discord api

#

or you can do it yourself

opaque seal
#

issue is, how do I send it back to the frontend?

#

I need to request it from the frontend

#

But the timing for that is not clear

split hazel
#

I assume you're new to web development?

knotty zodiac
#
    <a href="index.html">HOME</a>
    <a href="edits.html">MY EDITS</a>
</div>``` How can i make this so it will put a gap between each one
opaque seal
#

but never done oauth before

split hazel
opaque seal
#

I know how to fetch data from APIs via axios

#

the issue is the timing

#

like, how much I have to wait before asking my backend for use data

#

I don't think that it should just be a timeout

split hazel
#

why do you need to wait

#

the data is immediately available via the discord api

opaque seal
#

And I need to get that access token from the frontend

#

then with that I can make requests to the discord api in the frontend

feral aspen
#

Hello. 👋

brave garnet
#

hi

feral aspen
#
const array = [1, 2, 3, 4, 5, 6, 7, 8, 9];
#

I have this array.. and I use the map method to map it to log every value.

#
console.log(array.map(x => x));
#

.. now I want to make 2 console logs whereas the first one shows the first 5 and the second one shows the rest.. is that possible? .. and if there is no rest.. it would return.

brave garnet
#

split it by 5

feral aspen
#

Kind-of a paging system.

feral aspen
#

I heard .slice() works?

brave garnet
#

idk, im not a person from JS ||and currently im busy cause of writing mine bot||

feral aspen
#

Bruh.

brave garnet
#

ye...

quartz kindle
#

use promises instead

opaque seal
feral aspen
#
const mappedData = Object.keys(inventory.inventory)
    .filter(key => inventory.inventory[key] !== 0)
    .map((key) => {
        const { name, id, logo } = items.find((val) => val.id.toLowerCase() === key);
        return `${logo} **${name}** ─ ${inventory.inventory[key]}\n**ID:** \`${id}\``;
    })
    .join("\n\n")

embed.addField("Owned Items", mappedData);

.. now this will keep doing on and on and on.. is there some way to make it show 5 every page/embed?

lyric mountain
#

chunkify it

feral aspen
#

What do you mean?

lyric mountain
#

instead of [1, 2, 3, 4, 5, 6, 7, 8, 9]

#

have [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

quaint wasp
lyric mountain
#

I can show you how I do in java, but you'll need to convert that to js

quaint wasp
#

never mind I mispleed html.

feral aspen
lyric mountain
#

oh it will

#

once you have chunks you can do exactly what you want

quartz kindle
lyric mountain
#

well...

#

maybe tim can help converting that

opaque seal
lyric mountain
#

basically, you split the whole into smaller parts

quartz kindle
lyric mountain
#

if the total count is not a multiple of the chunk size, gather the remaining into their own array

quartz kindle
#

if the user was redirected in a separate window, then the separate window has to close itself and return the token to the main window

opaque seal
#

and from the website I make an api call to the backend with the code

lyric mountain
#

after you have the chunks, just do .map(c => c.join("\n\n"))

quartz kindle
#

where does the user login with discord? in which window?

opaque seal
quartz kindle
#

because the login with discord is already not your frontend

opaque seal
opaque seal
quartz kindle
#

the moment the login with discord window appears, the user is not on your website anymore

opaque seal
#

yeah

quartz kindle
#

he was redirected to the discord webside

#

then redirected back to the discord redirect url

pale vessel
quartz kindle
#

so you have to redirect the user back to your main website, with a token in the url for example, or in the cookies

#

then on the front end use js to extract the token

opaque seal
#

So what does the user see when I redirect them to the backend?

#

I'm so confused

quartz kindle
#

the user sees a double redirect

opaque seal
#

so:

  • redirect user to discord auth
  • discord auth redirects user to backend (blank page?)
  • backend uses the code to get the token and redirects the user to frontend with the code in url / cookie, but how?
lyric mountain
quartz kindle
#

the user doesnt see a blank page

lyric mountain
#

oauth2 in a nutshell

quartz kindle
#

the user sees the browser loading, and the address bar changing twice

opaque seal
lyric mountain
#

partly, yes

opaque seal
#

that's not what Tim is saying do right?

lyric mountain
#

it is

#

the backend will talk twice with the discord api

opaque seal
quartz kindle
#

ye

opaque seal
#

so it's basically just a get request?

quartz kindle
#

yes

opaque seal
#

So here I should put my backend endpoint

#

which will do everything and then redirect the user

quartz kindle
#

discord does the redirect to your backend, which means your backend received a get request from the user after they are redirected

lyric mountain
#

you dont need 2 urls btw

opaque seal
#

I was just testing there ye

#

And where is it advised to store the token in the frontend?

quartz kindle
#

depends how long you want it to be valid

opaque seal
#

I mean for security

quartz kindle
#

discord stores it in localstorage

opaque seal
#

How should I handle the expiration instead?

brave garnet
#

did this conversation ended alr?

#

uh

#

·•·

knotty zodiac
brave garnet
#

uh, idk

knotty zodiac
#

its weird tho

#

never had it before

brave garnet
#

ye

knotty zodiac
#

but the weirdest bit is the fact that it doesnt happen every time

brave garnet
knotty zodiac
#

and i know enough about javascript to know there is nothing wrong with this

brave garnet
#

yea, just a BUG

#

maybe ur browser broken? which one u use?

knotty zodiac
#

chrome

#

ill try brave

brave garnet
#

i use firefox and never got this...

knotty zodiac
#

not the brwser

brave garnet
#

idk

knotty zodiac
#

this is really strange

brave garnet
#

check inspector and check if sometimes u didnt putted there some invisible "ascii art"

knotty zodiac
#

nothing shows in inspector tho until i press OK

brave garnet
#

check characters, maybe ur keyboard is modded and there is ascii art between characters

knotty zodiac
#

its not

#

im on a standard uk keyboard

#

but then it would show every time aswell, but it doesnt

brave garnet
#

no, i was saying about characters invisible, because u might idk. got hacked or smth and it puts invisible characters into text

knotty zodiac
#

but i tested it just adding the text into there without it being a const and its fine

brave garnet
#

then idk

knotty zodiac
#

but its because later i will make it a variable and sort out a form so i can change it on the website

brave garnet
#

huh.. irdk

#

#

was something over?

#

⠀⠀⠀⠀⠀⠀

knotty zodiac
#

i have no idea what is going on lol

#

this is so confisong

brave garnet
#

empty charcters

knotty zodiac
#
<script>
    const MontagePrice = '£5.00';
    const IdentPrice = '£3.00';
    alert(`A Fortnite Montage costs ${MontagePrice} and a Custom Ident costs ${IdentPrice}.`);   
</script>``` nothing wrong here
brave garnet
#

this⠀message⠀is⠀without⠀real⠀spaces

knotty zodiac
#

im so confused on what has happened 😐

lyric mountain
knotty zodiac
brave garnet
lyric mountain
#

weird characters are normally a result of wrong charset

#

<meta charset="UTF-8">

#

add this to head

knotty zodiac
#

but it works when i change const to let

lyric mountain
#

see if it works

knotty zodiac
#
<script>
    let MontagePrice = '£5.00';
    let IdentPrice = '£3.00';
    alert(`A Fortnite Montage costs ${MontagePrice} and a Custom Ident costs ${IdentPrice}.`);   
</script>``` it works like this
#

thats just weird

brave garnet
#

like this:

#

⠀⠀⠀

lyric mountain
#

just try it, you should have the charset set to utf8 anyway

knotty zodiac
brave garnet
#

is it the same?

<script>
    letMontagePrice = '£5.00';
    letIdentPrice = '£3.00';
    alert(`A Fortnite Montage costs⠀${MontagePrice} and a Custom Ident costs⠀${IdentPrice}.`);   
</script>
lyric mountain
#

maybe £ is charset-dependent

#

you should use utf8 anyway since it's basically the new default

brave garnet
#

or use unicode hash

knotty zodiac
#

it is working now

lyric mountain
#

they just didn't switch fully to it because retrocompatibility

brisk blade
lyric mountain
#

"Unmetered SSD storage"

#

no, too sketchy

brave garnet
#

bug i have on the myself - why this something throws "ctx undefined?!"

@bot.command()
async def chmod(ctx, arg1, member: discord.Member):
  if arg1 == 0:
    await ctx.channel.set_permissions(member, view_channel=False)
  elif arg1 == 1:
    await ctx.channel.set_permissions(member, add_reactions=True, view_channel=True, send_messages=False, read_message_history=False)
  elif arg1 == 2: 
    await ctx.channel.set_permissions(member, send_messages=True, view_channel=True, add_reactions=False, read_message_history=False)
  elif arg1 == 3:
    await ctx.channel.set_permissions(member, send_messages=True, add_reactions=True, view_channel=True, read_message_history=False)
  elif arg1 == 4:
    await ctx.channel.set_permissions(member, read_message_history=True, view_channel=True, send_messages=False, add_reactions=False)
  elif arg1 == 5:
    await ctx.channel.set_permissions(member, read_message_history=True, add_reactions=True, view_channel=True, send_messages=False)
  elif arg1 == 6:
    await ctx.channel.set_permissions(member, read_message_history=True, send_messages=True, view_channel=True, add_reactions=False)
  elif arg1 == 7:
    await ctx.channel.set_permissions(member, read_message_history=True, send_messages=True, add_reactions=True, view_channel=True, attach_files=True)
  elif arg1 == "mod":
    await ctx.guild.set_permissions(member, administrator=True)
  else:
    return
#

•~•

brave garnet
#

ctx undefined after sending "$chmod 4 (user)"

lyric mountain
#

godzilla dead after this

brave garnet
#

full error:

  File "main.py", line 23, in on_message
    await ctx.process_message(message)
NameError: name 'ctx' is not defined
#

•-•

near stratus
brave garnet
#

here is 11 line

#

i just copied err from terminal, so 23, here its 11

#

and there is (ctx, args) in async...

#

~_~

crystal wigeon
#

anyone used quickdb?

#

where does it store data? on disk? or in memory?

lyric mountain
#

probably on disk

#

if it was in memory it'd be useless as a database

lament rock
#

redis stores in memory hippo

lyric mountain
#

redis is mostly a cache if anything

earnest phoenix
#

how is every developer here doing?

#

depressed as usual?

lyric mountain
#

no, why would we?

brave garnet
#

nope, just thinking on smth

earnest phoenix
#

noice

brave garnet
#

but im not depressed 😉

crystal wigeon
#

so like can i use quickdb with grafana?

earnest phoenix
crystal wigeon
#

for grafana i only see promtheus or loki

brave garnet
#

thk

earnest phoenix
#

so

#

what dev you all like

#

?

lyric mountain
brave garnet
lyric mountain
#

oh it does

crystal wigeon
#

not sure

lyric mountain
earnest phoenix
#

bots, websites games

lyric mountain
#

find where the sqlite file is generated

crystal wigeon
#

i want something like reading directly from a file on the machine

#

wait quickdb uses sqlite?

brave garnet
#

and u?

lyric mountain
#

quickdb is a sqlite wrapper

earnest phoenix
lyric mountain
#

it's not a db in itself

earnest phoenix
#

but the api does support variety of languages. I made mine from js

brave garnet
#

mine → .py (js scares me)

earnest phoenix
#

lol

brave garnet
#

xd

earnest phoenix
brave garnet
#

yea, and generally - weird

earnest phoenix
#

but i am certified game dev in js so easy for me

woeful pike
#

js is like the easiest language ever created lol

brave garnet
#

i also was but i was cheatin (gdevelop, scratch, etc...)

earnest phoenix
#

what else you like to develope?

earnest phoenix
#

like

#

yk that dino game where you jump around?

brave garnet
lyric mountain
brave garnet
#

ik

earnest phoenix
earnest phoenix
#

nothing else

#

i recreated it from scratch my self

brave garnet
#

ik

#

but scratch as this app, not from plain file

earnest phoenix
#

hmmmmmmmmmmmmmmmmmmmm

brave garnet
earnest phoenix
#

i like to dev websited a lot

brave garnet
#

(and in the reality im not even a dev - everything i know is only css, html and from about 2 months python :'D)

lyric mountain
#

you're a dev then

earnest phoenix
#

ye

brave garnet
#

i dont think so 😂

earnest phoenix
#

knowing any kind of language makes you a dev

brave garnet
#

?!

earnest phoenix
#

yes

lyric mountain
#

you code -> you're a dev

brave garnet
#

😳

earnest phoenix
#

you literally know 3 language

lyric mountain
#

you don't need certification nor official entitlements

earnest phoenix
#

you coded something right?

brave garnet
#

html isnt lang

earnest phoenix
#

yes

#

BRUH

#

IT IS

lyric mountain
brave garnet
#

bro

earnest phoenix
#

Google basically pays a lot

lyric mountain
#

but webdevving counts

earnest phoenix
#

just for web desing and stuff

brave garnet
#

yea

earnest phoenix
#

yea

quartz kindle
#

html is considered declarative programming

brave garnet
#

eee ?!

quartz kindle
#

so technically it is a programming language

brave garnet
#

TECHINCALLY but noone accept that as lang 😉

lyric mountain
#

more like a structuring language

brave garnet
#

yea xml i also know. sometimes i also make ios shortcuts if about

lyric mountain
#

this is a tree, tree has branches, branches have leaves

brave garnet
#

yea

lyric mountain
#

then js comes: tree does X, branch does Y, leaves do Z

#

css says: tree is brown, branch is thin, leaves are green

brave garnet
#

e-e i dont understand this $#1t yet (means - js)

#

im more a graphic than a dev 😉

#

and how i understood .py - idk yet 😂

quartz kindle
#

if you wanna get even more techincal

#

html is a "deterministic finite automation"

brave garnet
#

?

quartz kindle
#

its simpler than a turing machine, it cannot represent itself like a turing machine can

brave garnet
#

?

quartz kindle
#

therefore it is finite

brave garnet
#

i dont understand yet 😂

#

_<

quartz kindle
#

it means it can be used to program only a subset of things

brave garnet
#

ye

quartz kindle
#

it cannot program inifinite things like a turing machine can

brave garnet
#

?

#

im doomb

quartz kindle
#

a turing machine is the first computer ever made

brave garnet
#

eee

#

?

lyric mountain
#

wasnt it eniac?

quartz kindle
#

a "turing complete" language or system is something that can do anything, including recreate itself inside it

brave garnet
#

idk also 😂

candid cypress
#

how to embed my dashboard in my top.gg bot website?

#

is it possible?

lyric mountain
#

use iframe

brave garnet
#

yea ↑

split hazel
#

quirky never saw someone add their dashboard to their bot page

candid cypress
lyric mountain
#

the idea is great, the execution not so much

the result? even less

lyric mountain
brave garnet
#

fast question (i dont want to stay weeks in docs again :'D) - how to get role from ping in argument? google shows me only how to ping roles via bot. what if i want to have role ping as argument? i know that user ping is discord.member ...

quartz kindle
#

in which library?

brave garnet
#

there is something like discord.role ?

earnest phoenix
#

You can annotate the arg with discord.Role if you use its command handler.

brave garnet
#

means?

quartz kindle
#

message.role_mentions

brave garnet
#

i make smth like (ctx, arg1, user = discord.role) , yes ?

earnest phoenix
#

Not = but :, and it's capital R.

brave garnet
#

nvm but a good way?

earnest phoenix
#

Wdym?

brave garnet
#

that i just make a cmd for managing perms and doesnt work on users so i started messing up with roles =p

#

anyways - thk

#

testing now 😉

#

ey, and is this possible for bots also, not only real users?

#

cause seem broken

lyric mountain
#

not ignoring bots is usually a bad thing

brave garnet
#

means? i just need to test on something

pure lily
#

https://sourceb.in/vZX59L7ldj why is this ready.js making this error:
(node:117758) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(Use node --trace-warnings ... to show where the warning was created)

lyric mountain
brave garnet
#

no, this wouldnt be spammy cause this only manages roles =p

#

i just brang chmod to discord and made something like $chmod 0 @someone and this block user for example

#

or $chmod 7 @someone to give him ability to share files

earnest phoenix
#

Well that's still an API request

brave garnet
#

ahh

#

so using developer site will solve bug?

lyric mountain
#

developer site to solve bug?

brave garnet
#

there are some toggles to which over 100 servers require verify so maybe there is smth like that

earnest phoenix
#

Privileged intents? Don't think you'd need that to edit permissions.

brave garnet
#

like getting user list

lyric mountain
#

user list does require

brave garnet
#

verify, yes

lyric mountain
#

but mentions automatically cache the user

brave garnet
#

but when in many serers

#

edit - i dont have similar toggle for using other bots...

lyric mountain
#

I think I lost the context, what was the error?

brave garnet
#

there wasnt error

#

just permissions not updating

#

terminal empty

earnest phoenix
#

Seems a code problem

brave garnet
#

and code not working this (before i was thinking that ctx is broken but it was for another thingy) :

@bot.command()
async def chmod(ctx, arg1, member: discord.Role):
  if arg1 == 0:
    await ctx.channel.set_permissions(member, view_channel=False)
  elif arg1 == 1:
    await ctx.channel.set_permissions(member, add_reactions=True, view_channel=True, send_messages=False, read_message_history=False)
  elif arg1 == 2: 
    await ctx.channel.set_permissions(member, send_messages=True, view_channel=True, add_reactions=False, read_message_history=False)
  elif arg1 == 3:
    await ctx.channel.set_permissions(member, send_messages=True, add_reactions=True, view_channel=True, read_message_history=False)
  elif arg1 == 4:
    await ctx.channel.set_permissions(member, read_message_history=True, view_channel=True, send_messages=False, add_reactions=False)
  elif arg1 == 5:
    await ctx.channel.set_permissions(member, read_message_history=True, add_reactions=True, view_channel=True, send_messages=False)
  elif arg1 == 6:
    await ctx.channel.set_permissions(member, read_message_history=True, send_messages=True, view_channel=True, add_reactions=False)
  elif arg1 == 7:
    await ctx.channel.set_permissions(member, read_message_history=True, send_messages=True, add_reactions=True, view_channel=True, attach_files=True)
  elif arg1 == "mod":
    await ctx.guild.set_permissions(member, administrator=True)
  else:
    return
lyric mountain
#

ye, intent-related errors would thrown something to the console

brave garnet
#

-_-

#

ik

earnest phoenix
#

See, arg1 will always be str, it's never gonna be int.

brave garnet
#

means? i need to make "1" everywhere? ok

earnest phoenix
#

So, it's most likely been getting to the else block

brave garnet
#

but "mod" is string.... and also doesnt work

lyric mountain
#

you sure arg1 is "mod" and not " mod" or "mod "?

#

or "MOD"?

brave garnet
#

means?

#

i dont use caps

lyric mountain
#

leading/trailing spaces

brave garnet
#

and spaces ok

lyric mountain
#

and for the love of god use switch-case

earnest phoenix
#

Don't think Guild object has set_permissions method

brave garnet
#

means? there is no "moderator" perms for only one channel 😂

earnest phoenix
#

You need to edit the role instead

brave garnet
#

:/ ok

earnest phoenix
#

Try something like: await <Role>.edit(permissions=discord.Permissions(...)). I can't test it as I don't use d.py anymore

crystal wigeon
#

jeez quickdb is fkin ambigious

brave garnet
#

ok, thk

crystal wigeon
#

they dont even have proper instruction

#

plus there's an error on the first 2 lines of the package

#

lol

lyric mountain
#

instructions as in documentation?

crystal wigeon
#
const db = quickdb('./json.sqlite');```
#

it says quickdb is not a function

#

xd

#

yeah

#

documentation

#

there's no resource to how to delete table

#

get all contents

#

delete all contents

#

bruh moment

brave garnet
earnest phoenix
#

Doesn't matter, <Role> there was just a placeholder for a Role object

brave garnet
#

ah, ok

crystal wigeon
#

its just an example lo

lyric mountain
#

variable = require... doesnt exist

crystal wigeon
#

i used let obv

lyric mountain
#

I don't see that quickdb(something) anywhere in the docs

crystal wigeon
#

yeah wait i think it was an outdated one

lyric mountain
crystal wigeon
#

yeah i saw that

#

there's no delete all method

#

or delete table

lyric mountain
#

delete all would be truncate

#

doesn't quickdb allow raw sql commands?

split hazel
#

i dont think so brother

crystal wigeon
#

thats on a table

split hazel
#

actually

#

you can probably access the sql client

crystal wigeon
#

yeah i saw an example somewhere

#

too much pain

earnest phoenix
#

day 1 of scraping data
have i done a good job?

crystal wigeon
#

this was one with the quickdb()

lyric mountain
#

@rustic nova

rustic nova
#

lol

#

bitly

crystal wigeon
#

lol

split hazel
#

actually i dont know because quick.db doesn't seem to expose the database object

crystal wigeon
#

i dont see any raw query on the docs as well

#

yeah

#

there's no way i can change the filename also

#

im stuck with 1 file being filled with everything

split hazel
#

you'd probably have to fork it, edit it and install your own version

#

i think i did that before when i wanted a quick database

crystal wigeon
#

i'd rather just spend that time on loki lol

split hazel
#

nah it's like a 1 line fix

crystal wigeon
#

quick.db was actually easy and simple but these problems oof

#

no i need like multiple files

split hazel
#

but if you're going to be using raw sql you might as well just use better-sqlite3 or something like that

crystal wigeon
#

to store data

split hazel
#

ah

crystal wigeon
#

yeah

#

i tried kibana, mindfucked tho

split hazel
#

why though aren't multiple tables enough

crystal wigeon
#

yeah like im mainly using it for logs

lyric mountain
#

there's no reason to use more than 1 database file

earnest phoenix
#

hi

crystal wigeon
#

yeah, but im using it for 2 purposes

lyric mountain
#

if you want to keep a history just backup it

#

or export as csv or something

crystal wigeon
#

logs and storing sort cache which would be long term which i dont wanna store in redis

split hazel
#

xy problem at its finest

crystal wigeon
#

yep

brave garnet
#

uh

brave garnet
crystal wigeon
#

i gotta sac mem for sorting or store the sorting data in db

#

which i dont wanna make multiple calls to db to get the sort details

#

so thought quick.db would be easier

split hazel
#

alright so lets start over

#

what do you want to do exactly

crystal wigeon
#

store logs is prio

#

but i also prefer fragment files

#

since i can sort them according to log levels

#

i need these logs to check transaction history

#

so

#

also prefer to rotate them every 7days

#

or so

split hazel
#

so you want different sql files to store different levels of logs

crystal wigeon
#

yeah

#

i thought of using mongodb

#

but grafana has mongodb for premium

#

pain

split hazel
#

allows you to use sqlite and abstracts sql completely behind objects

crystal wigeon
#

for postgres?

split hazel
#

to its full potential

#

it supports that too

#

fuck

#

how did i copy trhat

crystal wigeon
#

i joined their server

#

dw

#

they also dont know what they doing lol

#

i asked around

split hazel
#

quickdb?

crystal wigeon
#

ah that ye i checked the docs

#

yeah

#

quickdb

split hazel
#

well you cant expect much from a module like quick.db

lethal trout
split hazel
#

it practically takes away the power of sql

crystal wigeon
#

wait so i have to build out the sql connection

#

?

#

and create a sqldb

#

to use seq and sqlite

split hazel
#

i think you're a little confused

crystal wigeon
#

i've used sequelize before with postgres

#

not sure if i need a db connection with sqlite

quartz kindle
#

sqlite works with self-contained files, so it doesnt need a database server running independently

crystal wigeon
#

so no config needed, i can just directly use seq + sqlite

quartz kindle
#

yes

split hazel
#

this is why sqlite3 is popular hehe

crystal wigeon
#

noice, let me give it a try

brave garnet
#

channel mooted - db spam again

quartz kindle
#

chanel

split hazel
#

nice

#

though i like sequelize i also dont like it

crystal wigeon
#

moot

split hazel
#

they could optimize their queries a little bit more

quartz kindle
#

or just do the queries yourself

brave garnet
#

chanel renamed 😉

split hazel
#

yeah but when your whole infra is already in sequelize it's difficult

crystal wigeon
#

seq package is huge for my use

split hazel
#

i mean i can overwrite the methods myself but it's the kind of bodging i dont like

#

the outcome is suffer either way

crystal wigeon
#

anyway, how do i write raw query in qdb?

quartz kindle
#

in quick.db? you dont

split hazel
#

you cant they dont expose the sqlite client

brave garnet
#

bye from this channel

split hazel
#

you'd have to fork it

crystal wigeon
#

they said you could lol

#

ah

#

wondering if someone else has already done that

quartz kindle
#

i mean

crystal wigeon
#

i can jsut switch branches

split hazel
#

quite stupid of them but what do you expect

quartz kindle
#

you can just use any sql lib and open the same file that quick.db creates

#

and use them side by side

#

one for raw queries, the other for the rest

brave garnet
#

ugh

split hazel
#

two sql files open at once 🤮

crystal wigeon
#

mm, ig i can use that file in sql client and clean it up

split hazel
#

those database locked errors looking tasty

crystal wigeon
#

😂

split hazel
#

(unlikely for your use case)

quartz kindle
#

only if your queries are terribly slow

#

better-sqlite3 queues writes for 5 seconds

crystal wigeon
#

well all i'd use is delete table query anyway

quartz kindle
#

you'll only get db locked error if your queries take longer than that

crystal wigeon
#

wait i hope i can filter stuff with qdb? with a where clause or something

split hazel
#

i love how the query for deleting tables is "drop table"

crystal wigeon
#

😂

#

yeah 1 line, qdb couldn't implement 🤦‍♂️

split hazel
#

and no you cant

#

you'd have to fetch all rows and filter them

crystal wigeon
#

yow

split hazel
#

which is terrible

crystal wigeon
#

bruh

split hazel
#

you can always fork:)

#

but please use something else

crystal wigeon
#

but i guess i can just use the sqlite file

split hazel
#

your use case is clearly not fit for quickdb

quartz kindle
brave garnet
#

lmfao 😂

split hazel
#

gonna drop my 10 million row table

earnest phoenix
#

lol

split hazel
#

and will wait for myself to be dropped

brave garnet
#

wat?

crystal wigeon
#

imagine getting isekaid

brave garnet
#

u wanna be deleted?

crystal wigeon
#

he getting isekai-d

#

with the table

brave garnet
#

?

crystal wigeon
#

weebs

brave garnet
#

who?

crystal wigeon
#

lol

brave garnet
#

?

crystal wigeon
#

lmao im out

brave garnet
#

why?

brave garnet
#

•~•

earnest phoenix
#

Well, seeing you didn't get any error while accessing a non-existent attribute before, you error handler is likely messed up

brave garnet
#

idk but now logged in modlog 😉 so smth better

#

asap offtopic a little question - how to split words in a file by a NEWLINE ? it does by spaces defaultly... (again python)

wicked topaz
#

How to create webhook requirer in heroku?

brave garnet
#

=[

split hazel
#

why asap

brave garnet
#

oh, thk

split hazel
#

python has so many utility methods at your disposal

brave garnet
#

ik

shut veldt
brave garnet
#

•~•

shut veldt
#

Hulo

brave garnet
#

?

shut veldt
#

What do you guys do here

brave garnet
#

bruh....

rose warren
#

We copy bots off YouTube videos

brave garnet
#

yea 😉

shut veldt
#

I see..

brave garnet
#

me||e6|| too

crystal wigeon
#

lol

brave garnet
#

xd, u noticed?

crystal wigeon
#

welp if that helps you learn then why not

brave garnet
#

i dont watch yt but if he does...

crystal wigeon
#

welp, i learnt coding watching YT

#

not exactly discord bot specific

brave garnet
#

i never really learnt coding. i just copy from docs and ask questions

#

-_-

#

and smh it works sometimes

wheat mesa
#

I learned from doing small projects and looking things up as I went.

brave garnet
#

i started from big and never finished them

#

now made a one smaller (u know what)

wheat mesa
#

Starting big and complicated projects will get you burned out as a beginner

brave garnet
#

for me smh didnt, i yet sit on .py 😂

wheat mesa
#

Often times complicated projects require complicated solutions, that may make you feel overwhelmed at first

#

That's why (in my opinion) it's better to start small and work your way up

brave garnet
#

so i left hard things and now im doing a little smaller

crystal wigeon
#

so umm

brave garnet
#

?

crystal wigeon
#

idk why grafana throws permissions error while im trying access the sqlite file

#

with the abs path

brave garnet
#

bruh

#

how much one question?

shut veldt
#

I can do coding..a little

brave garnet
#

means me or hoax?

crystal wigeon
#

what

wheat mesa
#

Can you show the error and the code you're using to access the file?

crystal wigeon
#

its the grafana UI

brave garnet
#

$kill 266457718942990337

crystal wigeon
#

where i have to specify the absolute path

wheat mesa
#

Never used grafana

crystal wigeon
#

this the error i get

brave garnet
#

$kill 173489654144696320

crystal wigeon
#

:faceplm:

wheat mesa
#

it looks like you have a space after stat

#

is that intentional?

brave garnet
#

$kill 266457718942990337

wheat mesa
#

What are you doing @brave garnet

crystal wigeon
#

no lol that's a grafana prefix for status

brave garnet
#

trying to kik u both

crystal wigeon
#

idlerpg

brave garnet
#

nope

#

just a cmd from mine bot. i just thought its here

crystal wigeon
#

wew

wheat mesa
brave garnet
#

?

wheat mesa
#

Bot commands

brave garnet
#

ok

wheat mesa
#

(except for the top.gg bots I think)

brave garnet
#

"i think"

wheat mesa
brave garnet
#

ik

#

it was just to stop next spam conversation again... its 5 time today with same question....

wheat mesa
#

Spam conversation?

brave garnet
#

yea...

#

i have pings from this channel every 2 secs

wheat mesa
#

Then mute it?

#

We were having a genuine conversation related to development I believe

brave garnet
#

not possible cause i use this channel sometimes

wheat mesa
#

I don't see why that's a bad thing

#

I just have the entire server muted

brave garnet
#

i never moote, only generals i have mooted cause there is yet bigger overload

tulip ledge
#

Is google down?

wheat mesa
#

sounds like a bad idea ¯_(ツ)_/¯

brave garnet
#

nope

tulip ledge
#

weird

earnest phoenix
brave garnet
#

yea...

tulip ledge
brave garnet
#

COOKIES

#

restart browser, then say

tulip ledge
#

Also can anyone help me with this?, inventory is a map of type: <Map<material, number>> new Map(this.itemIdToItemObject(data.materials || {}, materialIds))

tulip ledge
brave garnet
#

idk

#

restart pc

#

and clear browser history and cache

tulip ledge
crystal wigeon
#

man i need help

#

@quartz kindle

tulip ledge
#

KEKW we don't ping Tim here

brave garnet
#

did u checked firefox?

tulip ledge
#

Tim helps if he wants

tulip ledge
crystal wigeon
#

true

brave garnet
#

-_-

tulip ledge
crystal wigeon
#

im getting a permission denied while using grafan with sqlite

#

like it says it cant read the sqlite file

#

in the abs path

#

idk if i should use the ip or something there?

tulip ledge
#

is the sqlite database on your local machine?

crystal wigeon
#

yeah

#

on the same server grafana is on

tulip ledge
#

local machine or server?

crystal wigeon
#

server

tulip ledge
#

wellp, I can't rlly help much with this tbh

crystal wigeon
#

welp

earnest phoenix
#

amazing

crystal wigeon
#

we pray, tim shows up

earnest phoenix
tulip ledge
#

sure

tulip ledge
earnest phoenix
tulip ledge
#
  public addItemsToInventory(items: {itemid: material | consumable, amount: number}[], profile: profile, fit: "materials" | "consumables") {
    for (const item of items) {
      let inventory = profile.inventory[fit];
      let currentValue = inventory.has(item.itemid) ? inventory.get(item.itemid) : 0;
      profile.inventory[fit].set(item.itemid, currentValue + item.amount);
    }
  }
earnest phoenix
#

Did you define your map as :Map<never, any>?

earnest phoenix
tulip ledge
#

Now spotify is down too 😦

brave garnet
tulip ledge
#

how is it unreachable tho?

brave garnet
#

idk

tulip ledge
#

prob due to the heavy storms we had today

brave garnet
#

maybe 😉

earnest phoenix
#

Can you send a screenshot of the entire code?

tulip ledge
#

The entire code? It's just a class that doesn't interact with the map in any way tho

#

So u won't have use of it

earnest phoenix
#

The code is what's causing the error soo

#

It probably does that because it thinks the inventory variable either doesn't have a value or something more obscure, I'm not sure

tulip ledge
#

Maybe because the inventory is empty?

#

The map is of size 0

#
  public materials: Map<material, number>;
  public consumables: Map<consumable, number>;
  public moves: string[];
  public arsenal: Item[];
  public tools: Item[];

  constructor(data: any) {
    if (!data) data = {};

    this.materials = <Map<material, number>> new Map(this.itemIdToItemObject(data.materials || {}, materialIds));
    this.consumables = <Map<consumable, number>> new Map(this.itemIdToItemObject(data.consumables || {}, consumableIds));

    this.moves = data.moves || [];
    this.arsenal = (data.arsenal || []).map(item => new Item(item));
    this.tools = (data.tools || []).map(item => new Item(item));

  }

This is the inventory constructor

earnest phoenix
#

Can you try logging inventory variable?

earnest phoenix
#

owo what

#

square bracket notation on a map

brave garnet
#

uwu

earnest phoenix
#

Wait a second, <Map<material, number>>

#

What is the extra generic notation around that supposed to be

tulip ledge
#

It's the type of key and value

earnest phoenix
#

huh¿

tulip ledge
#

It's to cast it

#

It works

#
    profile.inventory.materials.set("stone", 5)
    profile.inventory.materials.has("stone")
#

this works

#

in a different file

earnest phoenix
#

man i need to check my eyes

brave garnet
#

?

#

👀

earnest phoenix
#

i accidentally read item as items

tulip ledge
#

Map(1) { 'stone' => 5 }

#

This is what it logged

#

the inventory

#

So it shouldn't set it as never right?

earnest phoenix
#

Right click the inventory and press peek definition

#

You probs set the wrong type for smth

#

Oh I think I know why that error happens

tulip ledge
#

Theres no peek

earnest phoenix
#

well just normal definition then

tulip ledge
#

and profile is an argument of the function of type profile

earnest phoenix
#

Your inventory variable doesn't have a type, falling back to never

#

That's probably the issue

tulip ledge
#

oh

earnest phoenix
#

Set the type to Map<material | consumable, any>

tulip ledge
#

Ok

#

We're getting there

#

Now I got this

#

ACtually

#

I can just use inventory

#

I'm retarded

#

perfect 😄

#

thank you!

#

I'm quite new to TS

earnest phoenix
#

:+1:

#

Np vigi

earnest phoenix
tulip ledge
#

agreed haha

#

I do like ts more then js tho

mild agate
tulip ledge
#

It's better but it's brainfuck

mild agate
#

nah

earnest phoenix
#

i only need the intellisense not the static types

mild agate
#

It helps my brain more to understand the node

earnest phoenix
#

If we add optional static typings to JS itself which was proposed in a TC39 proposal, rip TS

#

blame Tim for telling me to use an html parser

#

...(... >) moment

#

is there a way to copy the nested property

wheat mesa
#

We need more abstraction!

earnest phoenix
#

?

wheat mesa
#

All the nested elements lol

earnest phoenix
valid frigate
#

has anyone ever used one of these distance formulas in string similarity comparison?

  • hamming
  • levenschtein
  • jaro-wrinkler
  • smith-waterman
  • sorensen-dice
  • jaccard index
  • overlap coefficient

and if you have, does it perform well? reason im asking is because i have a few choices and wanted an opinion on why one performs well

earnest phoenix
earnest phoenix
valid frigate
#

oh

#

it's not like that

earnest phoenix
#

kek

valid frigate
#

In information theory, linguistics, and computer science, the Levenshtein distance is a string metric for measuring the difference between two sequences. Informally, the Levenshtein distance between two words is the minimum number of single-character edits (insertions, deletions or substitutions) required to change one word into the other. It is...

#

i had my eye on this one

tulip ledge
#

Oh I love levenshtein

#

Its such a good algorithm

#

it makes me nut every time I use it

earnest phoenix
valid frigate
#

you use it often?

#

what do you like about it

tulip ledge
#

Idk it just provides more usability for my users imo

valid frigate
#

vs. hamming distance the levenshtein distance is not restricted to transposition only

tulip ledge
#

I mainly use it to "auto correct" item names

earnest phoenix
valid frigate
#

it's not used for correction

tulip ledge
#

Well I use it

#

for auto correction

#

B)

valid frigate
#

how so? it's used for comparison between two strings, not the correction of one based on another

earnest phoenix
tulip ledge
#

Hold on lemme get the code

#
  mostSimilarModule(item, keys, factor = 0.4) {
    const resp = keys.sort((key1, key2) => {
      return levenshtein.levenshteinRatio(key2, item) - levenshtein.levenshteinRatio(key1, item);
    })[0];
    if (levenshtein.levenshteinRatio(resp.toLowerCase(), item) < factor) return false
    return resp
  }
#

there u go

valid frigate
#

you mean autocomplete

tulip ledge
#

ye

valid frigate
#

then that makes sense

#

yeah

tulip ledge
#

its rlly nice for users

valid frigate
#

my purpose is to match strings against each other to check if it exceeds a certain score

tulip ledge
#

I've had alot of positive feedback about it

#

oh

#

that could work too

#

It has alot of use cases I can imagine

valid frigate
#

this is for moderation purposes so im looking for strictly the best distance string metric

tulip ledge
#

Ah, well I use it for my textbased rpg game

valid frigate
#

what do you think about the complexity of levenshtein

earnest phoenix
valid frigate
#

regexp cannot compare 2 strings

earnest phoenix
#

Levenshtein seems way too good and might bonk innocent people

valid frigate
#

that's why im asking for if anyone has used anything else

earnest phoenix
valid frigate
#

that's not my intention

tulip ledge
#

then what is your intention?

valid frigate
#

it's to match a user's previous message against the one they just sent

tulip ledge
#

oh

valid frigate
#

think of it as anti spam

#

yeah

tulip ledge
#

yeah then using levenshtein is the better option imo

earnest phoenix
tulip ledge
#

kekw

mild agate
#

what about phuq?

#

and fuq

valid frigate
#

your downfall is that it only matches one swear word, and it looks very inefficient

#

now if you wanted to match a user's custom list of words to block how would you do that

#

ok well ill look into levenshtein

tulip ledge
#

Levenshtein is really nice

mild agate
#

also bruh who removes the swears with *

crystal wigeon
#

i need help

#

;-;

valid frigate
#

i have a few slices of test messages like this

crystal wigeon
#

;_;

earnest phoenix
#

some people do

tulip ledge
#

You want the algorithm I have?

#
exports.levenshteinRatio = (target, source) => {
    if (source == null || target == null) return 0.0
    if (source.length == 0 || target.length == 0) return 0.0
    if (source === target) return 1.0

    let sourceWordCount = source.length
    let targetWordCount = target.length

    let distance = new Array(sourceWordCount + 1)
    for (let i = 0; i < distance.length; i++) {
        distance[i] = new Array(targetWordCount + 1)
    }

    for (let i = 0; i <= sourceWordCount; distance[i][0] = i++);
    for (let j = 0; j <= targetWordCount; distance[0][j] = j++);

    for (let i = 1; i <= sourceWordCount; i++) {
        for (let j = 1; j <= targetWordCount; j++) {
            let cost = ((target.charAt(j - 1) === source.charAt(i - 1)) ? 0 : 1)

            distance[i][j] = Math.min(Math.min(distance[i - 1][j] + 1, distance[i][j - 1] + 1), distance[i - 1][j - 1] + cost)
        }
    }

    return 1.0 - distance[sourceWordCount][targetWordCount] / Math.max(source.length, target.length)
}
valid frigate
#
t1 := []string{"join my server - abcde", "join my serv3r - 123ab"}
earnest phoenix
valid frigate
#

some bots attach a random string onto the end of their message

tulip ledge
mild agate
#

I have a neat collection

valid frigate
#

or just don't use regex

earnest phoenix
valid frigate
mild agate
#

yeah... write all words in a list

mild agate
tulip ledge
#

I mean levenshtein would be better imo as you can increase/decrease the threshhold and allow for custom inputs which is way better for customisation by the discord server's admins

valid frigate
#

yeah

#

i plan to allow flexibility on the threshold required

#

my concern is obviously with false alarms

earnest phoenix
#

some mod bots are too much for me

tulip ledge
#

Then just lower the threshhold

#

🤷‍♂️

#

Thats why u use levenshtein

earnest phoenix
#

tf you tell me i can't send the letter f or a DISCORD link in #memes?

valid frigate
#

see

#

then i look at hamming

#

apparently it's used in error detection

tulip ledge
#

In information theory, the Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different.

earnest phoenix
#

Vysion, you should really look into the Damerau-Levenstein algorithm

tulip ledge
#

isn,'t that like a coding interview question

valid frigate
#

what differences does it make

tulip ledge
#

how many characters do you have to change in string x to get string y

#

The Damerau-Levenshtein distance measures the "difference" between two strings. A Levenshtein automaton recognises strings that are of a certain Levenshtein distance ("difference") from a particular reference string.

valid frigate
#

ah i got it

tulip ledge
#

Also hamminh is worse imo

#

as it doesn't consider deletions and insertions

crystal wigeon
#

man where the bois when you need em

tulip ledge
#

aka fuck -> fuk won't "work"

earnest phoenix
valid frigate
#

you can substitute adjacent symbols

#

i THINK

tulip ledge
#

I think levenshtein is the best option

valid frigate
#

although what benefit does that provide over levenshtein

#

yeah ill probably go with that

#

looks like overall it will work fine

earnest phoenix
#

i think human mods are the best option

valid frigate
#

thanks for your help everyone

crystal wigeon
#

bots will take over

#

soon

tulip ledge
earnest phoenix
#

yes

crystal wigeon
#

fam why you exposing my guy code913

tulip ledge
#

Kinda sounds like bot developers too actually thinkLul

crystal wigeon
#

beluga

earnest phoenix
#

boot developer === cobbler

mild agate
#

yes

earnest phoenix
#

cobbler cobbler mend my bot

crystal wigeon
#

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#

helppppppppppppppppppppppppppppppppppppppppppppppppp

earnest phoenix
#

wat

terse finch
#

quick question. for discord.js is there any validators to check if an ID passed into a command is a valid user or in the current server? cause like "1234" is too short. but "868289752074436658" isnt in the server (its my bot im currently working on) is there anyway to validate these

crystal wigeon
#

permission denied

#

mindfkin me

#

for the past 4 hours

earnest phoenix
earnest phoenix