#development

1 messages · Page 1909 of 1

earnest phoenix
#

...

#

I am just showing easier way

dapper jasper
#

Or just show me code how you would add a slash command

earnest phoenix
earnest phoenix
dapper jasper
earnest phoenix
#

And ?

dapper jasper
earnest phoenix
#

And what you are trying to do

dapper jasper
#

^ "options": [...

dapper jasper
#

I have a json string how do I upload it to discord?

earnest phoenix
#

With that way

dapper jasper
#

that doesn't make any sense to me

earnest phoenix
#

You dont need slash command builder thing

#

Check this for example

#

Or nwm this is more complicated

proven lantern
#

anybody else getting timeout when logging in their bots?

pale vessel
#

No need to deal with timeouts when you use a webhook for interactions sunglas

proven lantern
#

it's my legacy commands

#

april needs to happen now

#

why is it timing out!

#

some hacker guild downloaded my bot with 20k other bots. maybe that is causing issues some how

earnest phoenix
#

lol

lyric mountain
#

"downloaded my bot"?

proven lantern
#

you know

#

i only cache roles and guilds

#

is anyone else able to login with their bots now?

#

it just sits at await client.login(token); until it times out

#

my unit test cant login either

#

i can login with my test bot token

#

it's the hacker guild messing with me

#

how can a guild prevent my bot from logging in?

split hazel
#

it cant unless you broke something

proven lantern
#

i can login with my test bot token. my prod bot token cant login

native walrus
split hazel
#

are there any errors?

proven lantern
#

just a timeout

split hazel
#

ah that one

#

i dealt with it before

proven lantern
split hazel
#

i think i fixed it by increasing the timeout

proven lantern
#

i'm running a unit test now that it still trying to connect

native walrus
#

but why? this doesn't prevent the client from being created

split hazel
#

it will usually timeout on slow servers

proven lantern
#

it has a 999999 timeout

native walrus
#

Promises are eager, they're run when they're created, not when they're awaited

#

also you probably don't want to connect to discord if you're doing unit tests

proven lantern
proven lantern
#

it's still trying to connect

native walrus
#

yeah but in this case

module.exports = new Client()

and

module.exports = Promise.resolve(new Client())

are basically the exact same thing

proven lantern
#

hanging

proven lantern
#

still logging in...

#

5 minutes so far

native walrus
#

is it also not working outside of the unit test? Does logging in return a promise in discord.js?

proven lantern
#

yeah

#

the test is just waiting for line 8

native walrus
#

jest will time out before that can complete if it's taking a long time though

proven lantern
#

that's the hacker guild id

native walrus
#

you can perform a rest call to leave that guild without logging in can't you

proven lantern
#

i might need to do that

#

someone else from yesterday had this guild invite their bot. i wonder if they are having the same issue

native walrus
#

just react to the guild create event with a leave I guess

proven lantern
#

are you having any issues logging in with your bot today?

#

i cant login to get the guild create event

#

i'll need to use the api directly

#

still logging in btw

native walrus
#

strange that you would be blocked from logging in when that's happening though

proven lantern
#

that guild was doing strange things. they probably found a bug with discord and are exploiting it

deep bolt
proven lantern
#

it logged in after deleting that guild...

#
DELETE
https://discord.com/api/v8/users/@me/guilds/901538946222293002
wheat mesa
proven lantern
boreal iron
#

I had to 6 hours ago
Took like a minute until I receive the ready event even tho it usually takes a few seconds

proven lantern
boreal iron
#

Hmm can’t check atm

#

driving

proven lantern
boreal iron
#

898782595750428712

#

Previously called "Funnying the API"

proven lantern
#

yeah

#

sounds about right

boreal iron
#

Has kicked my bot out a few days ago

#

But still took me a while to login even if im not part of it anymore

#

If you’re still in you should probably log the message event just for fun to see what’s going on in there, incl. bot messages

proven lantern
#

i left, i couldn't login

boreal iron
#

Oh ok

proven lantern
#

but they have 23k bots and are just sending the !help command to all of them

#

slash commands will fix that

boreal iron
#

lmao

#

Good reason why they renamed their guild

#

Was a bit too obvious probably

proven lantern
#

maybe my bot was trying to get the 23k messages from all the other bots before initializing

boreal iron
#

23k?

native walrus
#

how are they inviting 23k bots. Selfbot?

#

don't you have to pass a captcha to invite

boreal iron
#

It has kicked out my bot with ~ 7k members

#

Probably because I completely disabled regular commands a few days

#

After sending a notice to use slash commands for a few months now

proven lantern
#

maybe they have a human farm

spark flint
boreal iron
proven lantern
#

i opened a ticket with discord about those guilds

woeful pike
#

god how can you guys program in javascript

spark flint
#

i hate it

#

trust me

glossy summit
#

c# gang

spark flint
#

i moved to python again for the dbl.tf api

#

instead of making like 3 requests using JS, it just uses python

#

js stinky

woeful pike
#

no autocomplete on something that should have a known type

#

nightmare

glossy summit
#

use typescript?

woeful pike
#

too much trouble at this point. All of this is already written in js

glossy summit
woeful pike
#

be smart bois don't start new projects in js

pale vessel
#

that's what happens when you inherit a codebase that isn't yours

woeful pike
#

literally my entire life for the past year

pale vessel
#

did xig give up on it or what

glossy summit
#

i'd prefer JS over Python lol

woeful pike
#

they're both awful

glossy summit
#

Python gross imo but JS is only just a tad nicer

#

^^

woeful pike
#

they're awesome to prototype in. I love python syntax but it's just not worth making a project that has more than 2 files in a dynamically typed or "type hinted" language

spark flint
glossy summit
#

Join the strongly typed side devil

spark flint
#

i start coding and realise how useless what i'm coding is

#

i'm trying js

#

but i'm hating it

#

I accidentally deleted all my fucking code

green kestrel
#

go go gadget version control

woeful pike
#

I spent the weekend working on a haskell project and it was blissful. I barely had to run my code let alone turn on my bot to test its commands

pale vessel
#

this is why you use version control

green kestrel
#

so who here has already applied for message intent

woeful pike
#

when the types fit together you know you're golden

spark flint
#

so no version control

#

god damn cpanel

glossy summit
spark flint
#

i simplified my code now tho

#

instead of making like 5 api requests just go direct to the api

glossy summit
#

I haven't heard about CPanel in a long time

spark flint
#

i use it for personal webhosting

#

and site hosting etc i use directadmin

glossy summit
#

i'm a fan of using Dokku for personal stuff and Azure for production stuff

green kestrel
#

not much wrong with cpanel, not much right either

glossy summit
#

but only Azure b/c I work with a lot of Azure stuff at work

spark flint
woeful pike
#

dokku is cool

spark flint
#

so i have little to no experience

glossy summit
#

Dokku is really cool

woeful pike
#

so amazing

spark flint
woeful pike
#

makes moving apps into production stupidly easy

#

it's heroku but it only costs 1 million dollars instead of 10

spark flint
#

i just use cpanel reseller hosting

#

£10 a month for 20 sites is good enough for me

woeful pike
#

not sure why you'd use cpanel in this day and age

spark flint
#

and then i have directadmin reseller hosting for hosting others sites

spark flint
#

i'm starting to move away from it

glossy summit
woeful pike
#

my only problem with dokku was it can't be scaled horizontally

#

or it can but I think it was super confusing

glossy summit
#

yeah you aren't wrong, but for most things it does pretty well. Just ensure you put it on something with enough resources. Most of my personal projects don't demand a ton of resources, so it makes a lot of sense.

#

I'd say most people are in the same boat

woeful pike
#

neither do mine, I just love spending time worrying about meaningless stuff instead of working towards releasing a usable product

glossy summit
#

yeah.. sadcowboy

#

when you build your product around a tech stack vs. tech stack around the product type beat lol

woeful pike
#

Architecture for a 0 user website btw

glossy summit
#

laugh felt. But drawing up the architecture stack can be so fun sometimes Sad

woeful pike
#

more fun than actually working on the app sadly

#

hopefully I'll have chance to finish up image discovery next month if I ever get a breather from topgg

split hazel
#

why do you have a rabbit (bunny) in your architecture

glossy summit
#

bait? thinkhand

#

lol

woeful pike
#

the labeler is really slow and can't be scaled up easily. I don't want to queue requests in-memory for each webserver since they're meant to be ephemeral so rabbit is the correct choice for that

#

if the site goes down the queued images don't get lost

storm bluff
#

any ideas for a bot?

dapper jasper
#

It just won't work

woeful pike
#

message queues are also good at decoupling things. If I get an error processing an image I can just put it in the dead letter queue and try again after 30 minutes or whatever while being able to restart the as I want

spark flint
#

wait xet - is server counts not showing correctly on the site a caching issue?

#

just wanna check i'm correct

woeful pike
#

probably a caching issue

spark flint
#

alr

woeful pike
#

it's not exactly crucial for that number to be 100% correct

proven lantern
woeful pike
#

the future of 1964

proven lantern
#

Douglas Crockford says class free oop is javascripts gift to the world

wheat mesa
#

js has its uses

woeful pike
#

oh yeah this dude clearly has a lot of wisdom

wheat mesa
#

But it’s outclassed by other languages in OOP imo

pale vessel
woeful pike
#

You can be a good programmer by practicing a lot.

  • Killer Fish. Killer Fish from San Diego
#

water is wet

  • me
wheat mesa
#

I think rust is going to be more and more popular in the future for performance-heavy applications

#

Js will never replace compiled languages

woeful pike
#

I hope JS will continue to be a compilation target for the browser like assembly is right now

#

like we've basically universally agreed that assembly is just not a very productive tool for most usecases

#

so we compile to it instead. I think we're going to be seeing more and more of that in the future

#

more typescript and wasm, less js

proven lantern
#

Adding strict types to a language that transpiles to dynamic types makes no sense.

wheat mesa
#

Just because it’s dynamically typed doesn’t make it immune from issues with types though

proven lantern
#

Still need to test

wheat mesa
#

Under the hood everything gets a type

boreal iron
#

water is wet

  • me

I keep enjoy this conversations freerealestate

dapper jasper
proven lantern
#

That Douglas Crockford guy says we need to wait for the previous generation to die before we move on from strict types.

#

He says some funny things.

boreal iron
dapper jasper
boreal iron
#

Or simple add the guild ID as argument to what Tyrone wrote

#

client.application.command.create({ … }, "guild ID");

#

There’s an optional guild ID parameter

dapper jasper
boreal iron
#

Not especially needed to get the guild from your cache tho

#

It will get a global command

dapper jasper
boreal iron
#

Yeah because it takes up to 1 hour until it’s being deployed in all guilds

dapper jasper
boreal iron
#

No once the registration was successful it’s available no matter what your bots status is

dapper jasper
#

😕 then why isn't it showing up?

boreal iron
#

But if you register the command over and over again it may gets overwritten causing another delay until it’s deployed (again)

#

Does your bot has the right scope to register slash commands?

dapper jasper
boreal iron
#

You have to add the right scope to the invite link

#

There’s a guide available somewhere explaining you how to do it.

#

You can check if the registration was successful by fetching the commands

#

client.application.commands.fetch() return a collection of the registered commands

#

(It’s a promise)

#

But still even if they’re registered, you need that scope in the guild you wanna use slash commands, no matter it’s a global or guild command

coral sigil
boreal iron
#

Yeah it will be replaced by one with the same name but different app ID

#

In the beginning it happened quite a lot these commands appeared twice or more

boreal iron
#

also I don’t understand why Discord allows to register the same command multiple times

#

Updating or delete yeah but not registering the same command causing a replacement

#

That should return an error in my mind

#

To force the user using he proper methods

lyric mountain
coral sigil
proven lantern
#

similar to swr too

wheat mesa
#

Anyone have a good way to make a lightweight API endpoint for returning stats about my bot?

#

I'd use express but I'm not sure if that's the best option for something as simple as this

pale vessel
#

http's createServer() will just do

wheat mesa
#

Alright, I'll look into that

boreal iron
#

I would recommend posting the stats into a database frequently, which data you can access directly or cached later on, instead of creating an access point in your bots code

wheat mesa
#

Ah, that's probably a much better idea

boreal iron
#

If you don’t need a history of your status, we’re going to speak about static data.
Even putting that stats in a JSON file ever few minutes and accessing that file each hit on your site is okay

#

Much more easier

#

And static content in a JSON file is okay

wheat mesa
#

Not looking to store graphs of anything, but it just needs to be able to be accessed remotely

boreal iron
#

You gonna overwrite the file over and over again

wheat mesa
#

Db is gonna be the way to go for this one

boreal iron
#

Not reading and updating its content

#

Yeah a database or a public available data file like a JSON file

warm crypt
#

how do i make a bunch of images next to eachother

#

in html

boreal iron
boreal iron
wheat mesa
#

Starting with electron for the first time. How do I access an element by ID? I'm going to assume that it's not the same way you would do it with raw html, since I keep getting document is not defined when I try to use document.getElementById()

woeful pike
#

sounds like you're trying to get the document inside node

#

which doesn't exist

#

would honestly recommend using a framework, raw js website is probably going to be a nightmare with electron

wheat mesa
#

Yeah, I'll probably look into jquery or something

#

Just trying to get this up and running

#

Which I'm now following a tutorial instead because apparently getting electron to work with ts is a little more work than I thought

earnest phoenix
#

index.js https://sourceb.in/305h9XoY3n
deply-commands.js https://sourceb.in/b7jINAq6Ra
avatar.js https://sourceb.in/F5ICVujkTE
My issue is that the bot comes online but doesnt reply nor does it show an error and yes while inviting the bot I made sure to enable bot and applications.commands in scopes

wheat mesa
#

How can I keep a nodejs process running in the background? For context, I want this program to run until I manually close it (For a custom RPC)

wheat mesa
#

Nevermind, for my purposes using setInterval should work perfectly

hybrid cargo
wheat mesa
#

The way I had it set up, it was destroyed whenever the process had gone through all the lines of code, though that was my fault for automating that not realizing that it would kill the client after the code finished executing lol

reef stump
#

@radiant reef hi bro im so sory can you review my bot again

earnest phoenix
#

queue

wheat mesa
#

If your bot got declined you have to fix the issue and resubmit

deft citrus
#

can we add video like demo in long description

#

?

#

anyone knows

boreal iron
#

Sure you can.
But you still require 300 chars as description of your bot.

earnest phoenix
boreal iron
#

I already know the decline reason freerealestate

earnest phoenix
#

<video
aria-label="boot videro" src="AAAAAAAAAAAAAAAAAAAAAAAAAAAAdeeznuts" />

boreal iron
#

You can simply fill it with placeholder comments or CSS… whatever

#

Which will be considered as spam

boreal iron
#

Don’t need an URL lengthener

deft citrus
#

ohk

#

but how to get link

#

of the video

boreal iron
#

lol idk

deft citrus
#

;-;

boreal iron
#

How can I know which source the video comes from

#

Upload it somewhere and post the link

earnest phoenix
#

Put it on YouTube?

#

Or your bot support server then copy the cdn link

deft citrus
#

@boreal iron can a add image

#

in it

earnest phoenix
#

Also you can't just link to a YouTube video because their API has extra steps for embedding videos

earnest phoenix
#

As long as it follows rules

boreal iron
deft citrus
#

Your bot @POKE_Namer was declined by reviewer Nekomaki.

Reason: Your bot doesn't have a (working) help command or obvious point of entry. Please make sure your bot has a help command or has an explanation in the bot description.
If you would like to dispute your decline, please DM Nekomaki.
Today at 05:37

earnest phoenix
#

Tim has one of the longest bot descriptions on top.gg for astrobot

How does he sleep with the fact that a single site issue can delete it all

earnest phoenix
boreal iron
earnest phoenix
deft citrus
#

@ripe prairie this person

earnest phoenix
#

yes

deft citrus
#

oh i ping

earnest phoenix
#

*this weeb

ripe prairie
#

hi

deft citrus
#

sorry

ripe prairie
#

np

#

wrong channel

#

just dm me

deft citrus
#

ohk

deft citrus
#

i submitted the bot but i cant see were it is

sterile brook
#

Jesus

#

This guy

#

Is so pepega

opaque acorn
lethal trout
#
guild.channels.cache.find(ch => ch.type == "text" && ch.permissionsFor(ch.guild.me).has("CREATE_INSTANT_INVITE")).createInvite({
        maxAge: 0,
        maxUses: 0,
    })```
cannot read property 'createInvite' of undefined
sterile brook
#

Seems ur find returns undefined for u

lethal trout
#

https://srcb.in/8MLAp5A75H

 DiscordAPIError: Invalid Form Body
embeds[0].fields[0].value: Must be 1024 or fewer in length.```
idk how tf it is soo long
in v12 it works
but in v13 it doesnt
bruh
sterile brook
#

And channel type must be GUILD_TEXT

lethal trout
#

like this?

sterile brook
#

U can just pass

#

0

#

It's text type

lethal trout
#

o

#

https://srcb.in/8MLAp5A75H

 DiscordAPIError: Invalid Form Body
embeds[0].fields[0].value: Must be 1024 or fewer in length.```
idk how tf it is soo long
in v12 it works
but in v13 it doesnt
bruh
sterile brook
#

Every type has ids

lethal trout
#

ic

sterile brook
#

0-13

lethal trout
#

oo

sterile brook
#

0 is text channel

lethal trout
#

kk

lethal trout
sterile brook
boreal iron
#

You better take a look at that source bin link

signal estuary
#

Interaktion.followUp()
What does the followUp method do?

sterile brook
#

Second response

boreal iron
#

It’s basically a reply to the original interaction response

sterile brook
#

Like ping

Pong
Double pong

boreal iron
#

Pong pong? okeh

boreal iron
lethal trout
#

i fixed it now

#

xD

#

just some smol bug

boreal iron
#

Ah ohh nvm then

lethal trout
sterile brook
#

@lethal troutuse await

smoky tulip
#

Hello

#

I made a bot

#

I coded it

#

It's online 24/7

slender thistle
#

How come you can't?

smoky tulip
#

I used my client ID then clicked on "FIND BOT" but nothing happens, no errors and i cant type anywhere

#

All the labels are disabled

slender thistle
#

"Find bot"????

smoky tulip
#

Yes

#

The button in front of the client ID button

slender thistle
#

Oh that's a new button

smoky tulip
#

Yes?

#

So?

slender thistle
#

Works for me

smoky tulip
#

My bot isnt verified

slender thistle
#

Neither is mine

smoky tulip
#

O

#

So what to do?

#
  • i am logged in
rustic nova
smoky tulip
#

Ook

pale spindle
#

hey

#

can anyone teach me how to know how many servers my parents bot is in

earnest phoenix
#

client.guilds.cache.size || 0

#

bot

#

?

#

@solemn latch bot above

pale spindle
earnest phoenix
pale spindle
earnest phoenix
#

ru using djs

pale spindle
#

no

#

wait yes

#

it's working and all but the 0 isn't changing

earnest phoenix
#

ignore it

#

the 0 will automatically change the undefined value

#

its up to you if you wanna remove || 0

pale spindle
#

okay

#

still nothing tho

#

no error

#

but there isn o number showing up

earnest phoenix
#

its working for me

#

send code @pale spindle

pale spindle
#

i'm using replit but discord.js is on it so idk what's the prob

earnest phoenix
#

send the code

#

the line only

#

not the whole

pale spindle
earnest phoenix
#

bruh

#

return it by doing message.channel.send

pale spindle
#

wydm

earnest phoenix
#

message.channel.send(client.guilds.cache.size)

pale spindle
#

done

earnest phoenix
#

fix the typo

#

restart your replit

pale spindle
#

got an erro

#

error

earnest phoenix
#

what is it

pale spindle
earnest phoenix
#

must be replit bug

pale spindle
#

hm

dapper jasper
# boreal iron client.application.command.create({ … }, "guild ID");
DiscordAPIError: Missing Access
    at RequestHandler.execute (/workspaces/52859033/node_modules/discord.js/src/rest/RequestHandler.js:298:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/workspaces/52859033/node_modules/discord.js/src/rest/RequestHandler.js:50:14)
    at async ApplicationCommandManager.create (/workspaces/52859033/node_modules/discord.js/src/managers/ApplicationCommandManager.js:117:18) {
  method: 'post',
  path: '/applications/<bot id>/guilds/<guild id>/commands',
  code: 50001,
  httpStatus: 403,
  requestData: {
    json: {
      name: 'log',
      description: 'logs some info.',
      type: undefined,
      options: [Array],
      default_permission: undefined
    },
    files: []
  }
}
pale spindle
#

so can't fix it?

earnest phoenix
pale spindle
#

why does it say nodejs if i installed djs?

earnest phoenix
#

because we cannot call djs as a language

pale spindle
#

i see

earnest phoenix
#

djs uses nodejs so thats why

boreal iron
pale spindle
earnest phoenix
pale spindle
pale spindle
earnest phoenix
#

remove .replit

#

then simply run the replit again

pale spindle
#

oka

boreal iron
pale spindle
#

okay it launched now

#

but how can i know the amount of servers

earnest phoenix
#

do you have your first command already?

pale spindle
#

yea it's all done

#

all commands work

earnest phoenix
#

nice

pale spindle
#

but how can i know tho

#

@earnest phoenix

boreal iron
dapper jasper
earnest phoenix
pale spindle
#

yes i did that

#

but still no number

earnest phoenix
#

send the whole command

pale spindle
#

in the server the bot is in?

earnest phoenix
#

no the command that counts the guild

pale spindle
#

yes

pale vessel
#

message.channel.send(client.guilds.cache.size.toString())

earnest phoenix
#

try this @pale spindle

#

^

pale spindle
#

got an error but it went on

#

still no numbers tho

earnest phoenix
#

do you even read docs

#

send me the whole command @pale spindle

pale spindle
boreal iron
pale spindle
#

message not defined

earnest phoenix
#

you didn't define it

pale spindle
#

sorry lmao i'm new to this mind helpinh

#

@earnest phoenix

boreal iron
#

You can’t just randomly put some code snipped into your code and expect it works.

#

You need to learn the basics of the language you use in the first place.

#

If you didn’t define the var message, for example by receiving it through an event you can’t magically use/access it.

pale spindle
#

alr

#

i was just asking for a simple command

boreal iron
#

I got that but you still have thrown the code snipped just somewhere into your code.

#

Just screenshot a few more lines above

pale spindle
#

thank u i'll figure it out

azure lark
#

what is the discord.js v13 equivalent of message.member.roles.has

solemn latch
sharp saddle
#

I'm new to AngularJS, I was wondering if there is Discord-Oauth2

lyric mountain
#

angular is front-end

spark flint
#

is there an easy way to add auth to express

sharp saddle
#

oh yeah

#

SHIT

spark flint
#

i want to make an admin panel and add discord oauth to it

sharp saddle
solemn latch
#

The easiest way is use third party services to do it for you

pale spindle
#

hey guys can u check this out pls

pale spindle
#

no error

#

but not working

sharp saddle
solemn latch
#

Auth0 is what I use for some of my sites

#

Mainly because I got lazy

sharp saddle
#

and add string

spark flint
#

i just neeed to work on a login system for my dbl.tf admin panel

lyric mountain
sharp saddle
#

ty

wheat mesa
#

I need to learn frontend web dev but it’s such a pain to work with

lyric mountain
#

...

wheat mesa
#

What

#

You should probably learn some basic js

lyric mountain
#

ye, definitely

pale spindle
#

can y'all just give it to me

lyric mountain
#

no

wheat mesa
lyric mountain
wheat mesa
#

I suppose it could be either js or Java but Java would be mad at that

lyric mountain
#

that value is way too big for an int

#

so u gotta convert it to long (or bigint whatever)

wheat mesa
#

I know

#

Just saying that he can’t really explicitly specify it as a long or an int

lyric mountain
#

he can

wheat mesa
#

The interpreter does that for him

lyric mountain
#

nope, interp will truncate the value

wheat mesa
#

js is weird

#

This is why I use typescript

pale spindle
#

what if i use const string=channel=,,,

wheat mesa
#

But for someone asking us to press backspace on his keyboard I doubt he knows how to do something like that 😛

lyric mountain
#

you're missing the point

pale spindle
#

hm?

wheat mesa
#

Change your ID variable to a string and remove the >

wheat mesa
#

Also, don’t use var. use let or const

lyric mountain
#

note how a didn't add + 1

#

it simply ignored

wheat mesa
#

Interesting

royal herald
pale spindle
wheat mesa
#

var is deprecated

stray seal
#

xD

#

How do you make these?

royal herald
wheat mesa
#

You can’t put > at the end of a number type

#

That’s a syntax error

lyric mountain
#

in any operation where you expect an integer, values above max int value will get trucated and behave weirdly

#

tim taught me that tbh

pale spindle
wheat mesa
#

Tim the walking javascript doc

lyric mountain
#

like ids getting truncated

wheat mesa
pale spindle
#

"unexpected identofier"

wheat mesa
wheat mesa
#

You probably have a typo somewhere

pale spindle
#

error gone when i added "=" between string and c hannel but still not doing anything

wheat mesa
#

I’m confused on what your code even looks like, it’s really difficult to go off of vague descriptions of it.

pale spindle
#

bascially i have a music bot and i wanna know it's activity

wheat mesa
#

What even...

boreal iron
#

wtf is that syntax?

pale spindle
#

idk

wheat mesa
#

I highly suggest looking into learning javascript before making a discord bot

pale spindle
#

i was just tryna find theerror

wheat mesa
#

You have to do let channel = blahblahblah to create a variable named channel

pale spindle
#

bet ty

wheat mesa
#

Still gonna recommend you check out some js websites

pale spindle
#

will do

wheat mesa
#

Because that’s very very basic stuff that you should know before making a bot

#

Otherwise you’ll be confused later on

pale spindle
#

the thing is that i dind't know this command and i got confused af

royal herald
#

can someone help me whit brainfuck

wheat mesa
#

[++[][}++

lyric mountain
#

let's say...he took it to a whole new level

boreal iron
feral aspen
#

For a bot's slash commands to appear in a guild, what is the maximum amount of bots can there be in that "said" guild?

lyric mountain
#

don't think there's a limit for that

feral aspen
#

Can 30 bot's slash commands appear in a guild?

pale vessel
#

Why not?

boreal iron
#

You can scroll through the list of apps and their commands

#

Entering a few chars of the command will also reduce the list and just show the possibles matches

feral aspen
boreal iron
#

Well for me the commands description is almost enough

#

But an help command with a few more details can't be wrong

coral sigil
lament stump
#

Mongoose (JS) related question:

How do I check, if a string in an object which is in an array is present?

Like, I wanna check, if a user has the achievement "First Command".

My Schema keeps it like this:

{
  name: "First Command",
  achieved: true
}, {
...
}
]```

And I want to check if the achievements array contains an object, which contains the `name` "First Command"
#

Without knowing the position of the object

#

I didn't try mapping the data / putting it in a for loop, cuz idk how that would help

feral aspen
#

Basically check if achievments have an achievment named as First Command?

lament stump
#

Yes

#

That's what I want to do

feral aspen
#

Indeed, .map() method will not be useful at this case, you can use another method named as .some().

#

As in for your code..

lament stump
#

But what do I return in the map()?

#

Filtering if the name isn't "First Command" then returning if the map contains "First Command"?

lyric mountain
#

map returns the mapped object

lament stump
#

Yeah

feral aspen
#
const achievements = [
  {
    name: 'First Command',
    achieved: true
  }
];

console.log(achievements.some((val) => val.name === 'First Command')); // True
console.log(achievements.some((val) => val.name.toLowerCase() === 'First Command'.toLowerCase())); // True
#

Here you go. :)

