#development

1 messages · Page 1827 of 1

grim sundial
#

obviously

quaint rampart
#

ty

stray seal
#

On replit, how do i make it where it "Auto Fills" to help me?

drifting wedge
#

So I'm using nginx, cloudflare and flask, how do I add subdomains?

earnest phoenix
#

Just make a regular A record ASWaitWhat

drifting wedge
#

yeah but how do I add it

earnest phoenix
#

CF DNS settings banter

drifting wedge
#

bruh

#

I've tried that

#

But like with flask

#

and nginx

#

I know how to add it to the dns lmao

earnest phoenix
#

The framework you use doesn't change your server setup

wheat mesa
#

Yeah, it’ll yell at you for a lot of things

#

But personally I love typescript

drifting wedge
#

Yeah but how do I implement it

narrow bloom
#

is there any copyright on discord? Because i made a bot called Linkin Park 24/7 and it plays songs of the band 24/7. Am i allowed to publish such a bot?

earnest phoenix
#

You need to add new files in sites-available

drifting wedge
#

Yeah but then how do I add them into flask

#

Dude I've googled this all like 100 times lol

crimson vapor
#

Don’t ask me idk

sudden geyser
# narrow bloom is there any copyright on discord? Because i made a bot called Linkin Park 24/7 ...

You're responsible for the content you upload to Discord. If you play a song from a band and don't have the rights to, you're violating the ToS.

User content in the ToS:

Any data, text, graphics, photographs and their selection and arrangement, and any other materials uploaded to the Service by you is “Your Content.” You represent and warrant that Your Content is original to you and that you exclusively own the rights to such content, including the right to grant all of the rights and licenses in these Terms without the Company incurring any third party obligations or liability arising out of its exercise of such rights and licenses. All of Your Content is your sole responsibility and the Company is not responsible for any material that you upload, post, or otherwise make available.

Content as per the developer terms:

While we may sometimes review content to determine whether it is illegal or violates our policies or the Terms, and we may remove or refuse to display content, we make no representations or warranties about the content, its appropriateness, legality, pedigree or other details. Finally, content accessible through our APIs may be subject to intellectual property rights, and, if so, you may not use it unless you are licensed to do so by the owner of that content or are otherwise permitted by law.

narrow bloom
#

ok thanks

split hazel
#

obviously music bots are exempt since one of the largest bots are music bots/have some kind of music command

#

even though they stream copyrighted content regularly

#

my stance on such a topic is either remove that entire term or enforce it upon everything

sudden geyser
#

Music bots violate YouTube's ToS.

#

They've always been a gray area.

earnest phoenix
#

how delete data

sudden geyser
#

But people don't really care.

earnest phoenix
#

I failed

sudden geyser
#

And Discord just says "we're not liable"

#

(plus they get that perk)

stray seal
earnest phoenix
stray seal
stray seal
copper cradle
#

You forgot a ","

earnest phoenix
#

"token":"ssss",
"sss":""

copper cradle
#

Also u just leaked your token

earnest phoenix
#

meanwhile create a new token

stray seal
#

ok

stray seal
quartz kindle
earnest phoenix
#

azsrxdtcyvgu

earnest phoenix
quartz kindle
#

first of all, users.keys is an array

#

to remove an item from an array you have to use array.splice

#

google array.splice

#

second of all, you are reading from a json file

#

so every time you change, you have to write the json file again

stray seal
#

Where did i mess up?

quartz kindle
#

otherwise ihe change will not be saved

quartz kindle
eternal osprey
#

hey! Did the oauth2 uri change?

quartz kindle
#

please learn some js

wheat mesa
# sudden geyser Music bots violate YouTube's ToS.

They do, but I YouTube doesn’t take action against people that run bots like that, probably either because they don’t want to spend the money on legal fees, or because it doesn’t make a noticeable hit to their revenue. (Plus other solutions like IP blocks are far cheaper than legal action)

eternal osprey
#

const uri = `http://${hostName}:${port}/auth/discord/callback`;

wheat mesa
#

Learn js before making a bot

quartz kindle
#

i mean what ae you trying to do in that specific code

#

lol

wheat mesa
#

Makes life a lot easier

quartz kindle
#

you seem to have zero idea of what you are doing

stray seal
quartz kindle
#

why did you put ["ping", "test"] there?

#

what did you expect it would do?

wheat mesa
#

Also you might wanna regen your token after posting a screenshot of it

wheat mesa
#

Alright good

stray seal
#

I could just do this:

eternal osprey
stray seal
#
js
const Discord = require('discord.js')
const client = new Discord.Client()

const config = require('./config.json')
const command = require('./command')

client.on('ready', () => {
    console.log('The client is ready!')

    command(client, 'ping', message =>{
        message.channel.send('Pong!')
    })
})

client.login(config.token)
lyric mountain
#

methinks, is posting the token a reliable way of force-resetting it?

#

it'd be a great way of emergency procedure let your token ever be stolen

#

since going through all the discord dev pages takes a lot of time

modest maple
sudden geyser
stray seal
#

Can someone help me who is nice and not rude about me coding?

eternal osprey
wheat mesa
sudden geyser
#

Yeah

#

Which is where music bots pretty much sit

stray seal
#

Can some DM me to help me? I answer quicker in DM

sudden geyser
#

It's better you ask your question here.

brave tendon
#

hihi

quartz kindle
#

pls learn some js

earnest phoenix
#

@quartz kindle

#

how exactly do i delete the data i want

primal plinth
#

Hey, how can I make someone vote for my bot to send a notification?

quartz kindle
earnest phoenix
#

normally "splice(1,1)"

primal plinth
earnest phoenix
earnest phoenix
#

I learned to delete

stray seal
earnest phoenix
quartz kindle
primal plinth
quartz kindle
stray seal
stray seal
quartz kindle
#

you have to find the index of the item you want to delte

quartz kindle
#

you mean the video or what?

earnest phoenix
#

for example how can i get the index of the middle data

stray seal
quartz kindle
#

you can use for example array.findIndex()

earnest phoenix
#

ups

#

😄

quartz kindle
#

sorry, i dont agree with that statement. i dont think that video is one of the best code places

#

the best code places are the places where you learn how to code, for example codecademy, or udemy

earnest phoenix
#

I will learn slowly (I hope)

quartz kindle
#

then why does your code not work?

stray seal
#

Want me to show you the video?

quartz kindle
#

the video does not teach you how to code

#

you're just copying stuff from the video

#

also, what you did to your code is not in that video

#

you're doing things that are not according to the video

#

and the video does not teach you how to do things that are not in the video

#

amd i wrong?

stray seal
#

I am blocking you

earnest phoenix
#

@quartz kindle finish

sudden geyser
#

If you want to learn programming, YouTube videos won't get you far.

quartz kindle
#

i am trying to help lol

earnest phoenix
#

@quartz kindle thx

earnest phoenix
quartz kindle
# stray seal I am blocking you

what do you want me to say then? you're not doing what the video says, and then complaining that it doesnt work. well it doesnt work because you didnt do what the video says?

#

they hated him for he spoke the truth

earnest phoenix
#

you are a real savior Tim

earnest phoenix
normal comet
#

Does anyone know a good place to advertise a bot

lyric mountain
grim sundial
#

i've been searching for a while now, and im unsure how i am supposed to get the clients users

errant flax
grim sundial
#

can someone point me in the direction of this please, im not using a library

wheat mesa
#

You're interacting with the raw api, right?

grim sundial
grim sundial
errant flax
#

dont think u can do that with the api

grim sundial
#

wut

copper cradle
#

U can literally do that

copper cradle
errant flax
#

