#development

1 messages · Page 15 of 1

boreal iron
#

that's it

#

the builder will just make anything look weird

winged temple
#

honestly looks more clean as well

boreal iron
#

as well as it will combine your entire command object in one var

#

mostly named data I think

timber cosmos
#

um guys

#

what do you use

#

to make bots

boreal iron
#

notepad++ and my fingers to write the code

timber cosmos
#

because scratch is keep going down.

timber cosmos
boreal iron
#

what what?

#

how's that misunderstanding

timber cosmos
#

ok use notepad?

boreal iron
#

notepad++

#

has nothing to do with the windows notepad you may think of

timber cosmos
#

ok

#

how do I use it

#

do I scrach it

#

search it

boreal iron
#

are you looking for just a code editor?

timber cosmos
#

nope

boreal iron
#

but?

winged temple
#

he wanna learn how to make a bot from scratch

boreal iron
#

idk

#

because scratch is keep going down.

#

sounds like some free hosting service tbh

timber cosmos
#

Yep

#

It is

#

Is there a way to use it from somewhere else

boreal iron
#

either limited to hours/months, blocked by discord (as we leanred today) or highly unreliable

#

things aren't for free that's how it is

timber cosmos
#

Yep

boreal iron
#

so... nothing I can really recommend other than taking some money into your hands or asking some friend to be the host

#

you can try asking in #general but the result will be devastating probably

timber cosmos
#

guys where do I code bot

boreal iron
#

Well using an editor you like

#

Many people use visual studio code

#

i guess

eternal osprey
#

hey how would i get the message behind a button interaction>?

#

as i want to delete it

boreal iron
#

wdym by behind it?

eternal osprey
#

so like,:

if(interaction.isButton()){
 interaction.message.delete()
}```?
#

each button is attached to a message right? I want to delete the message + button when clicking on it

boreal iron
#

The button interaction has a property called message which is the message the button been pressed on

#

This is just a djs message object you can use the common methods on

#

Like message.dekete()

eternal osprey
#

you know fake, i would marry you.

boreal iron
#

If it’s called like that

#

I would marry myself, too but I’m allowed to

eternal osprey
eternal osprey
boreal iron
#

Also just as reference

lyric mountain
boreal iron
boreal iron
#

Finally I can

#

Just need to move to Brazil I guess

#

Tim, we’re divorced now

#

Send me 50% of your stuff

earnest phoenix
#

What a FakE bond!

proven escarp
feral aspen
#

Alright, I finished coding my custom commands system, but I have no idea how to activate it.

quartz kindle
#

:^)

feral aspen
#

How will I be able to run this custom command made by the user on my message event?

module.exports = async (bot, message) => {
    if (message.author.bot) return;

    if (...) {
        ...
    } else {
        const server = await Server.findOne({ serverID: message.guild.id });
        const prefix = (server && server.prefix) || process.env.PREFIX;
    
        if (!message.content.startsWith(prefix)) return;
    
        let args = message.content.slice(prefix.length).trim().split(/ +/g);
        let cmd = args.shift().toLowerCase();

        Commands.findOne({ //
            serverID: message.guild.id, //
        }, async (error, commands) => { // 
            if (commands) { //
                let toExecute = commands.commands.find() //
            }; //
        }); //
    
        let commandfile = bot.commands.get(cmd) || bot.commands.get(bot.aliases.get(cmd));
        if (commandfile) await commandfile.run(bot, message, args).catch(error => console.log(error));
    };
};

https://cdn.hamoodihajjiri.com/xkOox2snZO

Content Delivery Network
#

Alright, let's clear off things, I'm writing it where I put // up.

quartz kindle
#

find the item where the property command equals the variable cmd you already have defined

#

then send a message containing the property value of the item you found

feral aspen
#

Alright, moment.

feral aspen
#

Ayy, it works. Many thanks! :)

pine nova
feral aspen
#

Would this be necessary, the !!! in: ```js
if (!!!commands.commands.find(command => command.command === commandToDelete))

#

Returning a boolean and checking if it's false.

earnest phoenix
feral aspen
#

Fair enough.

quartz kindle
#

even so !!! is the same as !

#

if statements already implicitly check things as booleans

lyric mountain
#

They wondered so much whether they could, that they forgot to wonder whether they should

winged temple
#

fr

earnest phoenix
#

if you guys seperate ur functions into files by its relevance/importance/topic, what would be considered the main file then? do u have ur events in the main file or how does the main file look like

#

just trying to see how people handle their code

hot glen
#

what i do I put everything in seperate files, the main file is the "loader" that loads all the commands and things

earnest phoenix
#

alright

hot glen
#

you dont have to do it that way

#

I'd say its alot harder to manage big projects in the way i structure my projects

earnest phoenix
#

I thought of putting my events into main file and loading my bot from the main file, and inside the events I run my functions and inside the functions I await for other functions

#

and the functions I have separated into files so each task has their own function

hot glen
#

just figure out how you feel the most comfortable in your project

#

I get aids when i see index.js files that are 1000+ lines

earnest phoenix
#

alright ic

earnest phoenix
hot glen
#

one of my irl friends doesnt use exporting or seperate files at all

#

i was once over at his house and he showed me his bot

#

i was like "cool show me the source"

#

and he was showing me a file with 10k+ lines

earnest phoenix
#

that's a pain in the ass

#

it already gets confusing for me at 1K lines going up and down and trying not to get confused

hot glen
#

literally like 100 functions looking exactly like this

#

yeah

earnest phoenix
#

how do I install discord.js v13

#

not v14

hot glen
#
npm i discord.js@13
earnest phoenix
#

thanksss

hot glen
#

xd np

earnest phoenix
#

if I import discord.js, what do I call this?

#

package?

#

basically I think I will make a file specially where I import all the stuff and then export it onto other files where I need them

#

so I assume I will name this file packages