lament stump
#

Oh i forgot that .some worked like this

feral aspen
#

Most importantly, please understand the code before pasting it in.

lament stump
#

I'll try it c:

feral aspen
#

Would you like for me to explain it?

lament stump
#

Nah, I'm fine

feral aspen
lament stump
#

.reduce() is stupid too imo

feral aspen
#

Not stupid, but hard to learn.

#

You will use it a lot when it comes to sharding, in the near future.

lament stump
#

(my bot with 5 servers be like: tf is sharding bro)

feral aspen
#

Anyways, happy to help, enjoy the rest of your time.

lament stump
#

Thanks c:

feral aspen
#

:)

lament stump
#

c:

#

Yep, it worked. Thanks @feral aspen! (i even worked with .some() already, i just forgot that it existed)

pale spindle
#

yay thank u guys it's working now!

pale spindle
#

@lyric mountain tyyy

crystal wigeon
#

Hey quick question

pale spindle
#

@wheat mesa u too

crystal wigeon
#

Will my bot not work with prefix commands from next year??

#

Do I have to change to slash commands?

lyric mountain
#

depends

crystal wigeon
#

someone said discord won’t be sending raw messages?

#

Like bruh how am I gonna identify users or ids typed

lyric mountain
#

that's missinformation

crystal wigeon
#