i dont know ok bonk

wheat mesa
#

Probably shouldn't say that if you don't know

errant flax
#

thats why i said "dont think" but :thumbs_up:

grim sundial
#

i've even listened to all events, with every packet which is coming in. i've looked through all the data and i've not seen any users

#

maybe i missed it im not sure

quartz kindle
#

which users?

#

you mean guild members?

grim sundial
#

nop, users

#

all users which share a mutual guild as the client

quartz kindle
#

there is no such thing

#

there is guild members

#

and members are linked to to users

#

users have no link to any guild

grim sundial
#

wait one sec

#

oh, yeah i see now.

#

thank

sinful belfry
#

anyone else had issues using erlpack on worker threads? i keep getting this error:

Error: Module did not self-register: '\\?\C:[file path]\node_modules\erlpack\build\Release\erlpack.node'.

when trying to create multiple worker threads (one worker thread works fine tho)

quartz kindle
#

i heard somewhere that NAN needs some special shit to work with threads, while N-API doesnt

#

erlpack uses NAN instead o N-API

sinful belfry
#

ah ic

#

is this "special shit" difficult to add/use, or is there an alternative to worker threads which would make it work?

quartz kindle
#

it would be something related to the C++ code in the lib

#

you can also try rebuilding

#

this error also happens when the build failed

sinful belfry
#

yea gave that a go, didnt seem to make a difference

#

probably dont wanna touch the c++ code

quartz kindle
#

the only alternative to worker threads is child process

sinful belfry
#

is a child process more powerful than a worker thread?

sly sierra
quartz kindle
#

has all the properties of a standalone node.js program

#

(and bloat)

sinful belfry
#

ah makes sense

#

ty will give it a go

quartz kindle
#

weird that this doesnt seem to affect some people, im pretty sure people have used erlpack in threads before

#

could be also related to node.js version

#

NAN is whack

sinful belfry
sinful belfry
thorny flume
#

I'm wanting to make a 10 second tag system to identify if my bot is online or not, but I'm not sure if I do this tag, how can I identify this tag and send the response to the api saying if the bot is online or not?

quartz kindle
#

In order to be loaded from multiple Node.js environments, such as a main thread and a Worker thread, an add-on needs to either:

Be an Node-API addon, or
Be declared as context-aware using NODE_MODULE_INIT() as described above

bright thorn
bright thorn
lyric mountain
#

code, we need the code

#

no code no help

sinful belfry
#

this is supposed to be somewhere within the erlpack module code?

quartz kindle
#

thats in /js/erlpack.cc

sinful belfry
#

ah yeah got it

quartz kindle
#

although this will only work if erlpack doesnt use global variables

sinful belfry
#

and NODE_MODULE_INIT

quartz kindle
#

did you rebuild?

sinful belfry
#

oh no

#

hang on lemme try

sinful belfry
#

tysm

#

yup got 4 threads running fine

quartz kindle
#

ayy

#

lmao i just saw this

#

pending pr since 2020

crimson vapor
#

fun

sinful belfry
crimson vapor
#

is tim breaking any more rules, Starman?

sinful belfry
#

i dont think anyone even checks that repo

#

of course

crimson vapor
#

ok

#

just making sure

quartz kindle
#

im always breaking rules

#

i broke every single rule with djs

crimson vapor
#

with context it isnt very funny but I think this will be super funny on starboard

quartz kindle
#

xD

crimson vapor
#

me when I realize discord.js-light is just prototype pollution

quartz kindle
#

there is only one pollution

#

the forge methods

crimson vapor
#

forge isnt a real thing???

quartz kindle
#

thats the pollution

#

lmao

crimson vapor
#

why isnt forge a real thing???

#

it seems like such a good idea

quartz kindle
#

djs dont like partials

crimson vapor
#

if you can just be like
const maybeAGuildIDontKnow = client.guilds.forge({ id: "180112943612952577" })
maybeAGuildIDontKnow.leave().catch(() => { console.error("Not a guild!") })

quartz kindle
#

ye

#

djs dont like possible api errors with invalid ids

#

also, i have a new type of pollution now

#

require cache pollution

#

:^)

crimson vapor
#

what do you do there?

quartz kindle
#

require.cache[path].exports = class extends require.cache[path].exports {}

#

:^)

crimson vapor
#

wait a fucking minute

#

wh

#

so basically

#

you said fuck you to Structures and did that shit?

quartz kindle
#

yup

crimson vapor
#

ok

#

does djs 13 have cache control or only djs next?

quartz kindle
#

it has

crimson vapor
#

so is djs-light reaching its end?

quartz kindle
crimson vapor
#

v13??

quartz kindle
#

yes

crimson vapor
#

so like 0 false 1 true?

quartz kindle
#

no

#

0 is no cache

#

N is max items in cache

crimson vapor
#

uhh

quartz kindle
#

ex MessageManager: 200

crimson vapor
#

thats gonna cause issues when someone sets it to like GuildsManager: 5

quartz kindle
#

yup

crimson vapor
#

thanks djs

#

very helpful

quartz kindle
#

thats not the only issue

#

half of those make events not fire anymore

crimson vapor
#

list the issues

quartz kindle
#

even with partials enabled

crimson vapor
#

djs really hates partials that much?

quartz kindle
#

because "missing data"

#

yup

crimson vapor
#

xD

quartz kindle
#

so djsl will still exist for a bit longer

#

to fix all the events

crimson vapor
#

djs does all that yet it doesn't ship with a real command handler

#

like what

quartz kindle
#

who cares

#

people should make their own handlers

crimson vapor
#

I mean

#

not really

quartz kindle
#

yes really?

crimson vapor
#

if they want they should be able to absolutely

quartz kindle
#

people dont need that much babysitting

crimson vapor
#

but no reason to code something if its already done for you

crimson vapor
quartz kindle
#

yes, fuck those people

crimson vapor
#

ive never been there actually

quartz kindle
#

lmao

crimson vapor
#

I just assume its worse than here

quartz kindle
#

but i mean

#

ever seen a webserver package with built in renderer or page handler?

#

there comes a point where you should probably stop making built in things

crimson vapor
#

ehhh

#

hmm

quartz kindle
#

it just makes bloat

crimson vapor
#

I think a command handler built in would still be nice

#

like not commando

#

that shitty help command

#

in DMS

#

WHY

#

WHY DMS

quartz kindle
#

i think its still better done in a separate package

crimson vapor
#

perhaps

#

or maybe like included but not forced

#

so you can do like js const { CommandClient } = require('discord.js') and it would have the command handler built in

quartz kindle
#

like detritus

#

still too much bloat to me

crimson vapor
#

but it would just be likejs class CommandClient extends Client { commands = new CommandHandler(this) }

crimson vapor
quartz kindle
#

a raw websocket :^)

crimson vapor
#

ok

quartz kindle
#

btw

#

djs just added this

crimson vapor
#

what in the world

quartz kindle
#

basically customizable auto sweeping caches

crimson vapor
#

so thats good?

quartz kindle
#

looks way overcomplicated to use tbh

#

but yes, more options more good

#

now if only they would fix the events

#

djsl would be dead

#

but they dont fix

crimson vapor
#

you could just use the raw events and the forge method

#

ez

quartz kindle
#

sure

#

anyway

#

nobody cares about any of this anymore

#

with the slash command thing

crimson vapor
#

typescript would go crazy but it would work

#

oh right

#

its time for someone to create a new default shitty command handler for slash commands

#

or port over the old one

#

because thats what people do :)

quartz kindle
#

im gonna make an interactions webhook server

crimson vapor
#