#
import sharp from 'sharp'
import axios from 'axios';
import jsdom from 'jsdom';
import mongoose from 'mongoose'
import Canvas from '@napi-rs/canvas'
import booruData from './booruData.js'```

stuff like this in one file
boreal iron
#

Just import it in your index file?

sharp geyser
#

Didn't know people use napi-rs/canvas

solemn latch
#

whats the point of importing everything in one file then export it into another? 👀

boreal iron
#

I mean… just 7 lines oldEyes

earnest phoenix
#

14 or so*

earnest phoenix
#

and events

#

I need to decide for where I save my functions ( separated in files inside folders ), my events and my imports

#

e.g. if all my functions in separate files are based on discord.js, would I have to import discord.js to every file that needs it

solemn latch
#

isnt that a good thing?
improved readability

earnest phoenix
#

I am just trying not to confuse myself with imports and exports

boreal iron
#

Well just create a class, put your methods inside and export it

willow aspen
#

Not only is importing in the files needed good for readability, which shouldn't be confusing you.
But also makes the compiler aware, especially in web site instances, what is needed by the file.
If you just import every single thing in your highest level you're going to end up with a very large bundle size.

solemn latch
#

having individual imports for what you need at the top of the file, not in another file then importing everything into every file.

You can take a quick glance at the imports and see whats needed.

willow aspen
#

More can be read on this by searching "Tree Shaking"

boreal iron
#

Construct the class in your index file and pass it in your command handler to your modules

#

Aka oop style dblWink

earnest phoenix
#

I think I will just create a file that represents an import, e.g: all discord related functions go to the discord file ( which has the discord import ), all axios related functions to the axios file and so on

#

settings where I define the builder, client, intents, partials etc

#

functions for all the functions, including functions called in the event

lyric mountain
#

since when u converted to oop?

boreal iron
#

Tf

#

Never did something else

#

Stop drinking!1!

civic scroll
#

but import hell tho 💀

ancient nova
solemn latch
#

more imports please ❤️

winter pasture
#

import * from <3
import * from <3
import * from <3

proven lantern
#

lazy requires ftw

solemn latch
#

🤔 I've never heard of that.
Why?
Just a faster startup?

stuck dawn
#

how can i keep scrolling enabled but overflow hidden? it doesn't work..

#

i tryed elementname::-webkit-scrollbar display none and it doesn't work either

civic scroll
#

you wanna hide the scrollbar or something

stuck dawn
#

i wanna hide both scrollbars the x and y

#

but keep functionality but it doesn't work

stuck dawn
civic scroll
#

done

#
scrollable::-webkit-scrollbar {
    width: 0;
}

done

proven lantern
solemn latch
#

That's cool

stuck dawn
#

i tryed that way but display none

#

and it didn't work

civic scroll
#

OFC DISPLAY NONE IS NOT GONNA WORK

#

it hides the whole thing

ancient nova
#

😩

ancient nova
#

anyone have some regex to change xml into json KEKW

#

too lazy to write it

#

it'll prolly be long asf

spark flint
ancient nova
#

I imagined something wayyy longer

ancient nova
#
TypeError: string.replace is not a function
    at toProperCase (/home/container/modules/functions.js:99:17)
    at Object.exports.run (/home/container/commands/ipinfo.js:54:142)

?

lament rock
#

the variable named string isn't actually a string

#

You can ensure something is a string by wrapping it in String(…)

eternal osprey
#

hey guys, i want to host a little small site i made. However, if i actually host it on my vps i will need a domain name right?

solemn latch
#

not 100% required, you can use the ip in the url

eternal osprey
#

Owhh awesome!

#

Thanks woo

#

what's a good hosting client that you guys would recommend? Apache?

ancient nova
#
fetchIP.mobile ? "Mobile" : fetchIP.hosting ? "Server" : "Computer"
``` that's the line it happens at
solemn latch
#

I really like nginx

#

I used apache for years, used nginx once and never thought about leaving

ancient nova
#

do I need to somehow format this op?

rustic nova
#

could you post the section that uses .replace

#

since I dunno what you're trying to replace

#

though what @lament rock said, best is to wrap it

ancient nova
#

bro what the fuck

Missing } in template expression
#

my bad

#

how do I parse a domain into an IP again?

#

was it dns.promises.lookup or dns.lookup or what?

ancient nova
#

already got it working but ty

terse dock
#
@bot.command()
async def help(ctx):
    embed = discord.Embed(title = "Help", color = 0x00ff00)

    # Loop through all the commands and add them to the embed
    for command in bot.commands:
        embed.add_field(name = f"{command.name}", value = f"{command.description}", inline = False)
    await ctx.send(embed = embed)

@sharp saddle

spark flint
#

ERR_TLS_CERT_ALTNAME_INVALID

#

never had this error before

#

but getting literally hundreds now

terse dock
#

...

#

NEIN

sharp saddle
#

well

#

whats the error?

spark flint
#

request to https://anti.fish/check failed, reason: Hostname/IP does not match certificate's altnames: Host: localhost. is not in the cert's altnames: DNS:api-node2.phish.gg

terse dock
#

N o t h i n g

vivid fulcrum
#

there's probably an error but you aren't handling it properly

#

if it's a runtime error

#

(which it is)

terse dock
#

O

#

I'm still handling errors

#

f*ck

vivid fulcrum
#

make sure you aren't adding over 25 fields (i.e. commands) to the embed

#

25 is the limit

terse dock
#

Now im getting a error

#

Everything is filled

vivid fulcrum
#

you don't have descriptions for some of your commands

terse dock
#

I do

vivid fulcrum
#

so you're sending an empty string

#

the error says otherwise

terse dock
#

well from my code I do

vivid fulcrum
#

print out the names and descriptions to your terminal just in case

terse dock
#

Could it be this:

#

How aliases is first

vivid fulcrum
#

order shouldn't matter

terse dock
#

2 is missingt

#

missing*

#

well spelt wrong

#

F**k

#

Works now

#

thx

ancient nova
#
            const mutedRole = await message.guild.roles.create({
                name: "Muted",
                color: "#000000",
                reason: "Muted role for Butler Bot",
                permissions: []
            });
``` how do I make this role not allow people to talk?
terse dock
#

send_message?

#

or send_messages

ancient nova
#

that will allow them to talk, I'm looking to deny their permissions

terse dock
#

Hmm

#

Let me check brb

#

Is this discord.js?

#

send_messages = false

#

@ancient nova

#

Let me know if that works.

ancient nova
#

I just realized I had to loop over all channels any deny their permissions like so

#
            // Forgot about this, however we are going to need to loop over all channels to make the role "muted".
            message.guild.channels.cache.forEach(channel => {
                channel.updateOverwrite(mutedRole, { SEND_MESSAGES: false });
            });

channel.updateOverwrite is not a function
what was it again if not that?

#
            message.guild.channels.cache.forEach(channel => {
                channel.createOverwrite(
                    mutedRole,
                    { SEND_MESSAGES: false }
                ).catch(() => {
                    channel.updateOverwrite(
                        mutedRole,
                        { SEND_MESSAGES: false }
                    )
                });
            });
``` maybe something like this? idk
#

didn't work

#

do I have to await that maybe?

#

wait don't tell me it changed names?

spark flint
#
FetchError: request to https://domain.tld failed, reason: Hostname/IP does not match certificate's altnames: Host: localhost. is not in the cert's altnames: DNS:api-node2.phish.gg
#

getting this for no reason 🗿

ancient nova
#

can someone help

sharp saddle
ancient nova
# sharp saddle https://discordjs.guide/popular-topics/permissions.html#editing-overwrites
            // Forgot about this, however we are going to need to loop over all channels to make the role "muted".
            const channelsToOverwrite = message.guild.channels.cache.filter(ch => ch.deleted == false && ch.type === 'GUILD_TEXT');
            for (const channel of channelsToOverwrite) channel.permissionOverwrites.set(mutedRole.id, { SEND_MESSAGES: false });
