#development

1 messages · Page 1582 of 1

cinder patio
#

You can use any key-value data structure to store cooldowns

crimson vapor
#

maps are generally easier to understand when you first start out

#

as you don't have to write everything yourself

frosty valve
#

where can I find the docs for map caching?

lament rock
#

There are micro optimizations you can make to make raw Object K,V access times faster than Maps.

wind kayak
#

Any JS Collection tutorial Instellate

cinder patio
#

Collections are a discord.js feature

wind kayak
#

What the fuck?

lament rock
#

Other libs may provide their own Map extensions

wind kayak
#

This was a sarcastic question

#

Now I'm getting worried

earnest phoenix
wind kayak
frosty valve
earnest phoenix
wind kayak
#

Performs better in scenarios involving frequent additions and removals of key-value pairs

#

Which cooldowns are, definitely

earnest phoenix
wind kayak
#

Objects: Not optimized for frequent additions and removals of key-value pairs

#

=> Collection (Map) better for cooldowns

#

And no, Collections are not a discord.js specific feature

pale vessel
#

It is

#

why is it not

#

Ah, not specific yes

#

Other libs have their own collections too

#

they all extend map

wind kayak
#

Triggers me everytime when people think Nodejs bot = discord.js

quartz kindle
#

usually the way to do it is to create a symlink, that way if one is updated, the other is automatically updated as well, since its linked to the same file

#

google how to create symlinks in linux

cinder patio
#

100k iterations

wind kayak
#

How are we obviously talking about discord.js?

#

Just because that is the only discord JS wrapper you know doesn't mean everyone is automatically talking about discord.js

wind kayak
delicate shore
#

It actually worked

#

Thanks

#

Tim

wind kayak
#

Making a test meant for objects and using it for a map is obviously going to perform worse

slender wagon
#

how do i learn typescript

opal plank
slender wagon
#

aight thanks 😄

#

yeah i do know js i just wanna move on TS everyone says it is better

opal plank
#

smart call

#

you should tell that to tim

wind kayak
#

Gotta go back to work, talking to a brickwall anyway

quartz kindle
#

collections are not js

cinder patio
#

How is the test meant for using objects... both have the same general use-cases. The only pro with maps is that it also keeps track of the size and also the order. In the case for cooldowns, the order and the size of the map is not important

quartz kindle
#

Maps are js

cinder patio
#

I'm not sure if this guy is trolling or just full of himself

opal plank
#

speaking of collector, i had to make my own collectors for reactions and messages

#

fun™️

wind kayak
quartz kindle
#

again

wind kayak
#

👋

quartz kindle
#

Collection !== Map

wind kayak
#

Yes we are not noobs

#

Collection extends Map

#

Still doesn't mean that collections are a discord.js specific feature

#

And still fact that maps perform better for frequent changes

cinder patio
# wind kayak

And that's what the test showed.... 100K insert operations, objects 4ms, maps 10ms

wind kayak
pale vessel
#

Only insert?

wind kayak
#

This

#

Really I lost all interest in this conversation

quartz kindle
#

yes Collection extends Map, but that doesnt mean you can call Maps Collections, unless you specifically use Collections from discord.js or install them as a separate module. furthermore, Collections implement many features from Arrays that Maps dont have, if you use those features, you are not getting Map performance

wind kayak
#

It's like throwing rocks at a tank

opal plank
wind kayak
#

Collection !== discord.js

#

Again

pale vessel
#

Other libs also implement collections, Eris for instance

opal plank
#

and Collection !== Map

wind kayak
#

Basically all

quartz kindle
#

yes, its not discord.js but it is something you have to install separately

#

Collection is not built in

#

Map is

wind kayak
#

Nobody ever said collections are maps

eternal osprey
#

hey, could anyone tell me how i would fix my code so that the program.namelmao changes every 1 second (cuz now it sends the same string every time).```
private static Random random = new Random((int)DateTime.Now.Ticks);
private string RandomString(int size)
{
StringBuilder builder = new StringBuilder();
char ch;
for (int i = 0; i < size; i++)
{
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
builder.Append(ch);
}

    return builder.ToString();
}

// get 1st random string
string Rand1 = RandomString(4);

// get 2nd random string
string Rand2 = RandomString(4);

// creat full rand string
string docNum = Rand1 + "-" + Rand2;
Program.namelmao = docNum
}```'c# btw

wind kayak
#

We are literally just telling this guy that maps perform better for cooldowns

quartz kindle
#

you told him to use Collections

#

not Maps

wind kayak
#

Because every lib has collections and we are talking about discord bot cooldowns

quartz kindle
#

not every lib has collections lmao

cinder patio
#

Tested performance of deletion (delete obj[x] vs obj.delete(x)) And they are the same

opal plank
cinder patio
quartz kindle
#

well he was going on and on about not being collections not being about discord.js, implying they exist in non-discord libraries

wind kayak
#

No?

cinder patio
#

Yeah he said "Google JS Collections tutorial"

wind kayak
#

I said collections are not d.js specific

opal plank
#

this is wrong btw

#

Detritus does not extend maps

eternal osprey
#

anyone here knowing c#?\

wind kayak
#

With a JS lib

#

And all js libs I know of have collections

opal plank
quartz kindle
#

again, that implies "JS LIBS"

opal plank
quartz kindle
#

aka, non-discord libs

wind kayak
#

Wow im so incredibly sick of this conversation

cinder patio
#

Googling "JS Collections tutorial" does not yield any tutorials which explain how discord.js Collections work