thought so

lyric mountain
#

if u have message intent disabled u wont receive message content

#

message content as in CONTENT, not the message itself

#

imagine as if everybody sent empty messages

crystal wigeon
#

Yeah like if I type something like “$ bite”

#

Our

#

Phew

lyric mountain
#

bot would see ""

crystal wigeon
#

What

lyric mountain
#

empty 👏 message

crystal wigeon
#

It’s not gonna see “$ bite”?

lyric mountain
#

no content

#

zero

crystal wigeon
#

Tf

#

So I have to implement slash commands?

#

Like forced to implement

lyric mountain
#

you have 3 options

#

1 - use message intent, don't be verified, forget about 100+ guilds
2 - use message intent, be verified, live as normal
3 - don't use message intent, use slashes, that's it

crystal wigeon
#

Mm

#

I think I’m currently using message intent

lyric mountain
#

as an addendum, you need a VERY good reason to apply for message intent

crystal wigeon
#

Hmm

lyric mountain
#

to the point where ur bot wouldn't even be possible if using slashes

#

if its life depends on message content

#

anything less and you'll be denied

crystal wigeon
#

basically it’s life does depend on message content

lyric mountain
#

what does it do?

crystal wigeon
#

Simulate a battle?

#

Etc

#

There also commands to set teams where they type in numbers