and by new default I mean the first google search

sly sierra
#

I had to make a new command handler very cool HuTaoCry

crimson vapor
#

I did not have to make a new command handler because I already had a slash command handler made

ruby vine
#

Someone knows how to do this works?


megaConst = const;
ruby vine
#

Look

sly sierra
#

we are looking

crimson vapor
#

what

#

oh reassigning

#

use let

#
let x;
console.log(x); // undefined
x = 1;
console.log(x); // 1
x = 2;
console.log(x); // 2```
nova bone
#

hi, i'm making a programming language with @ruby vine. Just that i have a question, i would like to make a variable name like var or const, in the name that i want, example

Programming languaje original:

var variable = value

My programming language:

myname [variable] = [Value]

#

i just maked the rest of the language

#

but i just need to make that and i'll finish

ruby vine
#

yeah

#

x2

quartz kindle
#

oh

crimson vapor
#

oh

#

you need to specify that

sly sierra
#

The annoying thing I'm trying to stop is whenever a guild hasn't invited my bot with bot and application.commands will give me a Missing Access error per guild so now i'm left with a messy terminal

crimson vapor
#

idk anything about cpp but define maybe?

nova bone
#

How can i help someone

#

hi, i'm making a programming language with @ruby vine. Just that i have a question, i would like to make a variable name like var or const, in the name that i want, example

Programming languaje original:

var variable = value

My programming language:

myname [variable] = [Value]
i just maked the rest of the language
but i just need to make that and i'll finish

nova bone
#

no one answered

long crow
#

If I shared my github repo for discord bot here, anyone willing to review it? Doubt it though

long crow
#

opinion and what I missed out, improvement, future proof, code quality

#

kinda stuff

round cove
#

Uh, I can try but no promises. JS/TS?

long crow
#

js

round cove
#

Cool

long crow
#

be my guest if you want to look into it

round cove
#

Lemmie lookie

long crow
#

Glorious ping

rocky hearth
#

what is p flag here, tsc -p?

gusty bone
#

When i connect a card to my heroku, will I have to pay anything (besides the verification fee) to claim the dyno hours? just making sure.

copper cradle
#

No

lament rock
#

follows imports iirc

bright thorn
bright thorn
gusty bone
vale garden
#

hi

#
        m = await ctx.send("<Poll Stuff...>")

        if op1:
            await m.add_reaction(resources.a_m)

        if op2:
            await m.add_reaction(resources.b_m)

        if op3:
            await m.add_reaction(resources.c_m)

        if op4:
            await m.add_reaction(resources.d_m)

        if op5:
            await m.add_reaction(resources.e_m)

        print(m.reactions)
#

so i have this

#

and the reactions get added

#

but on printing the reactions i get an empty lis

#

*list

#

can someone help?

ripe prairie
#

send the full code

#

@vale garden

wanton flicker
#

is there a way to get all the users from a server that the bot is in

ripe prairie
#

for members in guild

#

input to list

#

print list

wanton flicker
#

ok thanks :D

ripe prairie
#

you need to have members intent enabled and declared

#

assuming you're using d.py

wanton flicker
#

so like this?