Cannot read properties of undefined (reading 'set')
#

why doesn't this work then?

sharp saddle
#

if i remember correctly

#

has a channel intent

#

idk

#

i'll see

ancient nova
#

this is so annoying what the fuck

#
            const channelsToOverwrite = await message.guild.channels.cache.filter(ch => ch.deleted == false && ch.type === 'GUILD_TEXT');
            for (const channel of channelsToOverwrite) {
                channel.permissionOverwrites.set(mutedRole.id, {
                    SEND_MESSAGES: false 
                }).catch(() => {
                    channel.permissionOverwrites.edit(mutedRole.id, {
                        SEND_MESSAGES: false 
                    }).catch();
                });
            };
``` ```Cannot read properties of undefined (reading 'set')```
#

WHY?????

sharp saddle
#

see what channelsToOverwrite returns

#

console.log(channelsToOverwrite)

wheat mesa
#

Because permissionOverwrites doesn’t exist on whatever you’re trying to use it on? Bae you REALLY need to learn how to debug/read documentation

#

It would save you wonders of frustration and time spent waiting for a response

ancient nova
ancient nova
#

please end my suffering and tell me what's wrong

wheat mesa
#

Again, debugging is yet another thing I suggested in that list

ancient nova
#

what am I even supposed to debug

wheat mesa
#

It takes 5 seconds to log channel right before you try to set the overwrites

#

And also gives us more information

ancient nova
#

ok fair

#

brb

ancient nova
# wheat mesa It takes 5 seconds to log `channel` right before you try to set the overwrites
[
  '734161576717844602',
  <ref *1> TextChannel {
    type: 'GUILD_TEXT',
    guild: Guild {
      id: '734161576285700186',
      name: "Hater's Bot Testing Server",
      icon: null,
      features: [],
      commands: [GuildApplicationCommandManager],
      members: [GuildMemberManager],
      channels: [GuildChannelManager],
      bans: [GuildBanManager],
      roles: [RoleManager],
      presences: PresenceManager {},
      voiceStates: [VoiceStateManager],
      stageInstances: [StageInstanceManager],
      invites: [GuildInviteManager],
      scheduledEvents: [GuildScheduledEventManager],
      available: true,
      shardId: 0,
      splash: null,
      banner: null,
      description: null,
      verificationLevel: 'HIGH',
      vanityURLCode: null,
      nsfwLevel: 'DEFAULT',
      premiumSubscriptionCount: 0,
      discoverySplash: null,
      memberCount: 5,
      large: false,
      premiumProgressBarEnabled: false,
      applicationId: null,
      afkTimeout: 300,
      afkChannelId: null,
      systemChannelId: '734161576717844602',
      premiumTier: 'NONE',
      explicitContentFilter: 'DISABLED',
      mfaLevel: 'NONE',
      joinedTimestamp: 1659225404765,
      defaultMessageNotifications: 'ALL_MESSAGES',
      systemChannelFlags: [SystemChannelFlags],
      maximumMembers: 500000,
      maximumPresences: null,
      approximateMemberCount: null,
      approximatePresenceCount: null,
      vanityURLUses: null,
      rulesChannelId: null,
      publicUpdatesChannelId: null,
      preferredLocale: 'en-US',
      ownerId: '392035788004524043',
      emojis: [GuildEmojiManager],
      stickers: [GuildStickerManager]
    },
    guildId: '734161576285700186',
    parentId: '734161576285700189',
    permissionOverwrites: PermissionOverwriteManager { channel: [Circular *1] },
    messages: MessageManager { channel: [Circular *1] },
    threads: ThreadManager { channel: [Circular *1] },
    nsfw: false,
    id: '734161576717844602',
    name: 'normal-cmd-testing',
    rawPosition: 2,
    topic: null,
    lastMessageId: '1004177415901286422',
    rateLimitPerUser: 0
  }
]
#

it logs this

wheat mesa
#

And this is channel, correct?

#

Because why is it an array?

#

That’s your issue right there for sure

#

Ah it’s because you’re looping over a collection with of

ancient nova
#
            const channelsToOverwrite = await message.guild.channels.cache.filter(ch => ch.deleted == false && ch.type === 'GUILD_TEXT');
            for (let i = 0; i > channelsToOverwrite.length; i++) {
                channelsToOverwrite[i].permissionOverwrites.set(mutedRole.id, {
                    SEND_MESSAGES: false 
                }).catch(() => {
                    channelsToOverwrite[i].permissionOverwrites.edit(mutedRole.id, {
                        SEND_MESSAGES: false 
                    }).catch();
                });
            };
wheat mesa
#

Use for(const channel of channelsToOverwrite.values()) instead, otherwise you’re going to be getting [channelId, ChannelObject]

ancient nova
#

is this better?

ancient nova
#

ok

#

@wheat mesa it worked

#

javascript is weird

wheat mesa
#

It’s not weird

#

Djs/the base map class defined a [Symbol.iterator] for the class so that you can loop over it like that

#

And it happens to work like that

ancient nova
#

I thought it would just return an array of channels

#

like it's.. kinda supposed to

wheat mesa
#

A loop is quite literally an iterator

#

It iterates over each thing

#

Otherwise you would not be able to use a loop on the collection like that

ancient nova
#

it is? I could've sworn I used that kind of loop like what I sent above and it worked fine

wheat mesa
#

However I’m not going to expect you to know that one since it’s a lesser known thing that you can do that with js

#

Forgot about it myself until now

wheat mesa
ancient nova
#

btw my bot uses 400mb now KEKW

wheat mesa
#

What did you add to make it use that much

#

Or are you just caching a lot more stuff

ancient nova
#

I've honestly got no idea at this point, I only added afks to the cache and added 2 more things stored in the warn system that's all

#

but maybe the ram count wasn't accurate in the first place

#

I changed it from .totalHeap to .rss

wheat mesa
#

Are you caching all your members, and is there any big libs that could contribute to that? Even djs shouldn’t be eating THAT much tbh

ancient nova
#

at first it jumped from 40mb to 200mb but now it's at 400mb almost

wheat mesa
#

Does it grow over time

ancient nova
wheat mesa
#

Sounds like a memory leak to me

ancient nova
#

let me check what it is right now

#

last checked it was 400mb yesterday

#

huh it's exactly at 135.17 MB

#

maybe the memory leak happens when certain command executes or certain module is used?

wheat mesa
#

Perhaps you just misread your ram usage

ancient nova
boreal iron
#

300 MB RAM for 77 servers

#

Tf

lament rock
#

The largest item in memory is module strings

ancient nova
#

imagine how much ram my bot gonna eat at 1k

lament rock
#

Why I moved away from Discord.js

#

it sacrifices memory usage for type safety which I hate

quartz kindle
boreal iron
#

Well tbh I’m using the default caching options and are by about 20MB usage for 400 servers yet

#

Dunno what people store or cache or how many junk vars they create

lament rock
#

just to import Discord.js takes up 100MB on my end so idk what magic you're pulling

boreal iron
#

lol

quartz kindle
#

dicksword.jayass

ancient nova
#

how do you do things?

#

😭

lament rock
#

slash commands give you everything or almost everything

quartz kindle
#

i dont need them?

ancient nova
quartz kindle
#

i dont even check permissions

ancient nova
lament rock
#

The message content intent enforcement might compel you to switch

boreal iron
#

Well 23MB now… what a peek

quartz kindle
#

heap or rss?

#

that looks like heap

boreal iron
#

Errr no don’t think so

lament rock
#

I don’t have to check permissions either. Only instance I should is if I join a vc, but I can just try to join it and if I don't receive a VOICE_SERVER_UPDATE in 5 seconds, it likely didn't happen

ancient nova
#

my heap was 40mb my rrs is 130mb now

wheat mesa
#

You can barely even run a nodejs process on <30mb of ram (rss) tbh, much less maintain a whole bot + gateway connection

boreal iron
wheat mesa
#

Surely you’re doing the calculation wrong then… surely

quartz kindle
#

sharding manager?

boreal iron
#

Nope

wheat mesa
#

Maybe he’s not even running v8, he’s running v25 KEKW

boreal iron
#

Lol

quartz kindle
#

do you have an eval command?

lament rock
boreal iron
#

Sure post the correct name

#

Isn’t it memoryUseage()?

wheat mesa
#

process.memoryUsage().rss

boreal iron
#

K one sec

quartz kindle
#

show all memoryUsage props

#

process.memoryUsage()

boreal iron
#

Don’t wonder about the 20MB I mentioned earlier

wheat mesa
#

Lol

boreal iron
#

Those stats are always 1h old

quartz kindle
#

do you host on windows?

#

your rss is swapped/paged out

#

thats why it shows 30mb

#

your heap is 250mb

boreal iron
#

Lemme check something

wheat mesa
#

So what you’re saying is that if your rss is lower than your heap, then use heap for stats

quartz kindle
#

you can do that

ancient nova
quartz kindle
#

the os will always try to balance between physical ram and swap/page files

#

rss should represent whats on physical ram

#

heap should represent what the js engine is holding

#

there is no accurate way to calculate other proportions from inside the program i guess

#

there are tons of different ways of calculating memory usage

boreal iron
#

Ah interesting

quartz kindle
#

windows has a "commit size" on the task manager

#

which is more accurate than the "memory usage" metric

#

because it also includes swapped/innactive

#

linux has a virtual memory, but its not really realistic in what it uses, it just says its allowed to use that much

wheat mesa
#

I see you’ve been talking to speedy too much

quartz kindle
#

or speedy's been talking too much to me

wheat mesa
#

Lol

boreal iron
#

Good this has been sorted?!

#

Actually sad but hmm

quartz kindle
#

i always enable the "commit size" column on my task manager

boreal iron
#

Hmm well can’t check atm

#

But yeah might be the case

quartz kindle
#

then you can see shit like this

boreal iron
#

Didn’t notice after moving it a windows vm

quartz kindle
#

thats mozilla thunderbird btw

boreal iron
#

Probably was accurate in the Ubuntu built before

quartz kindle
#

it made me scratch my head when running memory benchmarks

#

for example i was making scripts to intentionally fill up memory

#

and i would see rss grow and then suddely drop to < 100mb

#

while the js memory kept rising

boreal iron
#

Hmm ok I see

#

Guess I’m gonna check for the higher value than on the next bot version

#

Or make it depend on the OS

grizzled raven
#

speaking of rss, it feels like for me swap just doesn't get used at all lmao

#

is there some sort of common mistake i could be making

#

idk

quartz kindle
#

are you hosting on windows or linux?

boreal iron
#

But interesting we figured that out, never really thought about the memory drop on the new VM

#

Not that it would be important in my case at all

#

But good to know

quartz kindle
#

i think windows and linux report rss usage in different ways

#

its possible that both are using swap but linux includes it and windows for some reason doesnt

#

or they simply count it in different ways

lament rock
#

windows has "swap", but it's called the paging file

#

oh nvm I read that wrong

quartz kindle
#

i also cant find anything about it on google, the rss disparity between linux and windows in nodejs

boreal iron
boreal iron
quartz kindle
#

lmao

grizzled raven
boreal iron
#

Just regarding the default caching options… does a member permission check require both roles and permissions to cache?

quartz kindle
#

global permissions only need roles

#

channel-specific permissions need both roles and permissionOverwrites (and channels)

boreal iron
#

I need to check the dev docs again…
I think not only app permissions as field is available now, also member permissions is

#

I don’t remember anymore

#

Which shows the permissions of the app/member (if available) in reference to the current channel the interaction has been executed

#

Which completely makes role/permission caching obsolete tbh

#

Nvm

#

Just app permissions not member permissions

earnest phoenix
boreal iron
#

And close above

#

going to sleep now, gonna watch your response later

earnest phoenix
# boreal iron https://discord.com/channels/264445053596991498/272764566411149314/1004198328050...

Yeah, Windows reports RSS and similar memory usage diagnostics differently than Linux, which causes the values to differ, I'm not exactly sure in what way Windows calculates the memory usage but here's the source of process.memoryUsage() method if you want to look deeper yourself

JavaScript side implementation with binding call:
https://github.com/nodejs/node/blob/main/lib/internal/process/per_thread.js#L169-L178

C++ side implementation using memory tracker:
https://github.com/nodejs/node/blob/main/src/node_process_methods.cc#L179-L207

Memory tracker and retainers:
https://github.com/nodejs/node/blob/main/src/memory_tracker-inl.h

The heap statistics struct:
https://chromium.googlesource.com/v8/v8.git/+/refs/tags/10.6.85/include/cppgc/heap-statistics.h#19

The heap statistics getter:
https://chromium.googlesource.com/v8/v8.git/+/refs/tags/10.6.85/src/api/api.cc#8925

sharp geyser
#

Ain't no way you looked this up

wheat mesa
#

You…know he works on v8, right?

earnest phoenix
#
radiant kraken
#

🤓

ancient nova
#

bots finally verified

earnest phoenix
sharp geyser
#

But I'd never actively look for that

bright thorn
#

i want that when a channel permission is updated then i can use the channel for my bot which event is this any one can tell me ?

ancient nova
#
const moduleLogger = await {
    logSpam: function (_amount, _message, _settings) {
    // CODE
    }
}
``` is this not going to work when being called like so: `moduleLogger.logSpam()`
???
wheat mesa
#