lyric mountain
#

...only that wont suffice for discord

#

too little explained

crystal wigeon
#

mmm thinking what I should tell

#

There nothing else tho

lyric mountain
#

also, as it seems they require images/videos regarding it

crystal wigeon
#

If players want to invoke some commands they need to pass arguments

#

Yeah

#

I can do that

#

We got clips

lyric mountain
crystal wigeon
#

Is it easy to implement?

lyric mountain
#

kinda

crystal wigeon
#

Like I got args initially and do be passing it to inner funcs

#

Let’s see

#

Also

#

I just checked and I’m currently not using message content

#

Well the only thing I’m using is message.content to read the commands

#

and message.author

lyric mountain
#

then you're using message content duh

crystal wigeon
#

Also does slash commands help against self bots?

lyric mountain
#

they dont

crystal wigeon
#

Mmmm

#

Sed

#

Man it’s going to be a pain

earnest phoenix
#

If someone raids the interactions just wont go to your bot

lyric mountain
#

that still wont prevent selfbots

#

nothing can prevent selfbots

earnest phoenix
#

Except maybe forcing users to switch to slash commands and adding message intent

lyric mountain
#

still wont prevent selfbots

#

you can't tell apart normal and self users

#

and it's so easy for discord to actually prevent it

#

just make user endpoints not acessible anymore