#
   for i in client.guilds:
        for member in i:```
ripe prairie
#

no

pearl void
#

wai

wanton flicker
pearl void
#

@wanton flicker

#

{sum(a.member_count for a in self.client.guilds)}

#

i use cogs

#

so i did self.client.guilds

#

but if you dont use cogs

wanton flicker
#

i use cogs :D

pearl void
#

{sum(a.member_count for a in client.guilds)} <- then do this

wanton flicker
#

wait, what does this do

#

i want a list of all the members

pearl void
#

YES

ripe prairie
#

gives you the total number of users in all the guilds

#

your bot is in

pearl void
#

thats what it does

#

yea

wanton flicker
#

not the number

#

but the username??

ripe prairie
#

then remove sum

#

and use a list or tuple

pearl void
#

yea

wanton flicker
#

ah ok.

pearl void
#

remove sum and use list

wanton flicker
#

okok

ripe prairie
#

also you don't wanna use member_count

wanton flicker
#

hm?

#

what would i use then

ripe prairie
#

with a.member_count

#

that'll just give you the number of users in each guild

wanton flicker
#

a.members?

ripe prairie
#

yes

#
l = []
b = []
for a in bot.guilds:
  l.append(a)

print(l[1].members)
wanton flicker
#

why l[1]?

#

also i dont get why my bot is in a server with 250 members 🤔

#

btw this prints out the server, not the members?

#

stuff like this:[<Member id=863419048041381920 name='MaxiGames' discriminator='6440' bot=True nick=None guild=<Guild id=867792589847396362 name='Limey Hub' shard_id=None chunked=False member_count=14>>]

earnest phoenix
#

hey like i have this code

app.post('/voted', webhook.listener(vote => {
  let channel = client.channels.cache.get('870337356207648788')  //vote log channel id
  let user = client.users.cache.get(vote.user)
  channel.send(`<@${user.id}> has Voted for ${client.user.username}!`)
})) 

it doesnt mentions the user
i tried <@, <@!,<!@

#

all dont work

pale vessel
#

Why bother getting the user that might not even be cached

#

<@${vote.user}> ...

earnest phoenix
#

is just sends like this format

solemn latch
#

<@id>

#

Not <@!id>

solemn latch
#

Does your bot have the ability to mention?

craggy pine
#

Also, it will always look like that if the user is not apart of the discord server the bot is posting that in.

earnest phoenix
earnest phoenix
craggy pine
#

ik im just saying ig

#

once it's working and all.

#

We basically cached usernames for people who used the bot and if their ID matches just say <user> has voted.

#

db junk tho

earnest phoenix
#

brr okh

delicate shore
#

hey everyone

#

what library is best in nodejs

#

for training an ai chatbot

wispy yoke
#

ayy youre PCGamerX

#

nice to meet you

#

i use your api for my bot

#

(if youre the real pcgamerx that is)

delicate shore
#

thanks, also im just PGamerX not PCGamerX

#

and yes I am real one

wispy yoke
#

o, imagine me not knowing your name correctly facepalm

bleak jungle
#

hi

lucid prawn
#
client.on('channelDelete', (channel) {
 if (message.member.hasPermission("ADMINISTRATOR")) return console.log('THIS USER HAS ADMINISTRATOR PERMISSIONS!')
  channel.clone()
    .then((clone) => {
        console.log(`Cloned ${channel.name} to make a channel called ${clone.name}`);
    })
    .catch(console.error);
});

how can I define message?

craggy pine
#

If they're deleting a channel, there is no message.

lucid prawn
craggy pine
#

I get that. But is this a command being ran or just the event of a channel being deleted? Reading the code, there is no indication of a sort of command running first.

lucid prawn
#

sorry for the ping

#

just the event of a channel being deleted It will be connected to a command the command will grab the level the user is then let them use it or not

craggy pine
#

Gotcha. I'm not really the guy to assist with this but was wondering because in the context of the code block you sent, of course message would be undifined because just deleting a channel, there is no message.

lucid prawn
#

umm

#

could I make it run I different event before run that one?

flint acorn
#

Hello
Can I keep myself online using a VPS?

solemn latch
#

probably

rocky hearth
flint acorn
errant flax
#
module.exports = {
  type: "interaction",
  run:async(client,i,cache)=>{
    if (!i.isButton()) return
    if (!i.customId.startsWith("ticket")) return
    console.log("hello")
    const schema = cache.schema.get("ticket.js")
    const channelId = i.channelId
    const data = await schema.findOne({channelId:channelId})
    const channel = i.guild.channels.cache.get(data.channelId)
    const members = data.members
    if (!data) return
    const split = i.customId.split("&").slice(1)
    const action = split[0].slice(`act=`.length)
    if (action==="lock") {
      let val = split[1].slice("val=".length)
      val==="true" ? val=true : val=false
      let i = 1
      if (val===true) {
        const msg = await i.message.fetch()
        unlockLoop(channel,members,i)
        const components = msg.components
        const btn = components[0].components[0]
        btn.setCustomId("ticket&act=lock&val=false")
        btn.setEmoji("🔒")
        msg.edit({
          components: components
        })
      } else {
        const msg = await i.message.fetch()
        lockLoop(channel,members,i)
        const components = msg.components
        const btn = components[0].components[0]
        btn.setCustomId("ticket&act=lock&val=true")
        btn.setEmoji("🔓")
        msg.edit({
          components: components
        })
      }
    }
  }
}
rocky hearth
errant flax
#

oh ye

#

fuck

vale garden
# ripe prairie send the full code

its huge but here it is

# resources.py

async def constructor(*args, **kwargs):
  embed = discord.Embed(
    title=clean_none(kwargs.get("title")),
    description=clean_none(kwargs.get("description")),
    color=kwargs.get("color"),
  )

  embed.set_thumbnail(url=clean_none(kwargs.get("thumbnail_url")))
  embed.set_image(url=clean_none(kwargs.get("image_url")))

  embed.set_author(name=clean_none(kwargs.get("author_name")), icon_url=clean_none(kwargs.get("author_icon_url")))
  embed.set_footer(icon_url=icon, text="evil e-girl!")

  if kwargs.get("field_names") is not None:
    for name, value in zip(kwargs.get("field_names"), kwargs.get("field_values")):
      embed.add_field(name=name, value=value, inline=kwargs.get("inline"))

  return await kwargs.get("ctx").send(content=clean_none(kwargs.get("content")), embed=embed)

rocky hearth
#

and also val==="true" ? val=true : val=false is equivalent to val = val === "true" @errant flax

#

or let val = split[1].slice("val=".length) === "true"

errant flax
#

too lazy to change dog_kek

errant flax
#
const color = cache.jsonFiles.get("colors.json").default
      const emb = new MessageEmbed()
      emb.setColor(color)
      emb.setDescription("Support will be here shortly.")
      const lockBtn = new MessageButton()
      lockBtn.setStyle("SUCCESS")
      lockBtn.setEmoji("🔒")
      lockBtn.setCustomId("ticket&act=lock&val=false")
      const unlockBtn = new MessageButton()
      unlockBtn.setStyle("SUCCESS")
      unlockBtn.setEmoji("🔓")
      unlockBtn.setCustomId("ticket&act=lock&val=true")
      const closeBtn = new MessageButton()
      closeBtn.setStyle("DANGER")
      closeBtn.setEmoji("🗑️")
      closeBtn.setCustomId("ticket&act=close")
      const openBtn = new MessageButton()
      openBtn.setStyle("DANGER")
      openBtn.setEmoji("📂️")
      openBtn.setCustomId("ticket&act=open")
      const row = new MessageActionRow().addComponents([lockBtn,unlockBtn,closeBtn,openBtn])
      c.send({
        content: `<@${msg.author.id}>`,
        embeds: [emb],
        components: [row]
      })

??

cinder patio
#

place the unicode emojis in the label

errant flax
#

smart

cinder patio
#

.setLabel("emoji");

wheat mesa
#

You sure? I use this (for detritus, should still be the same though) for buttons:

new ComponentButton().setCustomId(':rewind:').setEmoji('⬅️').setLabel('Previous'),
new ComponentButton().setCustomId(':fast_forward:').setEmoji('➡️').setLabel('Next'),
#

etc etc

#

I think discord just doesn't recognize one of the emojis he's using

#

📂️ this one

#

Since there's nothing in the emoji selector associated with it

#

🔒
🔓
🗑️
📂️

errant flax
#

label was a fix shrug

earnest phoenix
#

hi yall, so bot was running perfectly but today bot returned an error when i tested some commands, this is the error UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions i gave bot every permission it needs

cinder patio
#

the discord documentation says that the emoji field must be a partial emoji, so it's the libraries that allow strings and just concentrate them to the label text

wheat mesa
#

Ah

wheat mesa
earnest phoenix
#

nvm it required administrator

wheat mesa
#

Just so you know (if you ever plan try to get your bot verified on top.gg)

earnest phoenix
#

i just use my bot myself and friends :))

#

i joined this server cuz sometimes i cant find my problem's answer on stackoverflow

#

anyone know how i could do this?

errant flax
#

wdym?

#

the vote or the fun fact cmd?

#

if the vote thing #topgg-api
if the command they probably used an api

long crow
#

Using vote to content lock is so low

wary flame
#

There's an npm package with hardcoded facts iirc

earnest phoenix
errant flax
earnest phoenix
tardy hornet
#
message.channel.awaitMessages(filter, {
    max: 1000,
    time: 10000
  }).then(collected => {

    if(collected.content === `${array2[Random2]}`){
      const damnlad = new Discord.MessageEmbed()
      .setDescription(`${message.author} damn that was fast, ggs on getting that 7k`)
      .setColor("GREEN")
      db.add(`money_${message.author.id}`, 7000)
      message.channel.send(damnlad)
  return}
  if(message.content !== `${array2[Random2]}`){
  message.channel.send('e')
return}

i am trying to do that when a user sends the array2[Random2] it will send the damnlad embed but if he does not it wont do anything till he sends the right thing

quartz kindle
#

you are waiting for a fixed 10 seconds, regardless if the user sent the right message

#

and collected is a collection

#

there is no collected.content

#

you have to find it in the collection

#

depends

#

if you need help with a specific part of it, maybe we can help

#

if you have no idea where to start, then no, we cant do it for you

#

that doesnt change what i said lol

vivid spoke
#

OK

quartz kindle
#

why did you delete the question lmao

cinder patio
#

day 2 of deciding what to use to make my documentation generator

#

I think I'll use handlebars tbh.

#

detritus

quartz kindle
#

djs v13 as well

cinder patio
#

wait a min handlebars is 3MB unzipped. Ok. So it seems like I can't get away with the size

#

I'll have to make people download bloat

errant flax
quartz kindle
#

ye

cinder patio
#

At this point it's react vs handlebars and I think I'm gonna go with handlebars because the react ecosystem is... eh... in order to make react work I'll need webpack, babel, all that shit

quartz kindle
#

you didnt like the razor thing?

cinder patio
#

It hasn't been updated in 3 years that's the only reason

#

the syntax is better than handlebar's

quartz kindle
#

1 year iirc no?

#

let me check

eternal osprey
quartz kindle
#

well last update mas march 2020

#

but most of the files are 7-8 years old lol

cinder patio
#

yup

eternal osprey
quartz kindle
cinder patio
#

they're all the same thing essentially

quartz kindle
#

well yeah

#

but different syntaxes and size

cinder patio
#

true

pure lily
#

Request failed with status code 400 lavalink error with spotify playlist, is this because of the lavalink node or the bot's code?

quaint wasp
#

this is probably false, but is it possable at all to track your console from code? Like to make it see that is something logs, it would do something with the data?

quartz kindle
#

nope

quaint wasp
#

aww

quartz kindle
#

logs are send to stdout

#

once they are sent, they are gone from the program

#

what you can do is extend the log function

#

so that is saves somewhere before sending

quaint wasp
#

indeed..

cinder patio
#
    console.log(...things);
    process.emit("log", ...things);
}```
quartz kindle
#