I have no idea what you're doing... ```js
const moduleLogger = await {
/*
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
*/
}

ancient nova
#

cause my VPS is going nuts

ancient nova
wheat mesa
#

That's not the point

#

Use classes for that

#

I have no idea what kind of syntax this is: const moduleLogger = await { }

#

Does it even let you do that?

ancient nova
#

I mean it works so why question it

#

js is weird

wheat mesa
#

Do you know what await does...

ancient nova
#

my bad I wanted to do async

#

I'm tired KEKW

wheat mesa
#

async would not make sense there either

ancient nova
#

how else would I use functions that need awaiting?

wheat mesa
#

🤦‍♂️

sharp geyser
#

Ever just have your piano start playing on its own?

ancient nova
sharp geyser
#

When you use it

#

And even then why are you awaiting something you're logging

wheat mesa
sharp geyser
#

You don't cause it's wrong to begin with :^)

ancient nova
#

yeah I fixed that

ancient nova
wheat mesa
#

What you're looking for is ```js
class ModuleLogger {
async someFunction() {
// ...
}
}

timber cosmos
#

Guys, is there a way to create bot

wheat mesa
#

Though const moduleLogger = { } stuff also works technically

timber cosmos
#

Not from like scratch

#

Like coding-

wheat mesa
#

That's creating an object manually