quartz kindle
#

you started it lmao

opal plank
#

you started it

wind kayak
#

Sorry for expecting people to use their brains

#

Obviously a mistake

opal plank
#

feud

#

its the latter

cinder patio
#

wdym

opal plank
pale vessel
cinder patio
#

ah yes

pale vessel
#

well now when people say "collections" i won't think of maps anymore then

cinder patio
#

Mongo.db Collections are also a thing

opal plank
#

how about we all think of Pokemon collectible cards when people say collection? thats a neutral stance mmulu

cinder patio
#

I can literally call any data structure a Collection of something

dusky sundial
#

1 month later, still no reply on my intents application 1105_prez_cry

slender wagon
#

i am waiting on it too

opal plank
#

it shouldnt have taken that long

slender wagon
#

well now it does take more than a month

#

discord is full of request they have said

#

just check on your tickets

dusky sundial
opal plank
#

if you didnt receive an email regarding it, ask in that server

dusky sundial
#

I'll try that, thank you

quick ridge
quartz kindle
cinder patio
tired panther
#

Does someone know why I can not connect my Yt account with my discord?

pale vessel
#

why not

crystal wigeon
#

hey umm

#

im trying out oauth

#

and i keep getting invalid grant

#

error

#

const code = req.query.code;
console.log({ code })
const payload = {
client_id: process.env.DISCORD_CLIENT_ID,
client_secret: process.env.DISCORD_CLIENT_SECRET,
grant_type: "authorization_code",
code,
scope: ["email", "guilds", "identity"],
redirect_uri: "http://localhost:5010/discord"
}
const accessToken = await axios.post("https://discord.com/api/oauth2/token", payload, {
headers: {
"content-type": "application/x-www-form-urlencoded"
}
});

#

in nodejs..

#

the syntax on the doc is python, i dont think there's much change to it tho

#

i tried with camel case as well

#

clientId

#

same error

#

maybe i should remove the form urlencoded?

pale vessel
#

http://localhost:5010/discord?

crystal wigeon
#

jsut a redirect uri

#

after the auth

pale vessel
#

It needs to be a valid URL and you must have it set in developer portal

crystal wigeon
#

yeah

#

i've set it there

#

the error is invalid grant

pale vessel
#

localhost?

crystal wigeon
#

yep

pale vessel
#

ic

crystal wigeon
tulip ledge
#

Alright this is quite a complicated issue to explain.
I have this bot wich I made a "custom" db handler for wich basically translates db.get() to an sql query and returns the value this allows me to ensure data so I have less data saved. Now I'm accessing the database from a different bot as I need to get some data from there, I am able to access the sqlite file but when I query a SELECT * FROM MoneyMoves the data returned is [] even though there is alot of data in there anyone knows why?

crystal wigeon
#

they show localhost even in their docs and tuts

#

i tried removing the header no luck

cinder patio
#

Does axios automatically encode the object you send to query params

#

Because it needs to be in the form of a string, not JSON

crystal wigeon
#

yep

#

see the method, data etc

cinder patio
#

So it doesn't...

crystal wigeon
#

huh

cinder patio
#

it needs to be like this client_id=...&client_secret=...

#

and so on

crystal wigeon
#

for post request the data will obviously go in the body xd

#

req.body

#

that ?client_id= is a get request

#

okay, lemme change the url

cinder patio
#

the body needs to be in the "x-www-form-urlencoded" format, that's why you provide "content-type": "application/x-www-form-urlencoded"

#

you are still sending the body, but you aren't sending json

crystal wigeon
#

so my url would /oauth2/token?client_id=

#

?

cinder patio
#

no, you pass the query params to the body

pale vessel
#

why is axios so confusing

crystal wigeon
#

im confused

pale vessel
#

this is why i use node-fetch

cinder patio
#
body: `client_id=${yourId}&...`
pale vessel
#

set the url, the method, the header, the body

#

easy

cinder patio
#

node-fetch is life

pale vessel
#

preach

opal plank
#

blasphemy, axios is life!

crystal wigeon
#

figured it out

#

axios is good tho

#

xd

crimson vapor
#

node-fetch > *

#

Erwin is committing Heresy

#

sedition, if you will

modest maple
#

@tender basin You're trying to index a int btw

earnest phoenix
#

Why don't lazy fetch doe

copper cradle
#

how can axios be confusing??

tender basin
sage crescent
#

hi, guys, anyone know how get user language? Python

cinder patio
#

Not possible

#

You have to ask em

copper cradle
#

that's impossible unless you ask them and then save it

sage crescent
#

mm

#

how?

earnest phoenix
#

actually

#

not impossible

#

you can get the locale through oauth

copper cradle
#

let's be honest here

shrewd sparrow
#

Asking them is the best way

#

Btw I got a way to reduce the load on bot reviewers

#

Just use a spam filter for the bot description

pale vessel
#

they most likely won't know how to use auth

blissful coral
#

@shrewd sparrow no

#

Because it can falsely check

#

And it takes us about 10 seconds to detect spam ourselves

shrewd sparrow
#

Ok thx

earnest phoenix
#

i got a way to reduce the load on bot reviewers

#

ban turkish bots

shrewd sparrow
#

Erm.

#

Anyways

#

10 seconds is time wasted

#

And when you multiply that by a ton of bots

#

It’s not cash money

#

And you can’t falsely check the ‘aaaaaaaaaaaaaa’s and ‘eeeeeeeeeeeeeee’s can it

#

The word length is also a factor

#

Just make the spam check more loose