#

voila, no more selfbots

earnest phoenix
#

Discord uses cloudflare
Doesn't cloudflare have bot protection?

lyric mountain
#

you're missing the point

earnest phoenix
#

Delete discord
No more selfbots

#

¯\_(ツ)_/¯

lyric mountain
#

if you login to an user account using the token there's absolutely no way of detecting whether it's an actual user or a selfbot

#

the only thing discord could do is making user endpoints private to the client

earnest phoenix
#

How?

#

You can still use chrome dev tools

crystal wigeon
#

Has discord fixed mobile login yet

lyric mountain
spark flint
#

nope

crystal wigeon
#

Like it keeps directing me back to login page tsktsk

spark flint
#

stinky discord

crystal wigeon
#

Mann

#

They ruining things more work for devs to migrate to slash commands

feral aspen
wheat mesa
#

It’s totally not like we’ve been given a massive warning ahead of time that we have to migrate to slash commands or anything mmLol

#

Slash commands are easier for users as well

spark flint
#

please help

quartz kindle
#

you are being haxx0red

fallen jetty
#

How to show the bot status in top.gg

azure lark
#

is there an express function that is like sendFile but you can sue a link to the file, such as, sendFile("https://images.dog.ceo/breeds/spaniel-welsh/n02102177_415.jpg")