ancient nova
#
const moduleLogger = {
    logSpam: async function (_amount, _message, _settings) {
    }
}
wheat mesa
#

If you intend to use this in multiple places, I'd suggest using a proper class

ancient nova
#

nope, only in a single script so no need to

sharp geyser
#

People actually still use the function keyword?

ancient nova
#

it's quite complicated, I'd like to explain but I'll most likely do it badly and you won't understand anyway

sharp geyser
#

I just use arrow functions

ivory wing
#

hey i was wondering how i made the webhook for top.gg to send to. I am using python. I am ok with using webhooks but i never tryed to set one up before?

ivory wing
#

I am trying to do it with out the of third party servacys and thats where i am stuck one

ancient nova
#

my method doesn't seem to work @wheat mesa

#

no errors though

#

should I just use a class? :/

wheat mesa
#

You have provided no information on how your code looks, so I don't know

#

Usually there's no reason to manually construct an object like that

ancient nova
#

god damn it nevermind

#

how tf do I async a class

wheat mesa
#

???

#
class ModuleLogger {
  async logSpam() {
  
  }
}
#

no function keyword is necessary

#

also, class names are PascalCase, not camelCase

ancient nova
#

makes sense

sharp geyser
#

Ain't no way this your first time using classes

#

Or at least seeing how ones done

ivory wing
#

I got the API working but the docs dont say anything about time. instead of the last 1000 votes is it possible to see the ones in the last 30 minutes

ancient nova
#

should I do an auto role next?

ancient nova
void mica
#

How would i make it a requirement to upvote on topgg to use a certain command?

ancient nova
#
    // If autorole is on, let's attempt at applying the role to the new member!
    if (settings.autoRoleEnabled === "true") {
        // Lets now attempt to fetch the role.
        // We start by adding a couple variables we are going to use later.
        const autoRole = settings.autoRole;
        const mentionedRoleRegex = /^<@&(\d+)>$/;
        
        // Now let's assign a couple variables that we are going to *edit* later.
        let finalCheck, roleID;
        
        // First lets start by testing by Id, mention and lastly by name.
        if (mentionedRoleRegex.test(autoRole)) {
            finalCheck = member.guild.roles.cache.get(autoRole.replace(/<@&(\d+)>/, "$1"));
        } else if ((roleID = member.match(mentionedRoleRegex)) !== null) {
            finalCheck = member.guild.roles.cache.get(roleID[1]);
        } else {
            finalCheck = member.guild.roles.cache.find(_role => _role.name.toLowerCase() === autoRole.toLowerCase());
        }
        
        const role = member.guild.roles.cache.get(finalCheck?.id || finalCheck);
        if (role) {
            // If role exists lets now add the role on our member.
            member.roles.add(role).catch((err) => {});
            
            // TODO: Logging confirmation.
        }
    }

anyone knows why this doesn't work?

sharp geyser
#

I'm still going to troll you for using strings

#

For booleans

wheat mesa
#

can someone put it on a pastebin this is hell to read on mobile

sharp geyser
#

I understand that pain

wheat mesa
#

Discord needs to come up with a solution for codeblocks on mobile fr

#

Perhaps zoom-able UNWRAPPED text blocks

sharp geyser
#

That will come in the update of 2060

wheat mesa
wheat mesa
#

This line

ancient nova
#
        if (mentionedRoleRegex.test(autoRole)) {
            finalCheck = member.guild.roles.cache.get(autoRole.replace(/<@&(\d+)>/, "$1"));
        } else if ((roleID = member.match(mentionedRoleRegex)) !== null) {
            finalCheck = member.guild.roles.cache.get(roleID[1]);
        } else {
            finalCheck = member.guild.roles.cache.find(_role => _role.name.toLowerCase() === autoRole.toLowerCase());
        }
        
        if (finalCheck) member.roles.add(finalCheck).catch((err) => {});
``` by the way I realized I fetched them 2 times
#

I thought this would surely fix it, yet it didn't

wheat mesa
#

Not to mention I have no idea what that regex does

ancient nova
wheat mesa
#

Also why are you prefixing random variable names with _ now

wheat mesa
#

Log it, see what it is

ancient nova
wheat mesa
#

I don’t do regex stuff, but you’ve given it a string literal in the 2nd argument of a .replace call. Which from my knowledge is going to replace anything your regex matches with that string

#

Log it and check

#

If I’m wrong then I’m wrong, but it’s a possibility

ancient nova
#

I'll log it and then get back to you

#

give me a moment

wheat mesa
#

👍

ancient nova
#

@wheat mesa it logged the ID of the role

wheat mesa
#

Don’t know then, mobile formatting sucks so it’s not very easy to read

#

Plus it’s 2:30am so I can only do basic stuff in my brain rn

ancient nova
#

same lol I literally feel brainded rn

#

but I really wanna finish this

boreal iron
eternal osprey
#
const { Client, Collection, Intents, Modal, TextInputComponent, MessageActionRow, MessageEmbed, MessageButton, SlashCommandBuilder   } = require('discord.js');
module.exports = {
    data: new SlashCommandBuilder()
    .setName('account')
    .setDescription('Command to generate an account'),
    async execute(interaction) {
}
}```Why is it erroring: SlashCommandBuilder is undefined?
boreal iron
#

Because you didn’t import slashcommandbuilder from discord.js

#

At least… I can’t see it

eternal osprey
#

Huh so far i haven't done that with any of my bots and they all work

#

how's that then>

boreal iron
#

Is exactly like you import client, nessageembed etc

#

I wonder do you need all this structures imported in that module?

#

Don’t see you using any of it at least no in that code snipped

eternal osprey
boreal iron
#

You should only import what you need tbh

#

But anyways just add slashcommand builder to the import list

eternal osprey
#

5|index | TypeError: SlashCommandBuilder is not a constructor

#

i think that my vps is running on the wrong djs version