that would kill it lol

cinder patio
#

oop

quaint wasp
#

whats emit? does it save or something?

quartz kindle
#

xD

#

process is an event emitter

#

you can emit stuff and listen to them with process.on("stuff")

quaint wasp
#

oh

#

basicly just like

client.on("event name", () => {
// stuff
})``` ?
quartz kindle
#

yes

cinder patio
#
console.log = function(...things) {
    process.stdout.write(things.join(" ") + "\n");
    process.emit("log", ...things);
}
quartz kindle
#

well, you could do that

#

but a better way would be to store the reference somehwere

#

like console.log2 = console.log;

#

then replace it and call log2 inside it

cinder patio
#

ye

summer torrent
feral aspen
#

Hey.

#

Is it only me who's experiencing trouble pressing enter when typing !help, it's like wanting me to press it 4 times for it to send, unlike normal messages requiring once.

rigid maple
#

Hello, I need help with an issue.
I want to enlarge/reduce the dimensions of a text as scaleX and scaleY or heigth and width
but I couldn't see anything like that in the ctx.fillText part of the canvas

#

What I want to do is:
ctx.fillText(text, height, width, x, y)
or
ctx.fillText(text, scaleX, scaleY, x, y)

#

their order may change, that's okay

#

used Translate

earnest phoenix
#

can some one help with the post stats

quartz kindle
#

you have 2 options:

  1. calculate font size from scale
  2. fillText in another canvas, then ctx.drawImage(othercanvas) with all the scaling parameters
earnest phoenix
#

i cant fix the error of it not contecting

rigid maple
#

Secondly, since I send the text as ctx.fillText, I don't know how to turn it into a picture.

#

used Translate

quartz kindle
#

you can draw one canvas inside another canvas

#

so canvas1 ctx.fillText()
canvas2 ctx.drawImage(canvas1)

#

with drawImage you can scale

rigid maple
#

but i won't do just one

#

about 7-8

#

maybe more

quartz kindle
#

are they all in different scales or the same scale?

rigid maple
#

Will this cause any performance loss?

#

Since the scales are set by the user, they can all be different or the same.

quartz kindle
#

there is a bit of performance loss yes, but its not a lot

#

so you want the user to be able to increase font size?

#

cant you just do it with ctx.font = ${size}px?

#

so you can stretch and stuff?

rigid maple
#

yes

quartz kindle
#

then no, you have to use the drawImage method

rigid maple
#

thank you so much

#

❤️

eternal osprey
#
 let guildMember = message.guild.members.find(guildmember => guildmember.id === user.id);
                return new Player(board, user.id, guildMember.displayName, avatar, 2000, 0, 0, false, []);
```. TypeError: Cannot read property 'displayName' of null
near stratus
#

check if guildMember is not null

eternal osprey
#

using a simple console.log?

#

Sure. One sec.

quartz kindle
#

what version is that?

#

shouldnt it be guild.members.cache.find()?

pale vessel
#

cache.get() too

eternal osprey
#

owh wait shit i ofc updated my djs

#

is there any other way to directly see my djs version instead of npm list

#

as i have lots of modules installed

quartz kindle
#

console.log(Discord.version)

#

if you have an eval command

eternal osprey
#

discord.js@11.6.4

quartz kindle
#

oh lord

#

that version is like 4 years old

#

and its pretty much broken

earnest phoenix
near stratus
eternal osprey
#

mhmm, i am running on the latest version with all of my other bots. Just need to update this one.

#

Might do it now i guess.

#

Will talk to you guys once it's done

earnest phoenix
#

d.js v11

eternal osprey
rocky hearth
#

ive generated, tsdoc in doc folder. Do I hv to push this folder to github, in order to host the docs on github pages?
or github I can configure it so, it could be auto generated and hosted?

long crow
#

context menu, look interesting

pale vessel
#

Hey that dude got banned here

#

Wait is that you

#

I hope that's not you

long crow
#

nah

#

look similar but not same person

pale vessel
#

Ah

earnest phoenix
#

How do i get server invite with discord js

#

Like when i said server info it will create unlimited invite link and will add to embed (i need only create invite part)

clever agate
earnest phoenix
#

Yes it has

clever agate
#

and what programming language do you say?

earnest phoenix
#

Discord js

clever agate
#

okeh...

#

wait....

earnest phoenix
#

Okay

clever agate
#
message.channel.createInvite({maxAge:0, maxUses:0}).then(iv => {
      console.log(iv.url);
});```
clever agate
dim lance
#

Im trying to get the webhook working, but i dont really understand how to get the domain... Im running this on my pc for now

const webhook = new Top.Webhook('hereThePsw');


webhook.login('what should i put here? /topggVote', '3000'); //you can edit the port (only numbers) NOTE: PUT .login METHOD BEFORE THE .on('vote') METHOD

webhook.on('vote', vote => {
  console.log(`User id: ${vote.user}\nAll data: ${vote}`);
});
#

is this the right channel btw?

pale vessel
dim lance
#

ok ty ill ask there

clever agate
long crow
#

Anyone here hosting on ovh vps?

modest maple
#

you mean when it's not on fire?

#

sorry, bad joke

summer torrent
#

lmao

slender thistle
#

that's a hot take

sudden geyser
#

google cloud

long crow
#

Ha Ha Ha

#

Ya Funny, thank you for the answer

earnest phoenix
sudden geyser
#

It returns a promise, so whatever you want to do with it is up to you

#

You could use async/await, convert it to a callback, or not even bother to resolve it. But if you want the actual invite, you need to resolve it somehow.

earnest phoenix
#

dose any one know how to make your bot page look good

#

?

sudden geyser
#

depends on what you consider good

#

You can use HTML and CSS in the long description

#

I like bots that keep to using regular Markdown

earnest phoenix
sudden geyser
#

What do you mean outdated?

earnest phoenix
#

they dont work for me so they might be to old

sudden geyser
#

Can you show what you're doing

earnest phoenix
#

just had to restert

#

i follow yt vid

sudden geyser
#

do you know css

earnest phoenix
#

no

sudden geyser
#

then let's start there

earnest phoenix
#

and not much html

rocky hearth
#

then learn the basics, dont just directly jump into the void

ornate arch
#

this is only for Discord bot development?

solemn latch
#

Nope. Can be other stuff too

nocturne grove
#

I'm getting used to the new slash commands. I figured out how I can respond, but I want to respond with a deferred response. How can I do that? Discord.js

#

I've got this now, but that's not working:

client.ws.on('INTERACTION_CREATE', async interaction => {
    client.api.interactions(interaction.id, interaction.token).callback.post({data: {
        type: 5
    }});

    setTimeout(() => {
        client.api.interactions(interaction.id, interaction.token).callback.patch({ data: {
            type: 4,
                embeds: [ new Discord.MessageEmbed().setTitle('hello world!')]
            }
        });
    }, 5000);
});```
ornate arch
#

anyone has a good option for a CI that can automatically push from a GitHub repository and are free to run nunit tests from DotNet CLI?

nocturne grove
#

oh my problem is solved. The deferred response is the same as a follow-up message:

setTimeout(() => {
    new Discord.WebhookClient(client.user.id, interaction.token).send('hello world');
}, 5000);```
carmine adder
#
await category.AddPermissionOverwriteAsync(Context.Guild.Roles.First(xa => xa.Name == "ERP Bot"), OverwritePermissions.DenyAll(category).Modify(manageChannel: PermValue.Allow));

I get The server responded with error 403: Forbidden error but my bot has permissions. What's the problem in this situation, anybody can help me please?

pale vessel
#

A role

carmine adder
#

Role Name yea

ornate arch
#

but, for what?

summer torrent
#

is this java or something

pale vessel
#

C#

carmine adder
#

I created a Category and i want to add this category my bot role. But i get it this error...

summer torrent
wary flame
modest maple
#

well, its not 'unlimited'

#

you have a limited amount of runtime

wary flame
#

Not if the repo is public

#

Or do you mean per run?

ornate arch
#

I never has used GitHub Actions but is good like Travis CI? (I have used Travis CI in some projects a time ago but I want know if has best options)

#

and I still curious to know what the abbreviation of ERP on the name of the bot thats mean

carmine adder
#

This isn't Enterprise resource planning if you thinking like this 😄

ornate arch
#

XD

#

thanks for giving your time to explain for me

sudden geyser
#

In React, is it safe to render a webpage at the toplevel (via document.documentElement)? All the examples I've seen start at the body element (via document.body) and users recommend others use Helmet.

rigid maple
#
{
  lvlDTdata: {
   asd: "asdasdasd",
   xd: "xdxdxd"
  }
}
{
  ttlDTdata: {
   asd: "asdasd",
   xd: "xdxd"
  }
}
```I have such a data, but how can I get ttlDTdata and lvlDTdata from these data?
i just need to loop these two headers already the data values `(asd, xd, asd, xd)` ​​inside are fixed
eternal osprey
#
fs.readdir("./src/commands/", (err, files) => {
  console.log(chalk.red('Loading Commands...'))
  if (err) return console.error(err);
  files.forEach(file => {
    if (!file.endsWith(".js")) return;
    let props = require(`./src/commands/${file}`);
    let commandName = file.split(".")[0];
    if (settings.includes(commandName)) return;
    console.log(chalk.green(`[+] ${commandName}`));
    client.commands.set(commandName, props);
  });
});```Uncaught Error: Cannot find module './src/commands/8-ball.js'. Pretty sure that the file is there tho.
sudden geyser
#

Does your data structure look more like this?

let objs = [
  {
    lvlDTdata: {...}
  },
  {
    ttlDTdata: {...}
  }
]

If so, you just need to find it by the key. For example, using .find to see if lvlDTdata exists as a key for one of the objects in an array.

earnest phoenix
earnest phoenix
sudden geyser
#

But that's inside the body

earnest phoenix
#

¯\_(ツ)_/¯

#

it must be for a reason

#

example: chakra-ui has a Portal component which i forgot what it does but it uses a completely seperate div inside the body element for doing some shenanigans

rigid maple
sudden geyser
#

That doesn't really make sense (Turan)

rigid maple
#

why

sudden geyser
#

You shouldn't have two top-level objects in the same variable

#

It wouldn't make sense to do ```js
let x = {
lvlDTdata: {...}
},
{
ttlDTdata: {...}
}

earnest phoenix
#

It's an array

#

xpData.locations.forEach

sudden geyser
#

That's what I was saying, but they're saying that it's not

#

ah so that now

rigid maple
#

this is the real output

{
  lvlDTdata: {
    x: 484.9999999999996,
    y: 149.9999999999998,
    scaleX: 2.7196793662000194,
    scaleY: 2.719679366200019,
    width: 872.9999768733978,
    height: 269.9999928474426
  }
}
{
  ttlDTdata: {
    x: 485.00000000000074,
    y: 15,
    scaleX: 2.634862774721654,
    scaleY: 2.634862774721655,
    width: 872.9999768733978,
    height: 269.9999928474426
  }
}
```I changed it because I didn't want to share
#

used Translate

earnest phoenix
#

Are you using visual studio code

rigid maple
#

i want to get x value in both headers with one code

earnest phoenix
#

If yes, hover over xpData.locations and send a screenshot

#

It will make it easier to see the data structure

rigid maple
#

1sec pls

sudden geyser
#

I wasn't concerned with the inner parts. I was concerned with the outer parts. Anyway, you just want to check if lvlDTdata or ttlDTdata are properties. For example, you could use let data = (x.lvlDTdata || x.ttlDTdata).asd

rigid maple
#

really small :D

#
[{"lvlDTdata":{"x":484.9999999999996,"y":149.9999999999998,"scaleX":2.7196793662000194,"scaleY":2.719679366200019,"width":872.9999768733978,"height":269.9999928474426}},{"ttlDTdata":{"x":485.00000000000074,"y":15,"scaleX":2.634862774721654,"scaleY":2.634862774721655,"width":872.9999768733978,"height":269.9999928474426}}]
earnest phoenix
#

i said hover over it...

#

with your mouse

#

in the code editor

rigid maple
rigid maple
earnest phoenix
#

It should say smth like { lvlData: {} }[] with number instead of 484.999999

pale vessel
#

Like Object.values(obj).map(({ x }) => x)?

sudden geyser
#

stole my thunder

#

or just xpData.locations.map((x) => x.x)

rigid maple
pale vessel
#

That returns [484.9999999999996, 485.00000000000074]

rigid maple
earnest phoenix
#

anyways

#

klay you were talking about where to render react elements iirc?

sudden geyser
#

Yeah

#

I just don't understand why people choose to render it only in the body or in a div in the body

pale vessel
#

Because that's where content should go

sudden geyser
#

And if I wanted to add stuff to the head?

earnest phoenix
#

Imagine the react stripping out all the other script tags from the body

#

That'll be a pain to fix

sudden geyser
#

Or even stuff to the <html>?

pale vessel
earnest phoenix
sudden geyser
#

hmm

earnest phoenix
#

that'll run the js when the component is mounted

#

DONT put it anywhere other than your App or root component

crystal wigeon
#

man i need help

#

this thing fkin stupid

#

Unexpected end of multipart data i keep getting this error when im forwarding formdata to another service

earnest phoenix
#

and if you dont want to wait for the UI to render for your head stuff to happen just put a <script async src="./head.js">

crystal wigeon
#

plus this only happens on mobile

#

mindfk

earnest phoenix
#

my mind also fk because you gave no code/error for us to help you with

crystal wigeon
#
            const files = req.files;
            for (let i = 0; i < files.length; i++) {
                fd.append("uploads", files[i].buffer, { filename: encodeURIComponent(`/${files[i].originalname}`) });
            }
            Object.keys(req.body).map((key) => {
                fd.append(key, req.body[key]);
            });
            const resultStream = new stream.PassThrough();
            try {
                req.headers["content-type"] = `multipart/form-data; boundary=${fd.getBoundary()}`;
                pump(fd, got.stream.post(`${USER_HOST_EXTERNAL_PROTOCOL}://${USER_HOST_EXTERNAL_DOMAIN}/files`,
                    {
                        headers: req.headers,
                        https: { rejectUnauthorized: false }
                    }),
                resultStream, (err) => {
                    if (!err) {
                        resultStream.pipe(res);
                    }
                    resultStream.destroy();
                });
            } catch (err) {
                resultStream.destroy();
            }```
earnest phoenix
#

what's req

crystal wigeon
#

welp im just trying to pipe formdata to another service

#

it works fine on desktop

#

ayyo i didnt paste the whole function name and stuff

#

(req, res) => above content

earnest phoenix
#

please use triple ``` instead of double .

crystal wigeon
#

when i try to upload from mobile it keeps throwing unexpect end of multipart