split hazel
azure lark
#

yes

split hazel
#

There isn't, you would have to download/fetch that file yourself and then send the file buffer/saved file

azure lark
#

f, ok

next crown
#

Hi

boreal iron
earnest phoenix
#

Is there api discord.cpp

Found it

eternal osprey
#

Error: /root/gauntlet-v3/node_modules/canvas/build/Release/canvas.node: invalid ELF header tried npm install an npm rebuild.

#

went from windows > linux

willow mirage
#

why it doesn't show up?

#
client.user.setActivity(`Starting up`, { type: "PLAYING" });
coral sigil
willow mirage
#

ahh

#

v13

#

sorry

coral sigil
#

No problem

willow mirage
#

I thought the nodejs

coral sigil
#

So you need to set it like this in djs 13

client.user.setPresence({ activities: [{ type: "PLAYING", name: "Starting up" }] })
willow mirage
#

hmmm

#

lemme try

coral sigil
#

So the type is the type and name is the text

willow mirage
coral sigil
#

?

#

Doesn't work?

spark flint
#

you sometimes have to wait for it to update

#

thats what happens on my bot

coral sigil
#

That's true

spark flint
#

mine takes like 2 mins

coral sigil
#

And you can set the status too client.user.setPresence({ activities: [{ type: "PLAYING", name: "Starting up" }], status: "idle/online/invisible/dnd" })

boreal iron
#

If you use setPresence keep in mind to set a status as well

#

Yeah there we go…

coral sigil
#

Isn't it defaulted to online?

willow mirage
willow mirage
boreal iron
#

It think default is null which is invisible

spark flint
#

Not like that

#

Give it time to change on discord

boreal iron
#

But I’m not sure how djs13 handles that

willow mirage
#

well... nope

wheat mesa
#

Bots should be able to have an RPC change my mind

willow mirage
coral sigil
#

I just set the name and type and the bot's status is online

willow mirage
#

since X:19

#

now is X:23

coral sigil
#

z test to change the status

#

My bot changes the status always instantly

boreal iron
wheat mesa
#

Make sure not to change the status too fast, you’ll get ratelimited rather quickly

boreal iron
#

Max 5x in 20s I think

coral sigil
#

You shouldn't do anything fast with discord api :D

willow mirage
boreal iron
#

If I remember right

willow mirage
#

ok

coral sigil
#

change it to something else than online

willow mirage
#

I changed to idle

#

but discord doesn't change

coral sigil
#

Could you show your code? Just to make sure there isn't anything wrong there...

boreal iron
#

Where did you use the code?

coral sigil
#

Because that code works on my end

boreal iron
#

Is the bot already logged in when you set the presence?

willow mirage
#
const mongoose = require("mongoose");
const { WebhookClient } = require("discord.js");
const hook = new WebhookClient({token: process.env.WEBHOOK_TOKEN, id: process.env.WEBHOOK_ID});

module.exports = async (client) => {
    try {
        process.env.LOCAL ? null : client.user.setPresence({ activities: [{ type: "PLAYING", name: "Starting up" }], status: "idle" });
        client.send = require('../../utils/functions/sendMessage');
        client.error = require('../../utils/functions/error');
        await mongoose.connect(process.env.MONGO, {
            useNewUrlParser: true,
            useUnifiedTopology: true
        })
        await require('../../utils/cache/loadGuilds')(client);
        if (!process.env.LOCAL) {
            const embed = {
                color: "WHITE",
                description: `${client.user.tag} has been started`
            }
            await hook.send({embeds: [embed]});
            client.setTimeout(() => {
                client.user.setActivity(`@${client.user.username}`, { type: "WATCHING" });
                client.state = true;
            }, 5000);
        }
        console.log(`${client.user.username} is online - It took ${require("ms")((new Date() - client.startup), { long: true })}`);
        if(process.env.LOCAL){
            client.state = null;
        }
    } catch (e) {
        return require("../../utils/functions/error")(e, undefined)
    }
}
coral sigil
#

Where do you run this code from?

willow mirage
#

FUCK

#

the process.env.LOCAL is not defined