ancient nova
#

do bots have nitro now?

eternal osprey
#

TypeError: SlashCommandBuilder is not a constructor
bro what the fuck is this

ancient nova
#

update to v14

eternal osprey
#

no i don't want to update to v14

boreal iron
#

Oh you’re on v13

#

Didn’t notice

eternal osprey
#

yeah

boreal iron
#

Well it’s part of the builders package then, just with v14 they have moved into the djs package

eternal osprey
#

I see

#

now it's throwing a tantrum of errors: 5|index | ReferenceError: SlashCommandBuilder is not defined

#

"discord.js": "^13.8.1",

boreal iron
#

In the first place update the package to 13.9

#

And yeah it’s not defined in discord.js but in the builder package

eternal osprey
#

what's the builder package then

boreal iron
#

But don’t ask how to import it, never used builders freerealestate

#

“discord.js/builders” maybe?! Idk

eternal osprey
#

still same error whatever fucking packjage i install

#

really starnge

ancient nova
#

😩 😫 😩

#

same tho, I'm still staying on v13

boreal iron
boreal iron
#

So the name should be @discordjs/builders

eternal osprey
#

Yeah it worked now

#

fr some reason i had a mashup of v14, v12, v13 in my node_modules

#

i then forced uninstall, install and it worked

#
let detecrole1 = message.guild.roles.cache.find(r => r.name === "Wow Events");
  let detecrole2 = message.guild.roles.cache.find(r => r.name === "FF Events");
  let detecrole3 = message.guild.roles.cache.find(r => r.name === "Public Events");
  let detecrole4 = message.guild.roles.cache.find(r => r.name === "Minecraft Events");
  let detecrole5 = message.guild.roles.cache.find(r => r.name === "Other Game Events");
if(message.mentions.roles.first() !== undefined){
    if(message.mentions.roles.first() === detecrole1 ||)
}```Is there any more efficient way of doing this instead of || marks (as i want to improve my habits lol)
#

I basically want to check if the pinged role is either role1, 2, 3, 4 or 5

tulip ledge
#

[detecrole1, detecrole2, …].includes(message.mentions…)

crystal wigeon
#

Hi so um im actually using this to get a channel from its id.

    return channel;```

But im not getting any data, this is a newly created channel
#

anything else i can try?

eternal osprey
pale vessel
#

Try fetching the channel

crystal wigeon
#

channels.fetch?

#

i got an error for that