earnest phoenix
#

even if it gets filtered out

#

and the end user resubmits

#

it does not mean that the description isn't going to be garbage and unhelpful

frozen rock
#

Selam Türkler birlikte bir bot kodlamak isteyen varsa seve seve işbirliği yaparım bot örneklerimi görmek isterseniz DM. :)

earnest phoenix
#

english only in this channel

frozen rock
#

is dis a rule?

earnest phoenix
#

yes

frozen rock
#

show me pls

glossy spoke
pale vessel
cinder patio
#

lIkE tHiS?

frozen rock
#

i said

#

anyone want to make a bot with me ?

quaint wasp
earnest phoenix
#

none

#

rent a vps

copper cradle
#

fuck the image won't load for me

#

none

agile lance
quaint wasp
#

Yeah

#

I did

#

it says tehy are reviweing the order

#

but for now I need to host it somehow...

copper cradle
#

well then just select the first one

#

why do u need a streaming platform

#

wait

glossy spoke
#

reviweing

earnest phoenix
#

there's no such thing as reviewing an order unless you bought and actual physical server and you're waiting for it to ship lol

#

it's a simple charge

copper cradle
#

I guess it's being setup, but still that doesn't take that much time

#

unless...

quaint wasp
earnest phoenix
#

i'm guessing it's on google

glossy spoke
#

I think you'll get scammed

copper cradle
#

It's probably a scam

#

what's the name of the provider

quaint wasp
#

look

copper cradle
#

ss

quaint wasp
#

its this

earnest phoenix
#

it doesn't

#

because the bot description needs to get reviewed anyways to see if it provides useful information or not

#

automatic spam filter does nothing for bot reviewers

#

only annoys the end user

copper cradle
#

well vultur is a well known provider but I've never heard of them doing that kinds of checking

glossy spoke
#

There are some people that puts their bot's code inside the description lmao

earnest phoenix
#

i yet have to see that

#

wow that's sad

copper cradle
#

we'll never see that

#

unless we turn into mods or bot reviewers

#

I kinda want to be a bit reviewer just to see what un declined turkish bots look like

glossy spoke
#

Just check out #mod-logs and you probably will see a denied bot for that reason

earnest phoenix
#

it's amusing how most of low quality bots are turkish

#

dbots outright started banning turkish bots from their service for this reason lol

shrewd sparrow
copper cradle
#

The actual question here is: why are there so many turkish bots

earnest phoenix
shrewd sparrow
#

yes

copper cradle
#

I don't see a problem with turkish people, but most of them don't even try with their bots

#

if at least they tried things would be so much better

earnest phoenix
#

the end user is just going to resubmit the bot with a description that isn't picked up by the spam filter

copper cradle
#

they could also take an online course and improve their english

shrewd sparrow
copper cradle
#

cuz let's be honest, not even mine is that bad

earnest phoenix
#

are you stupid

#

it's a genuine question

shrewd sparrow
#

some is good enough

#

ofc not all

dire obsidian
#

is there a way to make this shorter? (apart from using getElementsByClassName or id or by tag name)

copper cradle
#

I get what you say, but if it was actually a good idea, don't you think they would've done that already?

shrewd sparrow
#

who knows

earnest phoenix
cinder patio
#

I'm using esprima with typescript and when I import it it's just undefined. Really weird. I see the typings just fine, but:

import Esprima from "esprima";
console.log(Esprima)

logs undefined.

copper cradle
shrewd sparrow
dire obsidian
#

ye, that doesnt work with addEventListener

#

only adds the listener to the last element

copper cradle
cinder patio
#

It's called esprima I misspelled it in my message

#

lol

copper cradle
#

I've donde that countless times before

#

You probably do it wrong then

dire obsidian
#

probably

#

anyways thanks

copper cradle
cinder patio
#

I tried importing other npm modules and they worked fine

earnest phoenix
#
//pseudo
elements = []
for(i = 0; i < 10; i++)
  elements.push(getById(`button-${i}`))

this will store all of your elements @dire obsidian

#

if your only goal is to add event listeners

#

you can avoid the array altogether and just call addEventListener in the for loop

#

a cleaner way to do this is to apply a class on your buttons named something like, i don't know, btn

dire obsidian
#

k

lament rock
#

@cinder patio have you tried using the require statement instead of import?

cinder patio
#

I created a new project without typescript and it works just fine

lament rock
cinder patio
#
{
    "compilerOptions": {
      "target": "es6",                         
      "module": "commonjs",                
      "declaration": true,                   
      "outDir": "./dist",                    
      "rootDir": "./src",                      
      "removeComments": true,                
      "downlevelIteration": true,            
      "strict": true,                         
      "noImplicitAny": true,                 
      "alwaysStrict": true,                  
      "moduleResolution": "Node",
      "esModuleInterop": true,                  
      "skipLibCheck": true,                     
      "forceConsistentCasingInFileNames": true  
    },
    "exclude": [
      "./test/",
      "./dist/"
    ]
  }

My tsconfig.json

lament rock
#

oh okay. So it does compile to commonjs

cinder patio
#

I fixed it

#

I had to import it like this import * as Esprima from "esprima"; cause it has no default exports

copper cradle
#

just use deno and run ts natively

lament rock
#

I still think you should try to use require since import/export default was the worst thing to happen for esm/ts

copper cradle
#

without transpilling it

quartz kindle
#

deno is a meme

copper cradle
#

lol

cinder patio
#

deno also transpiles it, it just saves the js files somewhere where you won't see them