#

wait

coral sigil
#

If its not defined, it should still run

#

if we are talking about that check there

boreal iron
#

The embed says, bot has started and you’re calling the setPresence() method before already

#

Make sure it’s logged in and received the READY event

willow mirage
#

yes

#

I did client.isReady() too

#

it is says true

willow mirage
#

but everything work nromal

coral sigil
#

You could run the client.user.setPresence({ activities: [{ type: "PLAYING", name: "Starting up" }], status: "idle }) in the ready event just to make sure

willow mirage
#

the console.log("bot is ready") work

coral sigil
#

just to test

willow mirage
#

wdym

#

where?

#

in ready event?

coral sigil
#
  client.user.setPresence({ activities: [{ type: "PLAYING", name: "Starting up" }], status: "idle })
})```
coral sigil
willow mirage
#

but the ready event handler work normal

boreal iron
#

Also changing the presence two times in such a short frequency doesn’t make sense tho

coral sigil
#

yes, we are testing the code not the ready event

willow mirage
#

ok

coral sigil
#

The point is that you'll get the client that's ready from the ready event

willow mirage
#

ahh

#

now it work

coral sigil
#

Good!

dapper jasper
#

I need someone to make me code that will have make A role and give it to a person with administrator permissions server id: 883267709255688262 user id: 766993386112286793

willow mirage
#

but with client.on()...

coral sigil
coral sigil
#

so you have a ready.js file right?

#

And there's your ready event? Where did you put that client.on you were talking about?

willow mirage
#

in the index.js

#

directly

coral sigil
#

Yea okay. So the code I gave you doesn't work in your ready.js but works with client.on in the index.js?

willow mirage
#

yes

coral sigil
#

That's weird, could you send your event handler code?

willow mirage
#

they are normal

#

the messageCreate

#

and othwr events work

coral sigil
#

Could you still send it?

willow mirage
#

ok

#

const { readdirSync } = require("fs") module.exports = async(client) => { try { const cmds = []; const cmd = []; 		await ['client', 'guild'].forEach(async a => await readdirSync('./events/'+a).map(b => cmds.push(b) && cmd.push(b))); const load = dirs => { const events = readdirSync(`./events/${dirs}/`).filter(d => d.endsWith('.js')); for (let file of events) { const evt = require(`../events/${dirs}/${file}`); let eName = file.split('.')[0]; client.on(eName, evt.bind(null, client)); if(!cmds.includes(eName+".js")){ console.log(`Missing ${eName+".js"}`) 				}else if(cmds.includes(eName+".js")){ cmd.splice(cmd.indexOf(eName+".js"), 1); 				} }; }; load('client'); load('guild'); let value = true; console.log('--- LOADING ALL EVENTS ---') cmds.forEach(a => { 			if(!cmd.includes(a)){ 				console.log(`${a.slice(0, 1).toUpperCase() + a.slice(1)}: ✅`) 			}else if(cmd.includes(a)){ 				console.log(`${a.slice(0, 1).toUpperCase() + a.slice(1)}: ❌`) value = false; 			} 		}) if(!value) console.log('--- FAILED TO LOAD EVENTS ---'); return value; } catch (e) { return require("../utils/functions/error")(e, undefined) } };
earnest phoenix
#

lol

wheat mesa
#

What on earth

willow mirage
#

yeah..m

#

nobosy will understand it

#

it is on alien language

wheat mesa
#

On mobile it looks like a brainfuck one liner

coral sigil
#

That is true on pc too

willow mirage
#

im on mobile

#

cause just turn off my pc

coral sigil
#

Formatting it rn :S

coral sigil
boreal iron
willow mirage
#

the way I thingy to the variales are bad

#

the names...

coral sigil
#

Do you call this from the index.js?

willow mirage
#

yes

coral sigil
#

It is weird that this doesn't work...

willow mirage
#

yeah

#

I tried with out the .local

#

but still doesnt work

coral sigil
#

Could it be that it is the wrong client, because you need to await this in the index.js

willow mirage
#

i did await

#

it is not the event handler prbolem

coral sigil
#

Yes and that is exactly the problem

willow mirage
#

cause everything work normal

coral sigil
#

Yea because the other events doesn't need the client to be ready

willow mirage
#

well it is a async function tho

coral sigil
#

And you dont shard so there's no problems elsewhere

#

Yes it is, and it might be the problem

willow mirage
#

waiy what

#

what is the problem?

coral sigil
#

Because you await this, this gets run before the client.login

willow mirage
#

ohh

#

ahhh

#

damm ur right

coral sigil
#

And the correct client will never get passed into this

willow mirage
#

but my other bot work normal MegaThonk

#

witht the same logic

coral sigil
#

Yea because the other events dont need the client to be ready

#

or the code in them might i say

willow mirage
#

well i awaited it tho

#

maybe im lucky

coral sigil
#

You need to move this to the index js

#

that is where the correct client is

willow mirage
#

the handler?

coral sigil
#

or import the client here, but im not sure the importing will work

#

You cant pass the client as an argument to the event handler

wheat mesa
#

Reject CommonJS return to ES6

willow mirage
#
require('dotenv').config(); // Init .env file const { Client, Collection, Intents } = require('discord.js'); // Requires modules from d.js lib const client = new Client({ intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_WEBHOOKS, Intents.FLAGS.GUILD_MESSAGE_REACTIONS ], allowedMentions: { parse: ['users', 'roles'], repliedUser: true } }) // Init a Client for the bot // Init all caches informations client.guild = new Collection(); client.commands = new Collection(); client.parties = new Collection(); client.aliases = new Map(); client.categories = new Map(); client.categoryAliases = new Map(); client.limits = new Map(); client.startup = (new Date()).getTime(); client.state = null; (async () => { const commandsLoader = await require('./handlers/commands')(client); const eventsLoader = await require('./handlers/events')(client); const categoriesLoader = await require('./handlers/categories')(client); if(commandsLoader && eventsLoader && categoriesLoader){ console.log('--- LOGGING IN ---'); client.login(process.env.TOKEN).then(() => { console.log("--- LOGGED IN ---"); }) }else { return console.log('--- FAILED TO LOAD HANDLERS ---'); } })()

pls someone format it :>

#

this is the indexmjs

grim aspen
#

Oh boy I thought my phone fucked up formatting

coral sigil
#

What if you just did readdir and not readdirsync

#

so you dont need to await

willow mirage
#

i dunno

wheat mesa
#

Why... do you have your command aliases as a prop of your client...

willow mirage
#

where

wheat mesa
#

The world may never know

willow mirage
#

client.aliases?

wheat mesa
#

Yeah

#

My brain hurts to read this

willow mirage
#

well it is like this const command = client.commands.get(name) || client.commands.get(client.aliases.get(name)) @wheat mesa

coral sigil
#

Oh no your other handlers are also awaited

willow mirage
#

yeah

#

i will try to make it not async

coral sigil
#

Try to import the client first

willow mirage
#

nd then remove await

coral sigil
#

dont make big changes yet

willow mirage
#

I cant make changes

#

im on mobile

coral sigil
#

Go to your pc and export the client from index and import it to your event handler. And don't give it as an argument to the event handler

#

Idk if it'll work tho

willow mirage
#

wdym with export

coral sigil
#

you now have const client = new Client...

#

so you do export const client

willow mirage
#

like

coral sigil
#

then import it in the event handler

willow mirage
#

modile.export?

#

uhh ok that is another way to try

coral sigil
#

You can do module.exports = {client} i think as well

willow mirage
#

yeah

coral sigil
#

just add module.exports = {client} at the end of index.js

willow mirage
#

or just call it after login?

coral sigil
#

But you can't do your if check then

willow mirage
#

what if check?

coral sigil
#

I dont think that its possible to register the event listeners after you login

willow mirage
#

hmm

coral sigil
#

I haven't never done that

#

or tried

willow mirage
#

me2

coral sigil
#

put module.exports = {client} to the end of index.js

#

lets try that first

willow mirage
#

but then it already login

#

cause it login

#

then export

coral sigil
#

yea its the point

willow mirage
#

then why not call it after login? It is the same thing

coral sigil
#

and change const eventsLoader = await require("./handlers/events")(client);
to
const eventsLoader = await require("./handlers/events");

willow mirage
#

wair what

#

I dont understand

coral sigil
#

and then in event handler: module.exports = async (client) => {
to

willow mirage
#

then how u access client

coral sigil
#

module.exports = async () => {

#

you require the client in the event handler

#

const { client } = require('path_to_index.js')

willow mirage
#

wait so both file requires them self?

#

u need somehow call the event

#

after login or before login

#

before login then the export is undefined

coral sigil
#

the more sure way to getting it to work is not await the require in index.js

willow mirage
#

after login then u cant init a event

willow mirage
coral sigil
#

Why?

willow mirage
#

cause no async

coral sigil
#

You literally change the readdirsync to readdir

willow mirage
#

yeah

#

but as i remember there are more

#

right? I dunno

coral sigil
#

I think you only need to change those

#

Do you have your project public somewhere so I could test it

willow mirage
#

wait

#

lemme do it puvlix

coral sigil
#

It is not public yet

willow mirage
#

huh

willow mirage
#

cause u went to settings tab

coral sigil
#

True, sry

#

Can we continue in the DMs?

true ravine
#

In the latest node is there a way to allow uncaught promise rejections temporarily? (I'm assuming it would be with a flag in the node command)

#

Wait nvm found it

lyric mountain
#

but still, are u sure it'd be "temporary"?

true ravine
#

Yeah I just wanted to check something once without messing around with code

opaque acorn
#
TypeError: distube is not a constructor
#

?

wooden kindle
#

GLIZZY

opaque acorn
#
const distube = require('distube');
client.distube = new distube(client, {
  emitNewSongonly: true,
  searchSongs: true,
  leaveOnStop: false,
  leaveOnFinish: false,
  leaveOnEmpty: true
});

client.distube.on("addList", (message, queue, playlist) => {
  message.channel.send(`:tick_rail: Playlist añadida: **${playlist.name}** - **${playlist.songs.length}** canciones.`)
})

client.distube.on("addSong", (message, queue, song) => {
  message.channel.send(`:tick_rail: Cancion añadida: **${song.name}** - **${song.formattedDuration}**.`)
})

client.distube.on("playSong", (message, queue, playsong) => {
  message.channel.send(`:musical_note: Reproduciendo: **${playsong.name}** - **${playsong.formattedDuration}**.`)
})

client.distube.on("playList", (message, queue, playlist) => {
  message.channel.send(`:musical_note: Reproduciendo playlist: **${playlist.name}** - **${playlist.songs.length}**.`)
})

client.distube.on("error", (error) => {
  console.log(error)
})
#

its ok(?

coral sigil
# opaque acorn ```js const distube = require('distube'); client.distube = new distube(client, {...

Their example bot requires the distube library with different word casing: ```
const DisTube = require("distube");
client.distube = new DisTube(client, {
emitNewSongonly: true,
searchSongs: true,
leaveOnStop: false,
leaveOnFinish: false,
leaveOnEmpty: true
});

client.distube.on("addList", (message, queue, playlist) => {
message.channel.send(:tick_rail: Playlist añadida: **${playlist.name}** - **${playlist.songs.length}** canciones.)
})

client.distube.on("addSong", (message, queue, song) => {
message.channel.send(:tick_rail: Cancion añadida: **${song.name}** - **${song.formattedDuration}**.)
})

client.distube.on("playSong", (message, queue, playsong) => {
message.channel.send(:musical_note: Reproduciendo: **${playsong.name}** - **${playsong.formattedDuration}**.)
})

client.distube.on("playList", (message, queue, playlist) => {
message.channel.send(:musical_note: Reproduciendo playlist: **${playlist.name}** - **${playlist.songs.length}**.)
})

client.distube.on("error", (error) => {
console.log(error)
})

opaque acorn
#

ill try it

#
TypeError: Distube is not a constructor
#

nope

coral sigil
#

Have you done npm install distube?

opaque acorn
#

yes

coral sigil
#

Hmm, its really weird

#

I'll test a few things out and come back to you soon

opaque acorn
#

ok thx

wheat mesa
#

DisTube

coral sigil
#

:D I'm blind

#

lol, on my code the DisTube doesnt work also :D

opaque acorn
#
client.distube = new DisTube(client, {
                 ^
TypeError: DisTube is not a constructor
#

xd