#
name:'DiscordAPIError'
method:'get'
message:'Unknown Channel'
httpStatus:404
code:10003```
#

getting this error

#

its a newly created channel, it says 404

earnest phoenix
#

am I using jsdocs right?

#

basically I wanna document everything I write in a file, from imports to methods to functions to returns

cinder patio
#

just use typescript ez

quartz kindle
crystal wigeon
#

Also all commands work there

quartz kindle
#

not from code?

crystal wigeon
#

Nop

quartz kindle
#

if you did not receive a channel_create event, then discord is broken

earnest phoenix
quartz kindle
#

i had a feeling it was os dependent

#

on windows v8 could try acessing commit size instead of active memory

#

usually commit size is much more accurate, from what i see in my task manager

crystal wigeon
quartz kindle
#

do you have the guilds intent?

crystal wigeon
#

It basically says channel doesn’t exist

#

Yeah

#

It works if the channels already exist

quartz kindle
#

try adding a client.on("channelCreate")

crystal wigeon
#

Mhm

quartz kindle
#

then make a new channel and see if anything shows up

#

in the channelcreate event

feral aspen
#

How many times can you set slash commands in an hour?

#

Cause I'm no longer able to set slash commands in a guild since it's erroring.

#
const slashcommand = bot.slashcommands.get(interaction.commandName);
if (!slashcommand) return interaction.followUp({ content: 'An error has occured, whereas this command is no longer available.' }).catch(error => console.log(error));

Suddenly, returning the above error.

quartz kindle
earnest phoenix
#

I think I am using the standard one

quartz kindle
#

depending on your programs, plugins, extensions, cli apps, etc

#

it might support a different one

#

vsc for example uses the typescript jsdoc

earnest phoenix
#

ohh

quartz kindle
#

at least thats what i use

earnest phoenix
#

yeah I use that then

quartz kindle
#

since i also have the typescript extension installed

#

and thats what intellisense shows me

#

typescript jsdoc doesnt support all jsdoc @ tags, only a few, but it does support all typescript typings

#

which makes it easier to use

#

the typescript website has a section for their jsdoc version

#

you can check that

solemn latch
#

Vsc jsdoc needs to be enabled right?

quartz kindle
#

should be enabled by default

#

but strict typing is not enabled by default

#

so you wont get redline errors for types

#

the only relevant extension i have installed is intellicode

solemn latch
quartz kindle
#

you need to create a tsconfig file to configure it

#

the configs in vsc itself are not enough

#

vsc has these

#

which are enough to enable some type checking

#

but for full strict you have to do this

earnest phoenix
solemn latch
tender quest
#

do u guys know how i can be notified if ny bot goes offline?

pale vessel
#

Create a second bot that monitors the main bot

#

Or maybe set up a reminder on offline shards

solemn latch
lyric mountain
#

POV: you forgot a semicolon

quartz kindle
#

thats what happens when you enable strict mode on js files :^)

floral mist
feral aspen
tender quest
feral aspen
floral mist
boreal iron
#

simply use return;

#

to end the function

feral aspen
#

Supposedly, I have an array called ignoredRoles which are full of role IDs, and in my message event, I want to see that if the user has any of the ignoredRoles, then return.

#

How can I achieve such so.

cinder patio
#

roles.some(r => ignoredRoles.includes(r))

feral aspen
#

Oh, .some().

#

Forgot about that, thanks.

feral aspen
#
!toExecute
!toExecute.ignored.channels.includes(message.channel.id)
!message.member.roles.cache.some(role => toExecute.ignored.roles.includes(role))

Those are my three checks. Apparently, if I return; for one check, it's going to just not look at the rest of the code within the function, so?

#

I made one huge if statement like:

if (toExecute && !toExecute.ignored.channels.includes(message.channel.id) && !message.member.roles.cache.some(role => toExecute.ignored.roles.includes(role.id))) message.channel.send(...);
quartz kindle
#

another way is to use a process manager to manage your bot process, many of them can be configured to notify you via email if the process restarts

floral mist
spark flint
#

Love this bot

elfin tulip
#

Hello, how do I use discord.js collector on discord buttons?

celest shard
#

I want to make it so pages don't have to be static so any feedback on that (or anything else regarding the library) is appreciated, :)

proven escarp
wheat mesa
#

I don't think what he's saying has anything to do with the question. He's just asking for feedback

#

Which is perfectly fine

celest shard
#

I wasn't responding to the other guy, i was just asking for feedback :)

#

yeah what the waffle said

proven escarp
#

Damn my bad. Timing 100

#

Sorry!

quartz kindle
#

minimodding fail

celest shard
#

ah yours uses reactions so together we cover every edge case

lyric mountain
#

nope

#

mine uses both sides lmao

celest shard
#

hmm yes i see. I'm reading the readme right now

lyric mountain
#

reactions were kept for compatibility with older models (or use buttons in user messages)

lyric mountain
#

I'm just waiting for jda to release a stable version so I can build on top of it

celest shard
#

what are the chances though holy shit

sharp geyser
#

None

#

I'm kidding what you guys talking about?

celest shard
#

lol

lyric mountain
celest shard
sharp geyser
#

Oh pagination?

celest shard
#

and this other guy also made a library that is similar

sharp geyser
#

Yea I've used Haku library before

#

It's pog

lyric mountain
#

jda's "official" paginator is...let's say "peculiar"

sharp geyser
#

Until his library made me get 429nd out my ass

lyric mountain
#

I swear I NEVER managed to make jda-utilities work

celest shard
#

i won't be covering it though tbh unless someone PRs

lyric mountain
sharp geyser
#

Good glad I opened that issue

lyric mountain
#

lmao

celest shard
#

my library is cooler though guys believe me

sharp geyser
#

I was shocked when I realized you were that guy

#

Before I never interacted with you on topgg and then I realized you were that guy and was like damn

lyric mountain
#

top 10 anime plot twists

sharp geyser
celest shard
#

java is the new kotlin amirite

sharp geyser
#

Tf

celest shard
#

it's full circle

sharp geyser
#

I think the last time I used java was to make a parser

celest shard
#

kotlin wasn't really a thing when i started and i never made myself learn it

lyric mountain
#

when did u start?

#

kotlin is almost as old as jetbrains itself

sharp geyser
#

Back in 1912

celest shard
#

yeah but it took off fairly recently. google saying it was the preferred language for android etc

sharp geyser
#

I mean kotlin is nice ngl

lyric mountain
#

I love java but fuck android api

sharp geyser
#

I'd prefer it over normal java

lyric mountain
#

why did they have to rewrite the ENTIRE java ecosystem?

sharp geyser
#

Plus if you do wanna use java you can

#

Java is valid kotlin

lyric mountain
#

no, I mean android itself

#

all my homies use BufferedImage but no, let's use Bitmap tf

#

wanna use Color? too bad, figure out how to use this 100% incompatible class

sharp geyser
#

Makes sense

lyric mountain
#

tbh nowadays I'd use react or flutter over java/kotlin

#

same for web

celest shard
#

anyways if someone knows Discord4J and wants to provide (or help) the impl for the library i posted it would be great

#

made it for JDA only now cause i have literally never touched Discord4J. It's pretty different as far as i can tell

sharp geyser
#

Discord4J is still around?

celest shard
#

yup it's kickin

#

last commit on master was 4 days ago

sharp geyser
#

I didn't think anyone really used it

quartz kindle
#

d4j will be the next log4j

#

:^)

celest shard
#

they should change the name to avoid the vulnerability

#

that's how it works right?

nocturne spade
#

ohk

#

here

snow steeple
#

there should be a way

#

to make ur bot leave a guild

#

i think its something like

nocturne spade
#

hh

snow steeple
#

client.guilds.leave('guild id')

nocturne spade
#

kk

snow steeple
#

or <Guild>.leave

#

ya so

sharp geyser
snow steeple
#

cache guilds and find unusual names, ez.

snow steeple
quartz kindle
snow steeple
#

wow

#

such a good ip

sharp geyser
#

Hacked

snow steeple
#

guess what!

sharp geyser
#

Get trolled

snow steeple
#

i have the same ip

#

127.0.0.1

nocturne spade
#

HH

quartz kindle
#

what a coincidence!

sharp geyser
#

Also I just remembered that this is no longer an allowed topic

#

Dylan warned me a few days ago about it

celest shard
#

yeah? mine is fe80::7709:b321:f506:6560. I'm living in the future

snow steeple
#

ooh

#

ok

quartz kindle
#

dayum

lyric mountain
#

me when ip 7F000001

quartz kindle
#

nice

lyric mountain
#

but really, I fear a future where u wont be able to memo your own ip

sharp geyser
#

Did you just throw out a hex code

lyric mountain
#

ipv6 is just hardcore

sharp geyser
#

What color is that

quartz kindle
lyric mountain
#

oh wait, what is the color of localhost

sharp geyser
#

Yea

celest shard
snow steeple
#

ooh

sharp geyser
#

Everything has a color

quartz kindle
#

actually

#

my ip is

#

z8kflt

sharp geyser
#

Yes and my name is flibergorgon

#

Welcome to the year 3040

lyric mountain
#

localhost visualized

earnest phoenix
#

hey guys im mapping a list of admins, but I need a variable name. do I call it;
admins, adminList or adminMap or... administratorList or..

sharp geyser
celest shard
#

your pages are also made of static content right? @lyric mountain

sharp geyser
quartz kindle
#

\x7F\x00\x00\x01

#

thats my actual ip

quartz kindle
sharp geyser
#

Imagine it all IPs had a color

earnest phoenix
#

am I doing good spacing here?

lyric mountain
#

intellij shows in RGBA format, but the universal standard is ARGB

quartz kindle
#

arrhhhgb

civic scroll
lyric mountain
#

I would tab twice on method chains

civic scroll
#

^

torn topaz
#

^

civic scroll
#

ayo?

lyric mountain
#

ah the forms dude

torn topaz
#

hi lol

lyric mountain
#

hi

#

also return the value directly instead of assigning to a variable and returning it

#

node probably does that internally tho

civic scroll
#

bruh

#

just return the string literal

#

💀

#

i'm still thinking of a way to properly store configs in browser's storage

lyric mountain
#

what framework is that?

civic scroll
#

custom-defined file

#

i used jotai for storing states

#

it's a react web app

#

it's kinda stored like

key                      | value
System.Time.UseMiliatary   true
System.Time.GMTOffset      7
Clock.BlinkAnimation       true
Clock.DefadeZerosOnHover   true
lyric mountain
#

can't u use properties then?

#

or yaml since u repeat some domains

civic scroll
#

maybe i can do like

key: Config    
value: "{ 
    "System": {
        "Time": {
            "UseMilitary": true,
            "GMTOffset": 7    
        }
    },
    "Clock": {
        "BlinkAnimation": true,
        "DefadeZerosOnHover": true
    }
}"
#

but modification requires writing stuffs on the browser often

lyric mountain
#
System:
  - Time:
    - UseMilitary: true
    - GMTOffset: 7
Clock:
  - BlinkAnimation: true
  - DefadeZerosOnHover: true
civic scroll
#

can i use yaml in browsers?

lyric mountain
#

I mean, it's still a text format

#

although js does support json natively

civic scroll
#

yeah that's the problem

#

i wanna preload shit asap

lyric mountain
#

hm, idk how fast json -> object conversion is, but maybe u could use some easily parseable format

#

like properties

#
System.Time.UseMiliatary=true
System.Time.GMTOffset=7
Clock.BlinkAnimation=true
Clock.DefadeZerosOnHover=true
vivid fulcrum
lyric mountain
#

just iterate over the lines and split by =

civic scroll
#

shit's 3874 lines

vivid fulcrum
#

oh

#

expensive

civic scroll
#

yaml-parser

lyric mountain
#

you could try to benchmark it to see what's faster for u

civic scroll
lyric mountain
#

properties is fast af cuz u don't need to parse the whole thing at once

civic scroll
#

line-by-line parsing right

lyric mountain
#

my i18n file uses it, and has 630+ lines

lyric mountain
#

if it doesn't match what ur looking for just step over

#

oh also

#

there's a format I use for my dictionary files

civic scroll
#

shit's like ```js
config.map(({key, value}) => ${key}=${value}).join('\n')