copper cradle
#

oh really?

earnest phoenix
#

a guys

lament rock
#

Yeah. There is no runtime interpreter for TypeScript afaik since TS is built off JS

earnest phoenix
slender thistle
#

Seems like someone hasn't verified their bot

earnest phoenix
#

?

#

any expaination

lament rock
pale vessel
#

sounds like it's for pagination

#

i made something similar

lament rock
#

1024 seems a bit arbitrary though

earnest phoenix
#

yeah

#

i can't fit exactly on 1024.

pale vessel
#

he probably wants an array of string, each element with <=1024 characters to fit in one field

lament rock
#

aren't embed field max characters 2000

pale vessel
#

description and footer only

earnest phoenix
#

field 1024

lament rock
#

mmm. I see

spiral harness
pale vessel
#

@indigo folio wtf

lament rock
#

the bot owner needs to verify the bot

pale vessel
#

i thought that was you

spiral harness
#

oh xd

earnest phoenix
#

@pale vessel can you give advice

pale vessel
#

use reduce ig

west hatch
cinder patio
#

discord.js also has a utility method for splitting strings into chunks

pale vessel
#

does this even work for arrays

#

ah there's char

#

you can join the emojis by space for example and set char to " "

astral forge
#

Okay so

#

im making a simple ban command but the permissions wont work for some reason.

pale vessel
#

@earnest phoenix this works ig

astral forge
#

Lol

earnest phoenix
cinder patio
#

show your code

summer torrent
astral forge
#

GoogleFued mine?

pale vessel
pale vessel
astral forge
#

@client.command() async def ban(ctx, member : discord.Member, *, reason=None): if not ctx.author.permissions_in(ctx.channel).ban_members: await ctx.send("uh-oh! Looks like you're missing permission to use that command!") return await member.ban(reason=reason) await ctx.send(f"{member} Has Been **Banned**! For {reason}") print("Someone Just Dropped The Ban Hammer!")

So I made this simple ban command, but it still allows anyone to ban people.

pale vessel
#

uh oh, python!

astral forge
#

Yea

pale vessel
#

gotta call norizon or shiv mmmlul

astral forge
#

I'm bad at it too, thats why i have an error. :)

cinder patio
#

okay I don't know anything about discord.py, but this ctx.author.permissions_in(ctx.channel).ban_members doesn't make much sense because "Ban Members" is not a permission which depends on channels

astral forge
#

i also tried

#

@client.command() @commands.has_permissions(ban_members = True) async def ban(ctx, member : discord.Member, *, reason=None): await member.ban(reason=reason) await ctx.send(f"{member} Has Been **Banned**! For {reason}") print("Someone Just Dropped The Ban Hammer!")

cinder patio
#

interesting

pale vessel
cinder patio
#

ah

astral forge
#

so?

cinder patio
#

wait for someone who has more py knowledge

astral forge
#

Mk

outer perch
#
(node:7644) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Access

Nice, the mute command now throws this error

#

and I haven't touched it

mellow kelp
#

yeah cuz your bot doesn't have permissions

#

you could make a permissions check first

outer perch
#

that's when it sends Missing Permissions

#

not when Missing Access

#

cuz the bot has permissions 100%

mellow kelp
#

o

#

maybe the bot has a lower role than the user you're trying to ban

astral forge
#

me?

outer perch
#

*mute

gilded olive
outer perch
#

yeah maybe

gilded olive
#

do you know what a decorator is?

astral forge
#

lmao im new to python

gilded olive
#

Like @client.command()

astral forge
#

i do

#

yes

gilded olive
outer perch
astral forge
#

but there is one for @commands.has_permissions ??

gilded olive
#

Well then add what I said to it

#

Yes

#

As long as you import it

#

from discord.ext import commands

astral forge
#

i have that

#

yes

gilded olive
#

Or from discord.ext.commands import has_permissions

#

Whatever you want

astral forge
#

i have 'from discord.ext import commands'

astral forge
#

i have that.

gilded olive
#

Uh huh

astral forge
#

this is the code?

#

@client.command() @commands.has_permissions(ban_members = True) async def ban(ctx, member : discord.Member, *, reason=None): await member.ban(reason=reason) await ctx.send(f"{member} Has Been **Banned**! For {reason}") print("Someone Just Dropped The Ban Hammer!")

#

and it doesnt work

#

:/

gilded olive
#

wdym

astral forge
#

members can still ban higher ups.

outer perch
gilded olive
#

members have ban perms?

astral forge
#

no

mellow kelp
gilded olive
#

you mean mods banning admins?

astral forge
#

nope

#

members can ban admins

gilded olive
#

They have that perm then

astral forge
#

like a member who just join can run the command and ban someone

#

i just checked

#

they dont

gilded olive
#

Did you restart the bot?

#

That should work just fine

astral forge
#

oh wait it works

gilded olive
#

Knew it

astral forge
#

i was thinking it should output a message

#

but that was my old code

gilded olive
astral forge
#

so how do i make it output a message with this new code

gilded olive
#

Output what message

outer perch
gilded olive
#

Oh you want an EH

astral forge
#