#
            const files = req.files;
            for (let i = 0; i < files.length; i++) {
                fd.append("uploads", files[i].buffer, { filename: encodeURIComponent(`/${files[i].originalname}`) });
            }
            Object.keys(req.body).map((key) => {
                fd.append(key, req.body[key]);
            });
            const resultStream = new stream.PassThrough();
            try {
                req.headers["content-type"] = `multipart/form-data; boundary=${fd.getBoundary()}`;
                pump(fd, got.stream.post(`${USER_HOST_EXTERNAL_PROTOCOL}://${USER_HOST_EXTERNAL_DOMAIN}/files`,
                    {
                        headers: req.headers,
                        https: { rejectUnauthorized: false }
                    }),
                resultStream, (err) => {
                    if (!err) {
                        resultStream.pipe(res);
                    }
                    resultStream.destroy();
                });
            } catch (err) {
                resultStream.destroy();
            }```
#

i did use "```

rigid maple
pale vessel
#

What do you mean?

rigid maple
#

Code: js xpData.locations.forEach(z => console.log(Object.values(z).map(({ x }) => x))) Output: ```js
[ 484.9999999999996 ]
[ 485.00000000000074 ]

crystal wigeon
#

TT

rigid maple
#

I have to loop them as they are inside the array

pale vessel
#

What do you want the output to be

crystal wigeon
#

just use .flat()

rigid maple
#

[ 484.9999999999996, 485.00000000000074 ]

pale vessel
#

You mean js [ [ 484.9999999999996 ] [ 485.00000000000074 ] ]right?

#

If so then yes flat()

rigid maple
#

no

pale vessel
#

Then no

rigid maple
#

onyl [ 484.9999999999996, 485.00000000000074 ]

crystal wigeon
#

lol

earnest phoenix
#

then wrap it in a spread operstor

rigid maple
#

there is no way i can do this without looping

earnest phoenix
#

[...Object.values(rest of the code)]

rigid maple
#

when I loop it, it throws them all in a separate array

earnest phoenix
#

we still dont understand what you mean by throws in another array

rigid maple
#

the output is just this
[ 484.99999999999996 ]
[ 485.00000000000074 ]

pale vessel
#

Try xpData.locations.forEach(z => console.log(z))

#

Then they're separate entries

rigid maple
#

1sec pls

crystal wigeon
#

where the bois when you need em

rigid maple
#

Output:

pale vessel
#

Ok that's confusing just log xpData.locations

crystal wigeon
#

use flat

#

object keys.map(()).flat()

#

try this

rigid maple
# pale vessel Ok that's confusing just log `xpData.locations`

Output:

[{"lvlDTdata":{"x":484.9999999999996,"y":149.9999999999998,"scaleX":2.7196793662000194,"scaleY":2.719679366200019,"width":872.9999768733978,"height":269.9999928474426}},{"ttlDTdata":{"x":485.00000000000074,"y":15,"scaleX":2.634862774721654,"scaleY":2.634862774721655,"width":872.9999768733978,"height":269.9999928474426}}]
pale vessel
#

They're different entries

crystal wigeon
#

yeah flat should work

rigid maple
pale vessel
#

You can

#

xpData.locations.map(x => Object.values(x)[0].x).flat()

rigid maple
#

I want this

codecodecode
// output: [484.9999999999996, 485.00000000000074]
#

yes

#

xpData.locations.map(x => Object.values(x)[0].x).flat()

#

HoaX and flazepe and others

crystal wigeon
#

you dont need .flat

#

.flat()

rigid maple
#

oh yes

#
console.log(xpData.locations.map(x => Object.values(x)[0].x))

Output: [484.9999999999996,485.00000000000074]

#

Thanks

crystal wigeon
#

cool

#

now where my bois at

#

help me

#

;-;

#

or i might resort to fixing my issue with a dirty shortcut

slender thistle
#

@sudden geyser How would one spawn 2 simultaneous threads for a 1D Vec? thinking_star

#

Would it be in a while loop with an index being incremented by 2 once both threads are done?

#

Or is there another way in Rust?

sudden geyser
#

I'm confused by your question.

#

You can spawn a thread with std::thread::spawn, but what you want to do with the thread is the confusing bit.

shadow frigate
#

Is SQLite bad if you're using it with a sharded bot?

slender thistle
#

I want to run a selenium script in a separate thread

#

I want to spawn a thread per each element in my Vec

#

Optimally I want to do it in a bunch of two elements at once instead of just one

rocky hearth
#

how do I fix this?

/* 
Argument of type 'null' is not assignable to parameter of type 'T'.
  'T' could be instantiated with an arbitrary type which could be unrelated to 'null'.
-------
(parameter) fillWith: null
*/
function generate2DArray<T = null>(row: number, col: number, fillWith = null) {
  return Array.from(Array(row), () => Array<T>(col).fill(fillWith))
}
sudden geyser
#

Are you looking to make T a nullable type

rocky hearth
#

yeah, the default

#

is it possible to take the type (T) from fillWith?

#

so we dont even hv to specify the generic?

fair axle
#

I want to get the length of "a" letter in that list. How can I do this?

const list = ["a", "b", "a", "a", "c", "d"]
split hazel
fair axle
#

Yes

split hazel
#
array.reduce((total, e) => (e === "a" ? total + 1 : total), 0);

You would use array reduce to add up the total every time the specific element is found, where e is the element, you can figure out the rest

fair axle
#

What if I use this? Which one is the best

list.filter(item => item == "a").length
split hazel
#

that's a more readable way but slower

fair axle
#

Reduce is better

#

Okey thank you

split hazel
#

since you'd be making a new array and throwing elements into it as opposed to just adding to a total

fair axle
#

So, what is the best way to do it in that example

const json = {
  "1": "a",
  "2": "b",
  "3": "a",
  "4": "a",
  "5": "c"
}
#

I want the count the amount of "a" element

#

is it?

Object.values(json).reduce((total, e) => (e == "a" : total + 1 ? total), 0)
rocky hearth
#

yup 👍

fair axle
#

Thank you

amber wagon
#

Can sorting a big list of dictionaries crash a bot ?

sudden geyser
#

Or even .reduce((total, letter) => total + (letter === "a"), 0)

amber wagon
#

By crash I mean make it restart

grim sundial
#

nope

sudden geyser
amber wagon
#

I'm sorting it by just one value

#

Around 300 dictionaries in that list

#

1 dictionary have 1 user's data

sudden geyser
#

So you want to sort all users by some property

#

e.g. their level

#

But "big" is subjective

#

Most users don't have to worry about sorting large collections of data

amber wagon
#

yeah thats what i m doing it was working fine till 2 days ago but now it works sometimes and just end up restarting the bot i narrowed my search down to sorting if i reduce the number of users by filtering it works normally

sudden geyser
#

That sounds like a bigger problem

#

It could be the result of something else

#

Because sorting a 300 element list is nothing

earnest phoenix
#

How do I cache/fetch all the members of a guild and execute a command on them like adding a role? Right now I use:

message.guild.members.cache.forEach(members => {
 // code
})

But nothing happens on the accounts that haven't had any activity since the bot was turned on? Is there any way to force fetch all the members?

sudden geyser
#

Do you have the intents enabled

quartz kindle
#

you need the server members intent for that

earnest phoenix
#

I do have that I think

quartz kindle
#

then you can do await message.guild.members.fetch()

earnest phoenix
#

Alright I'll try that

#

a.setName(`Members: ${member.guild.members.cache.filter(x => !x.user.bot).size}`)
b.setName(`Bots: ${member.guild.members.cache.filter(x => x.user.bot).size}`)
c.setName(`All: ${member.guild.memberCount}`)
#

Why it shows member count wrong

lament rock
#

Not all members have been cached

earnest phoenix
#

It works on similar servers

lament rock
amber wagon
earnest phoenix
amber wagon
#

but cant figure out i changed my token on the day this bug first showed up

quartz kindle
#

because the cache size does not include all members

#

only active members

lament rock
#

users that are offline are not sent if you have presence intent iirc

quartz kindle
#

if you want ALL members, use guild.memberCount

earnest phoenix
#

I want member count without bots

quartz kindle
#

if you absolutely need to filter bots out, then you need to fetch all members

#

which requires the server members intent

#

and costs a lot of memory

lament rock
#

We're telling you the answer. We're not saying these things for no reason

earnest phoenix
quartz kindle
#

...

lament rock
#

That statement and the next three messages are one thought

timber fractal
quartz kindle
#

because infractions is always 1

timber fractal
#

oh, why is that what did i do wrong?

quartz kindle
#

you always create a new Collection

timber fractal
#

good point lmao

lament rock
#

It would be advisable to store things in an actual database instead of in memory since memory is volatile

timber fractal
#

works now thx

timber fractal
lament rock
#

Okay

fair axle
#

is mongodb supports Map Object?

solemn latch
#

why would you store a map object in mongodb?
realistically should be putting each key in their own document instead.

fair axle
#

I used json but I need functions like .filter() .has()

solemn latch
#

thats what mongodb does for you

fair axle
#

I will change the question

#

My json object

const json = {
  "1": "user",
  "2": "role",
  "3": "user",
  "4": "user",
  "5": "role"
}

What I need is

{
  "1": "user",
  "3": "user",
  "4": "user"
}
#

How can I filter json object according to values

solemn latch
#

youll probably want to use an array instead for that, as it seems your just indexing them anyway.

rocky hearth
rocky hearth
fair axle
#

yes

nimble kiln
#

Hello general chat

pale vessel
#

Hey

marble juniper
#

hi

#

so

sly sierra
#

hey

marble juniper
#

d o g

nimble kiln
#

How's your day been

marble juniper
nimble kiln
#

dog

sly sierra
nimble kiln
sly sierra
solemn latch
#

👀 you all are in the wrong channel

nimble kiln
#

oh no woo

sly sierra
marble juniper
#

wooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

rustic nova
#

what's going on here

sly sierra
marble juniper
#

dog party

nimble kiln
#

This is general now

sly sierra
nimble kiln
#

#general has been converted to development

marble juniper
rocky hearth
# fair axle yes
Object
  .entries({ "1": "user", "2": "role", "3": "user", "4": "user", "5": "role" })
  .flatMap(([key, val]) => (val == "user" ? key : []))
quick ginkgo
#

@quartz kindle pls rate my code on a 1-10 basis on how pissed off my code makes you

        // HANDLE THE FUCKING SCORE
        if (pongers.ball.x == g_desktopRect.left) {
            pongers.opponent.score++;
            resetGame();
        }
        else if (pongers.ball.x + pongers.ball.width == g_desktopRect.right - g_desktopRect.left) {
            pongers.player.score++;
            resetGame();
        }
        // HANDLE PLAYER-BALL COLLISIONS
        if ((pongers.ball.x == g_desktopRect.left + pongers.opponent.x + pongers.opponent.width && (pongers.ball.y > pongers.opponent.y && pongers.ball.y < pongers.opponent.y + pongers.opponent.height)) || (pongers.ball.x == g_desktopRect.left + pongers.player.x && (pongers.ball.y > pongers.player.y && pongers.ball.y < pongers.player.y + pongers.player.height))) {pongers.ball.xforce *= -1;}
        //bouncy ball hit ceiling/floor
        if (pongers.ball.y == g_desktopRect.top || pongers.ball.y + pongers.ball.height == g_desktopRect.bottom - g_desktopRect.top) {
            pongers.ball.yforce *= -1;
        }
quick ginkgo
#

no

#

just because you suggested it, im removing all line breaks

rocky hearth
#

give proper line breaks to ur whole code

wheat mesa
#

Make the entire thing a one liner

quick ginkgo
#

now im going to remove all line breaks when i finish

rocky hearth
#

u r cursed!!

wheat mesa
#

no

quick ginkgo
#
        // HANDLE THE FUCKING SCORE
        if (pongers.ball.x == g_desktopRect.left) {pongers.opponent.score++;resetGame();}else if (pongers.ball.x + pongers.ball.width == g_desktopRect.right - g_desktopRect.left) {pongers.player.score++;resetGame();}
        // HANDLE PLAYER-BALL COLLISIONS
        if ((pongers.ball.x == g_desktopRect.left + pongers.opponent.x + pongers.opponent.width && (pongers.ball.y > pongers.opponent.y && pongers.ball.y < pongers.opponent.y + pongers.opponent.height)) || (pongers.ball.x == g_desktopRect.left + pongers.player.x && (pongers.ball.y > pongers.player.y && pongers.ball.y < pongers.player.y + pongers.player.height))) {pongers.ball.xforce *= -1;}
        if (pongers.ball.y == g_desktopRect.top || pongers.ball.y + pongers.ball.height == g_desktopRect.bottom - g_desktopRect.top) {pongers.ball.yforce *= -1;}
wheat mesa
#

He’s cursed to forever write one liners

quick ginkgo
#

its 4 lines now

#

fuck it, i dont need comments

rocky hearth
#

*urself

quick ginkgo
#
        if (pongers.ball.x == g_desktopRect.left) {pongers.opponent.score++;resetGame();}else if (pongers.ball.x + pongers.ball.width == g_desktopRect.right - g_desktopRect.left) {pongers.player.score++;resetGame();}if ((pongers.ball.x == g_desktopRect.left + pongers.opponent.x + pongers.opponent.width && (pongers.ball.y > pongers.opponent.y && pongers.ball.y < pongers.opponent.y + pongers.opponent.height)) || (pongers.ball.x == g_desktopRect.left + pongers.player.x && (pongers.ball.y > pongers.player.y && pongers.ball.y < pongers.player.y + pongers.player.height))) {pongers.ball.xforce *= -1;}if (pongers.ball.y == g_desktopRect.top || pongers.ball.y + pongers.ball.height == g_desktopRect.bottom - g_desktopRect.top) {pongers.ball.yforce *= -1;}
rocky hearth
#

make it look better

quick ginkgo
#
if(pongers.ball.x==g_desktopRect.left){pongers.opponent.score++;resetGame();}elseif(pongers.ball.x+pongers.ball.width==g_desktopRect.right-g_desktopRect.left){pongers.player.score++;resetGame();}if((pongers.ball.x==g_desktopRect.left+pongers.opponent.x+pongers.opponent.width&&(pongers.ball.y>pongers.opponent.y&&pongers.ball.y<pongers.opponent.y+pongers.opponent.height))||(pongers.ball.x==g_desktopRect.left+pongers.player.x&&(pongers.ball.y>pongers.player.y&&pongers.ball.y<pongers.player.y+pongers.player.height))){pongers.ball.xforce*=-1;}if(pongers.ball.y==g_desktopRect.top||pongers.ball.y+pongers.ball.height==g_desktopRect.bottom-g_desktopRect.top){pongers.ball.yforce*=-1;}
rocky hearth
#

thats llike a good boy

quick ginkgo
#

i haven't tested it yet

#

so i sure do hope it fuckin works

#

at one portion of the project,
im just gonna make it assembly code

rocky hearth
#

Does anyone care?

quick ginkgo
quartz kindle
#

xD

fiery dawn
#

Hellu

lethal trout
#

https://sourceb.in/pO1ZgTfjRa
Soo.. this command will randomly send the message like "first one to say hi wins"
but in my code even if i say the correct thing it says wrong
it is like dank memer.. it will send smth random for coins

jovial nexus
#

how can i remove a role of a member without member intents?