lyric mountain
civic scroll
#

but then i still have to do iteration

lyric mountain
#

I pre-map the lines where each letters starts

#

so when reading, I can simply jump to it and start checking from there

#

first line is max size of line number

#

second line are the letters + line (like a000002 means letter a starts at line 2)

#

and this file is...big

civic scroll
#

perhaps i can do that

lyric mountain
#

u could do something similar but using the keys instead

#

like, System starts at line XXX, Clock at YYY, and so on

civic scroll
#

maybe i should do something like

#

volatile storage

lyric mountain
#

although you'd need to figure a format that allows multichar indexing

civic scroll
#

yeah

#

that too

lyric mountain
#

just go by initials then

civic scroll
#

like what

#

System.Time.GMTOffset -> STG

lyric mountain
#

like what I did, you'd just need to update the index if u change the structure

lyric mountain
civic scroll
#

i just gotta make sure that the keys are not overlapping

lyric mountain
#

unless u have a huge amount of settings under system

civic scroll
#

since it's an os

#

💀

lyric mountain
#

hm

civic scroll
#

yeah so i wanna make it as performant as possible

lyric mountain
#

ok so, you could index by 2 letters then

#

sy

#

or whatever, 3 letters as u said

#

stg

#

this is what I use for reading and going to the line

#

for example, b indexation would be chars 8 to 12 (AxxxxxxB|xxxxxx|)

#

then I return false if I reach a line where the letter is different than the current (since I cant have a word that begins with b inside c section)

civic scroll
#

i see

#

so fixed length

lyric mountain
#

or true if I do find the word

lyric mountain
#

so u can get a substring of it relying only on char index

civic scroll
#

ohhhh

lyric mountain
#

a000002b028596c041399d072604e084433
means

A -> line 2
B -> line 28596
C -> line 41399
D -> line 72604
E -> line 84433
#

and it can be easily generated by code

civic scroll
#

yes

quartz kindle
#

if you want as performant as possible, json will likely be faster, unless you know what you're doing

civic scroll
#

json then

#

i'm just afraid of multiple func calls

quartz kindle
#

you're reading/writing the entire thing to/from localstorage?

#

like serializing every time?

lyric mountain
#

keeping it in memory would be pretty bad no?

quartz kindle
#

the more memory you use the faster it is

#

the more stuff you keep in memory i mean

civic scroll
#

so i call for each write just in case

earnest phoenix
#
export const findFriendlyChannel = (guild) => {
    let found
    guild.channels.cache.map(async (channel) => {
        if (!found && channel.type === "GUILD_TEXT") {
            if (channel.permissionsFor(client.user).has("VIEW_CHANNEL") && channel.permissionsFor(client.user).has("SEND_MESSAGES")) {

                found = true

                console.log(channel)

                return channel

            }
        }
    });
}
const friendlyChannel = findFriendlyChannel(guild)
console.log(friendlyChannel)

why is friendlyChannel returning undefined even though I am returning channel which is the channel object

lyric mountain
#

async cant interfere on sync scope

earnest phoenix
civic scroll
#

i can't read

lyric mountain
#

blue and red can't exist at the same time

#

not without await

vivid fulcrum
#

there's no need for that to be async either

#

also there's literally find() 💀

earnest phoenix
lyric mountain
#

[ original msg deleted ]

then none fulfills that condition

earnest phoenix
#

but still returns undefined

#

but the console log returns the object

vivid fulcrum
#

use find()

#

map is for mapping
find is for finding

lyric mountain
#

then u go to php and explode()

civic scroll
#
export const findFriendlyChannel = (guild) => {
    for (const channel of guild.channels.cache)
    {
        const hasPermission = (permission) => channel.permissionsFor(client.user).has(permission);
        if (channel.type === "GUILD_TEXT") 
            if (hasPermission("VIEW_CHANNEL") && hasPermission("SEND_MESSAGES")) 
                return channel;
    });
}
civic scroll
#

my take on it

vivid fulcrum
#

can be a one liner 🙃

civic scroll
#

yeah

#

but yk

#

my brain on 1am

#

also callbacks are slower

earnest phoenix
#

so do I use find, for loop or my mapping

civic scroll
lyric mountain
#

you're not mapping anything

#

you're searching for a matching entry

civic scroll
vivid fulcrum
#

true but not noticable unless the guild has a hundreds of thousands of channels

civic scroll
#

but for readable you can use array.find

earnest phoenix
lyric mountain
#

map is like const mapped = <array>.map(elem => "amogus")

civic scroll
#

also

#

pointless var assignment

#

you return on first channel found

#

no need for looping entire thing

civic scroll
lyric mountain
earnest phoenix
#

ok im using .find

civic scroll
#

for iteration, array.forEach exists

vivid fulcrum
lyric mountain
#

reduce returns a minecraft piston 👍

solemn latch
#

oo, good to know

civic scroll
lyric mountain
#

what is i?

elfin tulip
#

interaction

#

oh.

lyric mountain
#

yk, that's why rubberducking works

#

In software engineering, rubber duck debugging (or rubberducking) is a method of debugging code by articulating a problem in spoken or written natural language. The name is a reference to a story in the book The Pragmatic Programmer in which a programmer would carry around a rubber duck and debug their code by forcing themselves to explain it, l...

elfin tulip
#

Yeah but the problem is with message.createMessageComponentCollector()

lyric mountain
#

what abt it?

#

I mean, is ur filter right? try adding a console.log inside it to see if it is collecting

elfin tulip
#

message is not defined

lyric mountain
#

did u declare message?

#

const message = ...

#

or something

elfin tulip
#

Its a reply

lyric mountain
#

where do u declare it?

#

ur not declaring it

#

that'd be const message = await interaction.reply(...)

#

if it does return a message

elfin tulip
#

I want to add collector to this replied message.

#

oh

lyric mountain
#

quack

civic scroll
#

quack

#

fr