i just write under it? await ctx.send("Uh-Oh! You are missing permissions to use that command!)

#

and the quote at the end

mellow kelp
gilded olive
#
@ban.error
async def ban_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
           handle_error()
    else:
           raise error```
#

mobile so indentation is fucked

astral forge
#

lol

outer perch
astral forge
#

it doesnt know what raise error is hold on

#

lmao

gilded olive
astral forge
#

wait a minute

gilded olive
#

If you copied it straight youd get an indentation error

#

Which is a red sqiggly line

#

you can just unindent and reindent

astral forge
#

LOL

#

ok

#

i paste it under the @command.has_permission right?

gilded olive
#

whatthefuck no

#

Under the ban command

astral forge
#

oh

quaint wasp
#

umm... Im using heroku first time.... And idk how to add my files to it so it could host it..

#

Where do I type that?

gilded olive
#
@client.command()
async def ban():
   ban()

@ban.error
async def ban_error():
    handle_shit()```
quaint wasp
#

in file terminal?

astral forge
gilded olive
#

else goes inline with the if

astral forge
#

oh

#

lmao

cinder patio
gilded olive
#

handle_error() is a placeholder function so make your own or move it

quaint wasp
astral forge
cinder patio
#

If your bot's source code is in a github repo, yes

astral forge
#

did i do it right? lmao

#

probably not

quaint wasp
gilded olive
#

Oh my

#

Thats even worse than before

astral forge
#

LMAO

#

where do i put it

gilded olive
#
if x:
    Please_learn_python()
else:
    Please_learn_python()```
astral forge
#

-_-

gilded olive
#

do you see how it works

crimson vapor
#

great program

#

but I keep getting Syntax Error

gilded olive
astral forge
#

-_-

#

pls just tell me

gilded olive
#

I just did

#

I showed you how it should look

crimson vapor
#

Uncaught SyntaxError: Unexpected identifier

astral forge
#

i did put it with the if command

slender thistle
#

in if statement for an else to work Python needs an if clause

#

What you did is nest an else INTO an if

gilded olive
#

Thus us a learn python moment but ill spoonfeed

slender thistle
#

which is not what's supposed to be done

crimson vapor
quartz kindle
#

lmao

pale vessel
#

good one

gilded olive
#
@ban.error
async def ban_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
           handle_error()
   else:
           raise error ```
slender thistle
#

poor indents

gilded olive
#

Fuck me the indentation looks so weird

#

Mobile whatthefuck whatthefuck whatthefuck

slender thistle
#

Don't spoonfeed

gilded olive
#

There are times when if you don't spoonfeed you'll be helping for hours

outer perch
#

@mellow kelp just put a lot of catches, just found it's Bad Gateway

slender thistle
# astral forge

A simple example:

x = 5
if x == 5:
    print("x is 5")
else:
    print("x is something that's not 5")
slender thistle
#

see how if and else are on the same column?

#

yeah true Ghoul

outer perch
#

my head's a mess rn

#

how is it missing perms, if it has Admin perms!?!?!?

mellow kelp
outer perch
#
DiscordAPIError: Missing Permissions
    at RequestHandler.execute (C:\Users\ragsf\Desktop\Gumball-and-Penny\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  method: 'put',
  path: '/guilds/738540548305977366/members/597908134698156035/roles/754433915610988635',
  code: 50013,
  httpStatus: 403
}
quaint wasp
#

why did it not work again?

outer perch
quaint wasp
#

uhh

#

then where?

cinder patio
quaint wasp
#

VSC?

cinder patio
#

git just isn't added to path

outer perch
#

default powershell

#

xD

cinder patio
quaint wasp
#

how?

summer torrent
cinder patio
mellow kelp
outer perch
mellow kelp
#

i smell copied code from 10 miles away

summer torrent
#

chill out

quaint wasp
#

bruh

outer perch
summer torrent
#

`- You can not moderate (kick/ban/nickname) a target that has a higher role than your highest role or is the guild owner

  • The ADMINISTRATOR permission does not skip this check
  • You can not modify (edit/add/remove) roles that are higher than your highest role
    `
mellow kelp
#

@quaint wasp your token is in the github repo

cinder patio
#

yeah

#

refresh asap

outer perch
crimson vapor
#

then it wasn't reset?

summer torrent
#

check it again

quaint wasp
crimson vapor
#

I don't own github either

quaint wasp
#

dont u have to like... have it in ur files?

outer perch
cinder patio
summer torrent
outer perch
#

has both roles

summer torrent
#

are you trying to add No.1 Thonk

quaint wasp
outer perch
#

Muted, the role name, was above everything

summer torrent
#

lol

quaint wasp
#

I got many files... but which one I do?

outer perch
#

stooopid me

#

just a question @summer torrent, to check every role one member has in a server, do I need GUILD_MEMBERS?

quaint wasp
#

uhh

summer torrent
#

idk

quaint wasp
#

hard question/

summer torrent
#

i think yes

cinder patio
unkempt ocean
#

I don't think it's necessary

quaint wasp
unkempt ocean
#

isn't it caches when your bot joins

outer perch
unkempt ocean
#

so basically you can get from them cache

cinder patio
outer perch
quaint wasp
#

wait

cinder patio
#

wait, shouldn't you already have git if you have a bot repository

quaint wasp
#

I got github desctop

cinder patio
#

well there you go

quaint wasp
#

I dont have it in the list..

#

of those folders.

gilded olive
#

you'll need to install git if you wanna use it from powershell, cmd etc

pale vessel
#

ye

compact prairie
#

in discord.js how do you get the new and old content of an edited message

summer torrent
#

messageUpdate event

compact prairie
#

iki

#

but if a wanted to put it in an embed

#

what would i pass in

#

message.content.updatedContent?

#

no

glossy spoke
#

That doesn't have sense, there two contents ._.

compact prairie
#

wdym

glossy spoke
#

I mean you can't put content 2 times

compact prairie
#
    const embed = new MessageEmbed()
        .setTitle("Action #2 - Message Edit")
        .addField(`Channel`, `<#${message.channel.id}>`)
        .addField(`Author`, `<@${message.author.id}>`)
        .addField('Edited Content', message.content.)
        .setThumbnail(message.author.displayAvatarURL())
        .setColor(0xcc5353)
        .setTimestamp()
    return message.guild.channels.cache.get(modlog.channel).send(embed)
#

under Edited Content what do i put

#

and i would like to make a column called original content

#

???

glossy spoke
#

@summer torrent are you alive?

compact prairie
#

???

summer torrent
glossy spoke
#

This guy needs help and i never used messageUpdate event

#

lol

compact prairie
#

bc

summer torrent
#

show full code

compact prairie
#
const { MessageEmbed } = require('discord.js')
const db = require('quick.db')

module.exports = async (client, message) => {
    if (message.partial) await message.fetch()

    let modlog = db.get(`moderation.${message.guild.id}.modlog`)
    if (!modlog) return

    if (message.channel.id === modlog.channel) return

    let toggle = modlog.toggle
    if (!toggle || toggle === false) return

    const embed = new MessageEmbed()
        .setTitle("Action #2 - Message Edit")
        .addField(`Channel`, `<#${message.channel.id}>`)
        .addField(`Author`, `<@${message.author.id}>`)
        .addField('Edited Content', message.content.edits)
        .setThumbnail(message.author.displayAvatarURL())
        .setColor(0xcc5353)
        .setTimestamp()
    return message.guild.channels.cache.get(modlog.channel).send(embed)
}```
#

how would i do it

summer torrent
#

this is your messageUpdate event?

#

are you binding client

compact prairie
#

yeah

#

yeah

summer torrent
#

it is something like (client, oldMessage, newMessage)

compact prairie
#

oh

copper cradle
#

why are you checking if a bool if false

#

just check for the bool itself

glossy spoke
#

Ya

copper cradle
#

you don't have to compare true to true

glossy spoke
#

That's unnecessary

copper cradle
#

bc it's gonna return true and it's going to be the exact same thing

#

that's just a beginner mistake

compact prairie
#

wwhat

glossy spoke
#

yep

copper cradle
#

there you have if (<bool> === false) and if bool is false then it'll be true, it's the same as if (!<bool>)

compact prairie
#

oh

glossy spoke
#

It's like using if (message.content == "hi" || message.content == "hi")

#

Both checks the same thing

compact prairie
#

yeah

glossy spoke
#

And both returns the same

#

True or false

crimson vapor
#

is quick.db instant and cahed?

#

or does it take time and blocking?

glossy spoke
#

I think it's instant and cached

compact prairie
#

instant

#

yeah

glossy spoke
#

quick.db is a json db

crimson vapor
#

what does it use to write to file?

compact prairie
#

sqlite

crimson vapor
#

ah

#

hi tim

#

is sqlite blocking?

quartz kindle
#

quick.db is not a json db, at least technically speaking

compact prairie
#

yeah

quartz kindle
#

better-sqlite3 is

crimson vapor
#

quick.db?

quartz kindle
#

yes

crimson vapor
#

yikers

#

wanna do some tests?

compact prairie
#

who me

quartz kindle
#

wat tests

crimson vapor
#

find how much it blocks

compact prairie
#

what

crimson vapor
#

isn't console.log also blocking?

quartz kindle
#

yes

crimson vapor
#

is process.stdout.write blocking?

quartz kindle
#

kinda

crimson vapor
#

less than console.log?

#

wait

#

is Array.prototype.join O(n)

compact prairie
#

can you help or not

#

how do i get the edited content of the message

#

if i edit the message

crimson vapor
#

djs?

compact prairie
#

how do i get the new content

#

yeeah

opal plank
#

fetch the message?

compact prairie
#

djs

crimson vapor
#

<Client>.on('messageUpdate', old, new) iirc

opal plank
#

or listen to messageEdit events

compact prairie
#

i am

opal plank
#

not message

#

messageUpdate

#

its a different event

compact prairie
#

i am

opal plank
#

what you got?

compact prairie
#

ik

#

what

#

i have an event handler

opal plank
#

what you go so far

#

show it

compact prairie
#
const { MessageEmbed } = require('discord.js')
const db = require('quick.db')

module.exports = async (client, message) => {
    if (message.partial) await message.fetch()

    let modlog = db.get(`moderation.${message.guild.id}.modlog`)
    if (!modlog) return

    if (message.channel.id === modlog.channel) return

    let toggle = modlog.toggle
    if (!toggle) return

    const embed = new MessageEmbed()
        .setTitle("Action #2 - Message Edit")
        .addField(`Channel`, `<#${message.channel.id}>`)
        .addField(`Author`, `<@${message.author.id}>`)
        .addField(`Original Message`, message.content)
        .addField('Edited Content', message.content.upda)
        .setThumbnail(message.author.displayAvatarURL())
        .setColor(0xcc5353)
        .setTimestamp()
    return message.guild.channels.cache.get(modlog.channel).send(embed)
}```
opal plank
#

2 events

quartz kindle
opal plank
#

3 params

#

client, oldMessage, newMessage

compact prairie
#

what

opal plank
#

module.exports = async (client, message) => {

compact prairie
#

oh

quartz kindle
#

but interesting is

opal plank
#

you only got 2

quartz kindle
#

what makes console.log slow is newlines

compact prairie
#

so it would be

opal plank
#

you need the new message to compare the old to the new one

#

of course, you need to adjust your handler too, to send all 3

#

client, new and old

crimson vapor
#

is there a way to log without blocking?

compact prairie
#

module.exports = async (client, oldMessage, newMessage) => {

quartz kindle
#

doesnt look like it

opal plank
#

yes, but like i said, you need to adjust ur handler too

#

not only ur command/export

compact prairie
#

but i also need the message event

#

or param

#

bc

opal plank
#

it only sends 2 params my dude

#

you're adding a third yourself

#

which is client

#

which isnt even needed

#

cuz its inside message already

compact prairie
#

i need the channel and guild

#

so i need message too

outer perch
#

anyone with knowledge in Firebase?

opal plank
#

take a good guess what oldMessage and newMessage is

compact prairie
#

oh

outer perch
#

yeah @quartz kindle I tested and the bot didn't do anything

crimson vapor
#

@quartz kindle if you make an async function to log and don't await it, its not blocking it is? or is it blocking but just a bit after

quartz kindle
#

actually

#

i just tested in a different way

opal plank
#

aight, time for booze, brb

quartz kindle
#

and it seems its not fully blocking

crimson vapor
#

im getting chick-fil-a today

#

Tim youve had chidk-fil-a?

#

right

quartz kindle
#

no

#

idk what that is

astral forge
#

Ok @gilded olive

#

you there?

crimson vapor
opal plank
#

aight, im back

crimson vapor
#

wb Erwin

#

how is your booze

opal plank
#

ty ❤️

quartz kindle
#

ok so

astral forge
#

So I got it down, but now this is coming up

quartz kindle
#

i have interesting findings

#

about logging

crimson vapor
#

how interesting is it?

astral forge
#

oh wait a minute im dumb.

outer perch
#

custom colors in logs

#

😄

opal plank
#

i have that

modest maple
crimson vapor
#

yes

compact prairie
#

tysm it works @opal plank

modest maple
#

Js logging is non-blocking technically

quartz kindle
#

techincally

opal plank
quartz kindle
#

but at the same time it isnt

modest maple
#

its a JS micro task to the event loop

compact prairie
#

🙂

quartz kindle
#

everything you put in console.log() gets queued

#

check this out

modest maple
#

particularly in this case 28:00 timestamp shows how the behavour of logging works

quartz kindle
#

wait now its not working anymore

#

lmao

opal plank
crimson vapor
#

bro

#

Erwin

opal plank
#

oh shit i forgot to turn redis on

crimson vapor
#

thats

opal plank
#

1 sec

crimson vapor
#

really good

astral forge
#

Okay, so I tried making a simple unban command, but it does not unban the user.

Code:

async def unban(ctx, *, member):
    banned_users = await ctx.guild.bans()
    member_name, member_disc = member.split("#")

    for ban_entry in banned_users:
        user = ban_entry.user

        if(user.name, user.discriminator) == (member_name,member_disc):
            await ctx.guild.unban(user)
crimson vapor
#

use ``` not `

astral forge
#

sorry

crimson vapor
#

all good

opal plank
#

there we go

crimson vapor
#

lol

misty sigil
#

redis

quartz kindle
#

idk why but suddenly my console.log became 10x faster

crimson vapor
#

I require redis to start my bot but don't actually use it anywhere kekw

misty sigil
#

bit schewpit

astral forge
#

lmao how do i make it so it has color functions

opal plank
#

im gonna start porting my stuff to redis very soon

astral forge
#

like ths

crimson vapor
#

innit @misty sigil

modest maple
#

I went to redis

#

for about

#

5 hours

astral forge
#

how do i make it have the color functions

modest maple
#

then removed it all

crimson vapor
astral forge
#

oh

opal plank
#

its ur lang

#

use py for python

astral forge
#

Okay, so I tried making a simple unban command, but it does not unban the user.

Code:


@client.command()
async def unban(ctx, *, member):
    banned_users = await ctx.guild.bans()
    member_name, member_disc = member.split("#")

    for ban_entry in banned_users:
        user = ban_entry.user

        if(user.name, user.discriminator) == (member_name,member_disc):
            await ctx.guild.unban(user)
opal plank
#

js for javascript

astral forge
#

bruh

opal plank
#

literally copy this

crimson vapor
#

gotta return

modest maple
#

```py
thing
```

opal plank
#

```py
print('hi')```

#

copy paste that ^^

modest maple
#

cant have a space or anything after the py

astral forge
#

there we go

opal plank
#
print('hi')```
astral forge
#

and lemme check

opal plank
#

i finally got a hub for my working pc

crimson vapor
#

hub?

opal plank
#

yeah, usb hubs

crimson vapor
#

ah

opal plank
#

1 port turns into like 10

crimson vapor
#

I have like 6 usb 2.0 on my pc

astral forge
#

oh wait it works now

opal plank
#

i got 4, but now i got 10

crimson vapor
#

pog

opal plank
#

this one i got has 7

crimson vapor
#

does it connect using USB-A version 3?

#

or usb-c

opal plank
#

i dont think its

#

it should be usb 2

crimson vapor
#

oh

#

thats strange

opal plank
#

which i fine, my ssd's are connected directly

#

this is only for my pheripherals

crimson vapor
#

ig yea

opal plank
#

ggez

crimson vapor
#

yea

opal plank
#

okay now im confused

#

@ Tim hilp

crimson vapor
#

I have my mouse and keyboard in the mouse and keyboard slot, the mic and bluetooth on the 2 red usb ports, and then my heaphones on my front port

#

what you confused about?

opal plank
#

how local functions work

crimson vapor
#

whats a local function?

outer perch
crimson vapor
#

@zealous trellis

#

I think

#

idk

opal plank
#

its when you export a function and expect it to be ran in the scope it was originally declared in

#

rather than somewhere else

crimson vapor
#

ah

#

wouldn't you do something like

const x = require('file');
x.func().bind(x)```
opal plank
#

the issue is that i cant bind it

#

cuz i want it to get everything on my index

#

unless i attach them somewhere, i cant bind them

crimson vapor
#

hmm

opal plank
#

@quartz kindle hilp

crimson vapor
#

so you want index and original file?

opal plank
#

index IS the original file

#

let me give a hands down example

crimson vapor
#

yea if you can

astral forge
#

how would i make the command "Banlist"? Showing all the banned users into the chat?

crimson vapor
#

guild.functionToFetchBans()

#

idk what it is

astral forge
#

okay thanks

crimson vapor
#

bro

astral forge
#

oh lmao

crimson vapor
#

lol

#

check the docs

opal plank
#

circled the wrong thiing ontop, but its index.ts

#

variable isnt acessible in that scope

#

even though its declared in there

#

though payload, which is passed as a param to the function, doesnt

crimson vapor
#

gimme a min I can't focus while in class

opal plank
#

and its not an object, so i cant bind it

crimson vapor
#

this seems like a fun problem

opal plank
#

if i were to bind it, it'd attach on globals or process

crimson vapor
#

ah

#

so you have nothing to bind to?

outer perch
#

@opal plank what's EvalCode, and how do I do that?

crimson vapor
#

I see the problem

astral forge
#

hmmm

outer perch
#

like, I always restart the Dev bot, cuz I put a console.log() in the middle of the command

#

but there I see you can do that without restarting anything

astral forge
opal plank
outer perch
#

don't u just run a command for the bot to log something you want?

opal plank
#

eval is native from node

astral forge
#

Code:

@client.command()
async def banlist(ctx):
    await ctx.send(f'Here Are The Users Who Have Been Banned! {ctx.guild.bans}')
outer perch
#

hmm

opal plank
#

so you can simply run eval('what to eval here')

quartz kindle
opal plank
#

pass it on your message command

opal plank
crimson vapor
#

what happens if you bind(this)?

outer perch
#

gonna do a reserach so

opal plank
#

this without an object binds to process

#

or globals

crimson vapor
#

ah

#

makes sense

opal plank
#

tim tried that sometime last week

astral forge
#

can someone help me?

opal plank
#

idk py, so not from me

crimson vapor
#

I barely know js

astral forge
#

@quartz kindle can you help?

#

I know you know py

copper cradle
#

I think py has something similar

#

is it similar or simillar? kthx

crimson vapor
#

similar

astral forge
#

similar

#

Hmm anyone here know py?

quartz kindle
opal plank
#

thats it

#

so i get all variables in the index

#

but i can only access the params passed

crimson vapor
#

I never said anything

opal plank
#

i wish i could slap you rn

astral forge
#

lol

cinder patio
#

How do you eval the code

astral forge
#

Hey google

#

can ya help me?

cinder patio
#

hi

opal plank
#

just eval()

cinder patio
#

depends

opal plank
#

plus a ton of other useless shit

#

but the core is that that function simply appends the arguments onto eval() func

astral forge
#

I tried making a banlist but whenever i execute the command this happens.

#

hold on

#

Code:

@client.command()
async def banlist(ctx):
    await ctx.send(f'Here Are The Users Who Have Been Banned! {ctx.guild.bans}')
cinder patio
#

Sorry, I don't know python ^-^

astral forge
#

:/

#

Why does no one know python -_-

mint mist
astral forge
#

ohhh

copper cradle
#

if you send the thing directly it'll send the reference

cinder patio
astral forge
#

omg im dumb

copper cradle
#

it won't send the actual data

#

cuz it's an object

#

you gotta do some fuckery which I can't help you with rn

opal plank
cinder patio
#

ooh

opal plank
#

the point is to get eval to be executed locally so it has access to my variables in the index.ts

outer perch
pale vessel
#

bruh

crimson vapor
#

lol

#

hi flaze

pale vessel
#

hello

copper cradle
#

you don't actually get confused

astral forge
#

wait where do i put len()?

copper cradle
#

nah

#

we don't need that

astral forge
#

@mint mist where do we put len()?

opal plank
#

the fact that i've been listening to whip a tesla while attempting to code is not helping me focus at all

astral forge
#

by who?

#

kinda wanna join in

opal plank
copper cradle
#

lmao

astral forge
#

oh yg

copper cradle
#

what does the genshin utils bot do

opal plank
#

ey pog 1800 servers

astral forge
#

anyway where do i put len() ???

opal plank
#

and more

#

click me if you wanna see more :p

copper cradle
#

if it doesn't give me primogems then I don't need it

astral forge
#

@mint mist

#

you there?

opal plank
copper cradle
#

hmmm

opal plank
#

the bottom link has everything

astral forge
#

you actually like genshin or is it a joke

opal plank
#

i do

astral forge
#

wait no im thinking of gacha life LMFAO

slim heart
#

@opal plank yo

opal plank
slim heart
#

so i have the code published i got the two packages and maybe we can figure out what's wrong with the namespace stuf

#

i asked xet too cuz hes the one who got me on the namespace thing in the first place but maybe u can see