#development

1 messages ยท Page 1695 of 1

timber fractal
#

thx for the help

raw pawn
#

how u make bot stay online : P

#

i so stoopid

waxen bough
#

it stays online. Unless it's not logged in or it throws an error

dusky sundial
#

Have you ever gotten your bot online?

raw pawn
#

yea but then after like 30 seconds it went offline :I

waxen bough
#

it didn't say anything in the log?

raw pawn
#

uhh i dont think so?

#

wait in the script or in discord?

waxen bough
#

in the script

pale vessel
#

in the java script

earnest phoenix
#

how can i check if a client is till active?

raw pawn
quartz kindle
#

how did you run your bot?

#

what did you do to start it?

raw pawn
#

it says logged in as my bots name :-:

quartz kindle
#

and after that it doesnt say anything anymore?

raw pawn
#

nope

quartz kindle
#

scroll up to the previous logged in message

#

and show what ot says after that

tacit sequoia
#

Repl PES_HyperReee

waxen bough
#

afaik if the red > appear in the end of console it means it's stopped

raw pawn
raw pawn
#

OH ITS ONLINE NOW

waxen bough
#

ohh

raw pawn
#

Uh

#

Thanks ig?

#

oh wait nvm its back to being offline

#

wait

#

imma try something

quartz kindle
#

it has to say something, it cant just do offline and not say anything

raw pawn
#

Its back online now lols

waxen bough
#

if repl.it doesn't detect activity in your bot they terminate its process

quartz kindle
#

thats why scroll up until you see what happened

#

the terminal, not the code

#

scroll up the terminal until the previous logged in message

#

to see what happened to the previous attempt

waxen bough
#

wait hold on did you use client.login()?

raw pawn
#

uh i somehow fixed it?

ornate bramble
#

Good morning
I need some help
I'm creating a bot but I can't add commands to it
If anyone can help me
I will be so pleased :emoji_39-14:

raw pawn
#

ooh wait

#

uh nvm sorry ^^

tacit sequoia
ornate bramble
raw pawn
ornate bramble
#

Okay thanks anyway

raw pawn
#

OK

#

hOW CAN U USE COMMANDS EVEN IF REPL.IT IS NOT OPEN??? TvT

waxen bough
#

and also it seems your bot won't do much other than replying to Hi

#

if you're the only one coding your bot then it's much better doing it offline

earnest phoenix
#

dude
this discord websocket heartbeat shit is so complicated
ive been trying to figure it out for half an hour and this is what i have rn: https://paste.mod.gg/abirezoluk.js

pale vessel
#

where is your break

earnest phoenix
#

oh f

earnest phoenix
#

ikr

tacit sequoia
#

Brain would explode

median moss
#

guys, I put this in my code to not allow people using it with bots, but it is still working.

if (user === user.bot) return message.reply("You can't rep a bot.")```
rare oasis
#

Hello
Can someone tell me what the alternative to discord.js that use less ram ? (not Eris ๐Ÿ™‚ )

earnest phoenix
#

oh and also i cant use await in a constructor so i had to do this bullshit to get the correct gateway url from discord:

this.ws = new WebSocket((() => {
            let url = "wss://gateway.discord.gg";
            (async () => (await (await fetch("https://discord.com/api/v8/gateway")).json()).url)().then(_url => _url != "wss://gateway.discord.gg" ? (() => {this.ws.close(); this.ws = new WebSocket(_url)})() : null);
            return url;
        })() + "?v=6&encoding=json");
earnest phoenix
#

you are checking if the user object is equal to user.bot

#

you should check if user.bot is true

median moss
crimson vapor
#

@rare oasis detritus or discord-rose

rare oasis
#

ohhh yeah it was detritus !

#

thanks bud

crimson vapor
#

detritus confusing af to me

#

same with eris tho ยฏ_(ใƒ„)_/ยฏ

median moss
#

ok

rare oasis
#

what about discord-rose ?

#

๐Ÿ˜›

pale vessel
tacit sequoia
median moss
#

it worked, thx @earnest phoenix

earnest phoenix
earnest phoenix
crimson vapor
cinder patio
tacit sequoia
#

Eris is .... different

crimson vapor
tacit sequoia
#

Than what I'm used to with Discord.js anyway

earnest phoenix
pale vessel
#

on phone rn

#

sad

crimson vapor
#

oh

raw pawn
#

guys what does it mean if ur bot doesnt work when the programing tab is closed and only works when its open? :I

pale vessel
#

you just need a webhook server

cinder patio
#

a webhook server is gonna use up less resources too

earnest phoenix
#

rly?

cinder patio
#

mhm. Only downside is that you don't get any info on guilds and stuff like that when you first connect

cinder patio
#

but you can always just make a request

earnest phoenix
#

ive already spent so much time on this shit, dont wanna rewrite

cinder patio
#

You'll only have to replace the websocket connection with an express server

#

or koa or fastify or whatever

#

Even better, you can just provide the middleware

#

let the user create the server

earnest phoenix
cinder patio
#
 let url = "wss://gateway.discord.gg";
        (async () => (await (await fetch("https://discord.com/api/v8/gateway")).json()).url)().then(_url => _url != "wss://gateway.discord.gg" ? (() => {
            this.ws.close();
            this.ws = new WebSocket(_url)
        })() : null);
        return url;
    })() + "?v=6&encoding=json");

This is... something

#

looks very unnecessary to me

crimson vapor
#

just use the correct ws url in the first place, no?

cinder patio
#

yeah

earnest phoenix
#

discord says you need to get a correct gateway url from their api (even tho it's the exact same shit everytime)

#

and i cant use await in the constructor

#

and if i use .then on the promise typescript will yell at me that public ws has no initializer

pale vessel
#

then make an async method

earnest phoenix
crimson vapor
#

method not function

cinder patio
#

public ws!: ... is make TS stop yelling

earnest phoenix
#

ty

crimson vapor
#
class Something () {
  constructor() {
    // some code
  }

  public async somethingElse () {
    // more code
  }
}```
#

no

#

huh

vivid fulcrum
#

you can have a static method (which you can make async) that acts as an initializer

pale vessel
vivid fulcrum
#

cosnt something = await Something.createAsync();

crimson vapor
#

fuck

#

no ()

#

right

#

whatever idc

vivid fulcrum
#

const

#

i hate mobile

crimson vapor
#

honestly same

earnest phoenix
#

ight how bout this:

public ws!: WebSocket;
constructor() {
    // ...
    this._setupWebSocket();

}

async _setupWebSocket() {
    let url = await (await fetch("https://discord.com/api/v8/gateway").json());
    this.ws = new WebSocket(url);
    this.ws.addEventListener("message", this._handleMessage);
}
vivid fulcrum
#

you're swallowing errors that way

#

best approach is the static async initializer

earnest phoenix
#

hm

#

ok

earnest phoenix
vivid fulcrum
#

correct

earnest phoenix
#

i could just put .catch on this._setupWebSocket();

vivid fulcrum
#

classes that need to do async work in the constructor should be initialized in an async context

earnest phoenix
#

do you intialize discordjs clients in an async context

vivid fulcrum
#

djs doesn't do what you do in the ctor afaik

earnest phoenix
#

my code doesnt even work lmao

#
error: TS2339 [ERROR]: Property 'json' does not exist on type 'Promise<Response>'.
        let url = await (await fetch("https://discord.com/api/v8/gateway").json());
vivid fulcrum
#

bc you're calling json directly on the result of fetch

#

not on the result of its awaiter

waxen bough
#

why do you use 2 await

vivid fulcrum
earnest phoenix
#
async _setupWebSocket() {
        let resp = await fetch("https://discord.com/api/v8/gateway");
        let { url } = await resp.json();
        this.ws = new WebSocket(url);

        this.ws.addEventListener("message", this._handleMessage);
    }
crimson vapor
#

is that why clients have a .login() function rather than just logging in when its created?

vivid fulcrum
#

no

crimson vapor
#

o

earnest phoenix
#

o

vivid fulcrum
#

that would go against all sane OOP conventions

earnest phoenix
#

um

error: Uncaught TypeError: this._heartbeat is not a function
                setInterval(_ => this._heartbeat(), this.heartbeat_interval);
#

but it is defined there

crimson vapor
#

bind

earnest phoenix
crimson vapor
#

bind the function

cinder patio
#

this.ws.addEventListener("message", this._handleMessage); <--- here

earnest phoenix
#

o

#

wtf

thread 'main' panicked
#

rest of the error:

'Error 'WebSocket protocol error: Sending after closing is not allowed' contains boxed error of unknown type:
  Protocol("Sending after closing is not allowed")', cli/errors.rs:35:7
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
crimson vapor
#

setInterval?

earnest phoenix
#

yeah

#

wasnt checking for ready state

#

but how the fuck is the function fired when it's not ready

smoky herald
#

Seems like the issue was too many reactions, I stopped getting the abort errors after disabling some reaction heavy commands and reaction autoclear

earnest phoenix
#

i still cant find the thing causing the error

lament rock
#

You should be routing your reaction handler through 1 reaction add event instead of 1 per

cinder patio
#

we can't either

vivid fulcrum
#

okay i was booting up my pc, but i wanted to show you why you should have a static async initializer

earnest phoenix
#
async _setupWebSocket() {
    let resp = await fetch("https://discord.com/api/v8/gateway");
    let {
        url
    } = await resp.json();
    this.ws = new WebSocket(url);

    this.ws.onopen = () => this.ws.addEventListener("message", this._handleMessage.bind(this));
    this.ws.onclose = console.log;
}

_handleMessage(event: MessageEvent) {
    let data = JSON.parse(event.data);
    switch (data.op) {
        // Hello
        case 10:
            this.heartbeat_interval = data.heartbeat_interval;
            setInterval(_ => this._heartbeat(), this.heartbeat_interval);
            break;
            // Heartbeat ACK
        case 11:
            this.got_last_heartbeat_ack = true;
            break;
    }
}

Both of these functions are only fired when the websocket sends a message i.e. only after the socket is open

vivid fulcrum
#

here's the reference code; https://paste.mod.gg/xulefulite.js
as you can see, the error is being swallowed where the async method is called implicitly, even if you added a catch there, you would still be allowing the creation of the class, even though a vital part of the class failed to initialize

the class which has an explicit async constructor boils the error to top level of the code, letting the user know that it had failed

earnest phoenix
#

IM GAY

#

i still dont understand what you mean by static async initializer

vivid fulcrum
#

look at the reference code

quartz kindle
#

gay

vivid fulcrum
#

oh wait

#

oop

#

i'm lacking a return this

#

there

earnest phoenix
#

uhh

#

i don get it

quartz kindle
#

you can also return the promise from the constructor afaik

#

and do await new Class()

vivid fulcrum
#

that works

earnest phoenix
#

so...

#

make a static async method in the class and use await Class().Method();

vagrant prairie
#

yo

#
``` anyone familiar with this?
#

i keep getting it

earnest phoenix
#

@vagrant prairie tl;dr the mongodb server said go away i dont like you and close the connection

vagrant prairie
#

i see

#

lemme look into my code

#

found it

vivid fulcrum
#

like tim said

vagrant prairie
#

mongoose.connection.close() comes multiple times

vivid fulcrum
quartz kindle
#

return new Promise also works

#

or make it a method and return this.method()

vivid fulcrum
#

damn there are so many interesting design patterns you can do with js

earnest phoenix
#

rewrote my entire code

vagrant prairie
#

good idea

vivid fulcrum
#

you're just catching the error thrown in the promise and... throwing it again

#

it won't error out the class

#

it will error the promise

vagrant prairie
#

pwd : yes

#

i keep getting topology error

earnest phoenix
#

how bout this:

constructor(options) {
  super();
  return (async () => {
     return await this.initialize();
  }).bind(this)();
}
quartz kindle
#

what are you trying to do?

earnest phoenix
#

i dont know

quartz kindle
#

i figured

earnest phoenix
#

resolve the promise and return the resolved value?

quartz kindle
#

return the promise itself

#

you cant resolve it inside the constructor

earnest phoenix
#

k

vivid fulcrum
#

also

quartz kindle
#

constructors are sync only

vivid fulcrum
#

you need to return this; in the initialize method

quartz kindle
#

you have to return the promise and have the user resolve it

earnest phoenix
#

and if somebody wants to create an instance of the class theyll do await new InteractionsClient()

earnest phoenix
vivid fulcrum
#

um

vagrant prairie
#

does anyne have mongo experience

vivid fulcrum
#

top level await isn't correlated to ctors being sync

earnest phoenix
vivid fulcrum
#

oh right

earnest phoenix
#
let client: InteractionsClient = await (new InteractionsClient(options));
vivid fulcrum
#

b o i

earnest phoenix
#

do i need the extra paranthesis

vivid fulcrum
#

do you wanna get slapped

#

also no

earnest phoenix
exotic willow
#

can someone help me with mongoose?

vagrant prairie
earnest phoenix
#

i love mongooses they're epic animals

#

also make for good databases

vivid fulcrum
#

mongeese

waxen bough
earnest phoenix
#

ยฏ_(ใƒ„)_/ยฏ

quartz kindle
#

geese are assholes tho

exotic willow
#

are you people trying to make a slash commands handler?

vivid fulcrum
vivid fulcrum
#

forEach is horrid and slow

earnest phoenix
#

pls forgive me

exotic willow
earnest phoenix
#

and it's not on npm

#

it doesnt even use node

#

it uses it's younger bro deno

vivid fulcrum
#

tldr it's because forEach needs to recomputate the callback function for every element and then fire that function which adds overhead and just really doesn't scale well at all

vagrant prairie
#

when u keep getting ignored

quartz kindle
#

forEach = for that creates functions

exotic willow
vivid fulcrum
#

i kind of agree?

waxen bough
#

it doesn't?

vivid fulcrum
#

sure thing, what's slowing you down are HTTP requests, not anything else in the code

#

you should still optimize your code though

#

especially for something like this, looping through commands etc

#

and especially in a library

#

the end user expects well performing code

exotic willow
earnest phoenix
#
TS2740 [ERROR]: Type 'Promise<void>' is missing the following properties from type 'InteractionsClient<options>': commands, endpoint, ws, s, and 29 more.
        return this.initialize(options);

i sometimes want to slap whoever made typescript

#

i have 69 errors
i have // @ts-ignore

gasp I have working code!

vivid fulcrum
#

i'm guessing you don't return this; in the intialize method?

vagrant prairie
#

can anyone help me (sad blob emoji)

quartz kindle
#

^

crimson vapor
#

deno js moment

quartz kindle
#

ts bad

exotic willow
#

exactly

waxen bough
exotic willow
#

it makes simple complex stuff 9000 lines

quartz kindle
vivid fulcrum
crimson vapor
#

its so nice just catching issues before they come up tho

vivid fulcrum
#

those 2 hours you'd spend trying to find a bug in a production website because you forgot that a variable is actually a number... would be 2 minutes with typescript

quartz kindle
#

yesterday i wrote a 200 line typing declaration and jsdoc for a single function

exotic willow
crimson vapor
#

what

vivid fulcrum
#

so no one

crimson vapor
#

thats a dumb thing to say

exotic willow
#

sorry I meant js is unfool proof if you give it to the wrong people

earnest phoenix
crimson vapor
#

c++ is unfool proof if you give it to the wrong people

earnest phoenix
#

vanilla js = bs
ts = bs

exotic willow
vivid fulcrum
#

everyone is bound to make a mistake of forgetting what type their variable is

earnest phoenix
#

it does

vivid fulcrum
#

typescript screams at you

earnest phoenix
#

but i want to use types and interfaces

exotic willow
pale vessel
#

how ignorant

vivid fulcrum
exotic willow
pale vessel
#

๐Ÿ˜ฑ

vivid fulcrum
#

yes, i hack with notepad

exotic willow
#

woah

#

can you teach me??

vivid fulcrum
#

just keep on plugging out the cables to your computer

#

if it doesn't work, scream at it

quartz kindle
#

no matter how good you are, you still make dumb mistakes

vivid fulcrum
#

if that doesn't work, punch your monitor

quartz kindle
#

youll just find them faster if youre good

waxen bough
exotic willow
waxen bough
quartz kindle
#

i tried quokka

#

didnt like it that much

exotic willow
#

that code hurts my eyes

#

I actually hate eslint

waxen bough
#

then nothing's gonna stop me from writing . this . code ( "ahha" ) ;

exotic willow
#

especially on vsc since it shows it's dumb errors in the terminal

#

what

#

ok

waxen bough
#

how do i exclude a folder

quartz kindle
#

eslit pls exclude "folder" kthxbai owo

earnest phoenix
#

oh

reason: "Rate limited."
opal plank
quartz kindle
#

thank

vivid fulcrum
quartz kindle
#

wait

#

dont you mean

#

repawted?

waxen bough
earnest phoenix
#

thanks discord for the rate limits

exotic willow
#

repowted

earnest phoenix
#

makes new botum

exotic willow
#

can someone help me with mongoose thou

quartz kindle
#

dont use mongoose

#

:^)

exotic willow
#

yes use mongoose

quartz kindle
#

aw

#

nW

exotic willow
#

shitty sql is shitty

vivid fulcrum
#

orms

quartz kindle
#

sqlite bae

exotic willow
#

everything that is sql based can go die in a hole

waxen bough
#

y

quartz kindle
#

lmao

exotic willow
#

its shit

#

its dog shit

quartz kindle
#

if its shit then why os it so fast

#

and so good

exotic willow
#

no

quartz kindle
#

and so ez

exotic willow
#

its not so good

#

its dog shit

opal plank
#

how so

exotic willow
#

mongoose is ez

quartz kindle
#

lmao

exotic willow
#

and fast

#

and online

opal plank
#

its shit

exotic willow
#

and cloud based

#

and better in every way

opal plank
#

is not an argument my dude

quartz kindle
#

mongoose is a clusterfuck

opal plank
#

define every way

exotic willow
#

sql is a clusterfuck

quartz kindle
#

xD

opal plank
#

everything you've been saying so far is vague

vivid fulcrum
#

but

#

you don't have to write sql at all

#

ORMs exist

quartz kindle
#

i mean

vivid fulcrum
#

best of both worlds

opal plank
#

also that

quartz kindle
#

mongoose itself is an orm

#

you cant really comoare sql dbs to mongoose

#

have ti comoare them yo mongodb

opal plank
#

bUt TiM, SqL iS ShIT

vivid fulcrum
#

also the fact that sql is a language

quartz kindle
#

ur shit

opal plank
#

wow

#

toxic

quartz kindle
#

:^)

#

i played league yesterday

#

made me toxic

opal plank
#

ah that explains

vivid fulcrum
#

yOu CHaNgED ๐Ÿ˜”

opal plank
#

my toxicity is usually brought fourth due to poor TS coding

earnest phoenix
#

@Mr Master#1250

vivid fulcrum
#

and then i gotta do global augmentation

opal plank
#

ikr!

vivid fulcrum
#

i don't like

opal plank
#

the worst is having to slap @obtuse osprey-ignore every fucking where cuz the types shipped with it are wrong

crimson vapor
#

LOL

opal plank
#

well, random ping

quartz kindle
#

xD

opal plank
#

ur fault for being named @ ts

crimson vapor
#

I love when that happens

opal plank
crimson vapor
#

yea hoenstly

vivid fulcrum
#

i think that person got pinged like 10 times in the past two days

#

here

#

just because of ts ignore

#

lmfao

opal plank
#

gonna switch my nickname to @ gmail

#

lets see how many pings we get

#

i dont think it parses it anymore

#

nope

#

wasnt there something else that parsed into mentions?

#

i recall having another thing apart from ts-ignore that made quite a few accidental pings

#

but thats beside the point

crimson vapor
#

I made @obtuse osprey-something my github alt name and I got spammed with emails

#

its funny

earnest phoenix
#

@obtuse osprey-ignore

crimson vapor
#

ill show when I get into the email

opal plank
#

its insanely infurating haivng to ts-ignore wrong interfaces

crimson vapor
#

LOL

opal plank
#

i dont like modifying other people's libs

raw pawn
#

Guysss

crimson vapor
#

pr it

raw pawn
#

i finally did it

cinder patio
#

yeah submit a pr or an issue

opal plank
#

i'll pr you to go watch the anime

earnest phoenix
#

@earnest phoenix -ignore

opal plank
#

cant be arsed to pr in all honesty

raw pawn
#

My bot is now in PERFECT condition

#

no more problems UwU

vivid fulcrum
#

did you delete all code?

opal plank
raw pawn
#

nope

opal plank
#

shouldnt you?

waxen bough
raw pawn
#

idk

raw pawn
vivid fulcrum
#

cant have bugs when there's no code in the first place :wesmart:

opal plank
#

fuck, its 9am, but goddamn i need a beer, literally woke up to 21 errors in prod due to a bad parser in someones lib

crimson vapor
#

bruh

#

its 9 am bro

#

don't do it

opal plank
#

gotta love it

#

age is just a number, time is just daylight

#

erwin - 2021

vivid fulcrum
#

we live in a society

opal plank
#

the mitochondria is the powerhouse of the cell

crimson vapor
#

Hotel? Shivaco

unreal estuary
#

age is a word

earnest phoenix
#

age is int

dusky mason
#

so i made a globalchat command

#

and i just have a question

#

i made it so you have to mention the channel that you want

crude moat
#

hey
my bot was working totally fine till yesterday
now it stopped responding
i rebooted it
and its still off
(no changes made in the code)

dusky mason
#

but i don't want it like that

#

how can i make it so that it automatically adds the channel to json file?

#

right now you have to do p!gcstart #channel

#

but i want them to do p!gcstart

#

and it adds their channel

#

here is the code of that section

#
        guild_id = ctx.message.guild.id
        channel_id = int(channel.strip('<>#'))
        # channel_id = ctx.channel.id
        with open('global_chat.json', 'r') as file:```
#

i tried to do it already in the #channel_id part

#

(commented part)

lusty quest
#

just save the message channel id

dusky mason
#

i do

#

uhh

#

im checking api

#

lol

vivid fulcrum
#

pls

#

stop using json as your db notlikenoot

dusky mason
#

oh @lusty quest

#

lemme try that

lusty quest
#

sounds right

#

but like cry said, dont use json as a db, will give you more headache than setting up a proper database when it starts to corrupt

dusky mason
#

oh i mean

#

it's just to store 1 id

#

then delete it

crimson vapor
#

is it stateless?

dusky mason
#

kind of

#

all it does is store

#

the channel id

#

and when they run the stop command

#

it deletes it

#

(and since not the most people use my bot) it's normally empty

lyric mountain
#

the code:

import System;
 
Console.log("Hello World");
vivid fulcrum
#

can't you just store that in a list then

dusky mason
#

because it's for different servers

vivid fulcrum
#

dictionaries

dusky mason
#

json is easier

#

also

vivid fulcrum
#

what

#

lol

dusky mason
#

didn't work

#

unless it's channel_id

crimson vapor
#

say its easier when it corrupts

dusky mason
#

oh yeah a file that says

#

{

}

lyric mountain
vivid fulcrum
#

it doesn't matter what the file contents are

#

you seem to not understand how r/w works

cinder patio
#

python has a built-in persistent storage

dusky mason
#

i mean if it "gets" corrupted there isn't much to replace

vivid fulcrum
#

you're also slowing down your code by a significant margin

crimson vapor
dusky mason
#

alright im not here for you guys to diss my code

#

im here for help

vivid fulcrum
#

lol

lyric mountain
#

that's...actual help

dusky mason
#

i didn't ask for that portion

vivid fulcrum
#

sucks to be you i guess

dusky mason
#

then ill go ask for help somewhere else

lyric mountain
#

they'll say the same if you say you're using json-db

dusky mason
#

at least they'll bother to help

lyric mountain
#

we are helping tho

copper cradle
#

just let their db corrupt, once it corrupts they'll regret everything

earnest phoenix
#

a.startbot

crimson vapor
#

@opal plank

earnest phoenix
#

a.startboz

copper cradle
#

what are you even trying to do

opal plank
waxen bough
#

Can my bot still be approved when I include this warning

#

wait ...at least 18 years of age correction

umbral zealot
#

You need to lock NSFW content so it only gets sent to NSFW typed channels

waxen bough
#

yes it does check it

umbral zealot
#

then your warning isn't relevant in any way since Discord already has the barrier to entry of clicking the "Yes I'm 18 let me in" button

olive rune
#

it has to be only nsfw channels, not if the user enabled nsfw for themselves :p

waxen bough
#

i gave admins option to disable it completely

umbral zealot
#

So, your setting and warning isn't necessary, though it is cool I guess

cinder patio
#

Why are you constructing strings in this way

umbral zealot
#

if someone didn't want nsfw content they could just... not create NSFW channels ๐Ÿ˜›

waxen bough
#

yeah i didn't think about that.

waxen bough
#

i usually create tables and that's the only clean way I know of

cinder patio
#
`text...\n...text`

That's not clean? ๐Ÿ˜•

crimson vapor
umbral zealot
#

Or just, y'know, ```js
const ErrorMessage = Hey you didn't turn on NSFW, do ${prefix}config nsfw on to do it. Also you agree I'm going to send you boobs, because that's how NSFW works, kid.;

#

because template literals support line returns ๐Ÿ˜„

waxen bough
#

ohh

near stratus
#

@waxen bough Remember you can't mention that your bot has nsfw content in the bot description

waxen bough
#

and i know i can't mention nsfw feature there

near stratus
#

then just do

if(message.channel.nsfw){return(false);}
#

and you're good to go

waxen bough
#

wait what

crimson vapor
#

why would you return without a response?

#

its fine to have nsfw in help menu and such

#

just not on the site

summer torrent
#

return (false) Thonk

waxen bough
#

haha when i was a newbie i do that

near stratus
summer torrent
#

nope it is return false

#

you don't need brackets

near stratus
#

brackets work so anyway

#

let's move on

summer torrent
#

how Thonk

near stratus
#

let's move on

summer torrent
#

oh wait

waxen bough
#

hhaa

summer torrent
#

this is for ASI

near stratus
summer torrent
near stratus
#

@summer torrent it works without brackets too btw

summer torrent
#

yes

near stratus
#

but brackets look cooler (otherwise it'd look like python {without any brackets})

cinder patio
#

You can wrap any expression (or a list of expressions) in brackets, that's why they work

#

I don't really like it cause it looks like it's calling a function, I only do it when I'm returning a react component

tired panther
#

what does thoose error means
I wanted to log out a file import (require) and wanted to log it out and it gives me this

earnest phoenix
#

what's the difference between git fetch and git pull

opal plank
crimson vapor
#

ban them from what

#

I don't understand

opal plank
#

yes

crimson vapor
#

ok

summer torrent
# earnest phoenix what's the difference between git fetch and git pull
freeCodeCamp.org

Git pull and fetch are two commands that are regularly used by Git users. Letโ€™s see the difference between both commands. For the sake of context, itโ€™s worth remembering that weโ€™re probably working in a clone repo. Whatโ€™s a clone? It's simply a duplicate of another

waxen bough
#

what's ts-nocheck

opal plank
#

it basically skips checking on that file

summer torrent
#

tells compiler to ignore iirc

opal plank
#

ts-ignore is for the next line to ignore

waxen bough
opal plank
earnest phoenix
waxen bough
#

hahahehihohu

opal plank
#

your sanity defeats the purpose of your coding life

earnest phoenix
latent heron
#

time to study HTTP status codes for proper REST API integration

opal plank
#

true man just retun 200 with the body containing the error

latent heron
#

lmao christ

near stratus
latent heron
latent heron
#

internet monetization when

opal plank
#

deal

#

making money of using api

#

hell yeah

#

its like lambdas, but reverse

waxen bough
#
{
  "code": 200,
  "data": "task failed successfully"
}
opal plank
#
{
  "code": 402,
  "data": "Credit Card payload not available or invalid, please provide a valid credit card in order to request to this api"
}```
near stratus
#

the best idea I could get

craggy hill
#

can anyone help me in node.js language for event that executes on variable change

#

I don't want to add Add Message even

opal plank
#

@craggy hill use getters/setters

#

in your case, setters

craggy hill
#

zero two

opal plank
#

its not zero two...

#

its ME!ME!ME!

#

but anyway

craggy hill
opal plank
waxen bough
#

Default prefix is ":" and it can be changed. Do I just write : (default)

opal plank
#

this chick makes zero two look like an innocent child

craggy hill
#

@opal plank actually I saw this on phut hon

opal plank
earnest phoenix
craggy hill
opal plank
#

i love how i used google as a synonym for search

waxen bough
#

goodle

earnest phoenix
#

search synonyms: google, lookup, bing, googol, 10^100

river panther
opal plank
river panther
#

yes ik that

opal plank
#

there, i explained the joke, now its 1000x funnier

river panther
#

i can see it in myself

#

AHAHAHAHAHAHAHAHAA

copper cradle
#

what's adelinquent account

opal plank
neat beacon
#

Is there a problem by using those bot hosting sites instead of the whole coding thing? I'm a lazy person ;w; Also my bot needs to have admin permission, and this isnt because i want, the hosting website makes the bot request that, is it a problem? cause if it is i think i shall search for other bot hosting or try to make my own bot from 0.

copper cradle
crimson vapor
#

@opal plank :loli_dance: moment

fierce ether
#

can you extend MessageEmbed?

copper cradle
#

ofc

#

you can extend any class you want

fierce ether
#

i know how to extend message but how do you extend message embed?

#

MessageEmbed.prototype = async function?

copper cradle
#

class X extends Y

lament rock
#

modifying the prototype chain manually NotLikeCat

near stratus
# neat beacon Is there a problem by using those bot hosting sites instead of the whole coding ...

Are those bot hosting sites bad ?
YES
Before you learn how to code ask yourself why do you need a bot for.
If you need a bot for your personal server or maybe to flex you can use those services.
But if you're actually series about making a bot (commercially) then DON'T USE EM
Take some time, learn to code then make one yourself. (Coding is not like rocket science or something, You'll only need 3 braincells to learn how to code)

copper cradle
#

coding's pretty easy actually

#

u just gotta be willing to learn

#

once u get the hang out of it you'll be coding bots in no time

opal plank
copper cradle
#

then you'll abandon them for years

#

and never come back

#

and turn into a white name bc some mf stole your co-owner's account and deleted the bot from top.gg

#

totally not me

near stratus
earnest phoenix
#

can someone help me with jda?

near stratus
#

what's jda ?

earnest phoenix
#

Java discord api

#

so there is something missing but what?

vivid fulcrum
#

ok prettier chill

quartz kindle
#

5/7

earnest phoenix
#

@quartz kindle u know jda?

quartz kindle
#

no

earnest phoenix
#

Someone?

copper cradle
#

just ask the goddamn question

#

somebody will help

earnest phoenix
copper cradle
#

do you get any errors coming from maven? how do u know there's something missing

deep robin
#

Can someone help me make my bot send embed links? (I use python)

copper cradle
#

just send the link MegaThonk

deep robin
#

I mean for like help messages tho

pale vessel
#

embed links as in embeds

#

question mark

copper cradle
#

embed links? do u mean markdown links?

deep robin
#

No, not links

#

For help messages

marble kraken
dusky sundial
#

what do you mean?

deep robin
marble kraken
#

the response for posting stats POST /bots/:bot_id/stats ... is not { "voted": 1 } is it? ๐Ÿ˜‰

dusky sundial
#

But the example response is for /bots/:bot_id/check?userId=:user_id

marble kraken
#

exactly .. its wrong

dusky sundial
marble kraken
#

example response is squarely in the Post Stats subheading

dusky sundial
#

Ah, I see what you mean

#

It's under the wrong title

#

You can report the issue on github if you want

earnest phoenix
#

How will I be able to check if the entire message contains a word from the getResult variable (which is an array).

I have use : if(getResult.includes(message.content)){ but its only for the first word

#

how can i do please

tacit sequoia
#

Could use a for loop

#
for (var i = 0; i < getResult.length; i++){

if (getResult[i].includes(message.content)){
//CODE TO RUN
}
}
#

Did that on my phone so caution, lol

cinder patio
#

you can also use some

#

getResult.some(r => str.includes(r))

#

more like

#

Wait

#

getResult.includes(message.content) should already do the job, kinda?

#

You'll have to split the message.content so you don't detect stuff like h3ueh3uheworduwhd3uhe3

const wordsFromMsg = message.content.split(" ");
getResult.some(w => wordsFromMsg.includes(w));
earnest phoenix
#
explore_messages = [
  "You explored the edge of town and made {} dollars and likes! "
    ]
#

How do I make another value show 8nbetween and^likes

#
document.getElementById("btn6").onclick = function() {
    
}```
#

i wanna if this button is clicked transfer me to next page(i have a second.html file)

vivid fulcrum
#

can i introduce you to react

umbral zealot
earnest phoenix
#

wut

#

ok

umbral zealot
#

understanding why react is fucking awesome requires for someone to put in the time

frigid mountain
#
const Discord = require('discord.js')

module.exports = { 
    name: '42ball', 
    description: '42ball <mesage>', 
    run(message, args){ 
    const sayMessage = args.join(" ")
        message.channel.send(randomMessage);
    }
}
const messages = [
    "Yes you big dummy",
    "No you sicko path",
    "mmm... maybe?",
    "Do what you have to do",
    "Yep",
    "Nope",
    "Are you transgender?",
 
];

const randomMessage = messages[Math.floor(Math.random() * messages.length)]; 

was suppose to send random messages but it sends the same ?

umbral zealot
#

put it in the function, not outside, so it selects a differetn random message every time

earnest phoenix
#
document.getElementById("btn6").onclick = function() {
    location.assign("https://main.html")
    location = "http://second.html";
}```
#

like this?

umbral zealot
#

that would be redirecting to a domain called main.html

pale vessel
#

why do you need js for that

earnest phoenix
#

ill put relative oath

umbral zealot
#

well if you want to know if that's correct, you know what to do, right?

earnest phoenix
#

didi it

frigid mountain
earnest phoenix
#

it workd

frigid mountain
umbral zealot
#

Ok so just take the variable and put it in the embed?

#

if you know how to use a variable and you know how to make an embed, you know how to put 2 + 2 together

frigid mountain
#

l

umbral zealot
#

don't make me link to my learnjs message again

frigid mountain
#

k

sand walrus
#

guys, how i send a code or errors ??

#

in this chat

cinder patio
earnest phoenix
#

3 "your laguage" code here 3

umbral zealot
#

```js
your code here
```

earnest phoenix
#

yeah

#

and error

#

error

sand walrus
#
                           ^

TypeError: Cannot read property 'hasPermission' of null```
umbral zealot
#

Message.member is null because your member isn't cached

#

Fetch them

opal totem
#

Have been toying with d.js and sms / tel links, apparently discord doesn't like to hyperlink sms:some number here or tel:some number here anyone got a workaround for that one.

sand walrus
#

i use this fo clear message but "spawn" this error...

umbral zealot
#

Ok, so, fetch the member

#

it returns a promise so you have to await it

cinder patio
#

message.member will be null if it's a system message, no?

umbral zealot
#

yeah but this is in a command so a system message's never gonna trigger it

cinder patio
#

ah

umbral zealot
#

unless Discord started sending system messages in guild channels saying !clear 100 kekface

sand walrus
#

i send here the code that i used but the text in " " are italian...

#
        if(!message.member.hasPermission("MANAGE_MESSAGES")){
            message.channel.send("non hai il permesso!")
            return;
        }
    
        if(!message.guild.me.hasPermission("MANAGE_MESSAGES")){
            message.channel.send("Non ho i permessi per farlo!")
            return;
        }
    
        var clear_count = message.content.slice(7);
        clear_count = parseInt(clear_count);
    
        if(!clear_count){
            message.channel.send("Inserisci un numero valido!")
            return;
        }
    
        if(clear_count > 250){
            message.channel.send("Massimo 250")
            return;
        }
    
        message.channel.bulkDelete(clear_count, true);
        message.channel.send("Ho eliminato " + clear_count + " messaggi")
        .then(msg =>{
            msg.delete({timeout:2500})
        });
    };```
pale vessel
#

return moment

umbral zealot
#

Are you ignoring my solution or do you not understand it?

pale vessel
#

also, maximum is 100, not 250

#

if you want more than 100, use loops

umbral zealot
#

Gotta love when I give a straight answer and I get ignored.

sand walrus
#

ok i try but i have the previous error...

umbral zealot
#

because it doesn't show in that new code you just pasted

craggy pine
#

I'm not doing anything against TOS with this question but asking since we are clustering...

Can a bot DM a user if the user doesn't share a server with the bot?

Cluster 1 has shards 1, 2 ,3
Cluster 2 has shards 4, 5, 6

Can a bot still technically be able to dm a user from cluster 1 to a user in cluster 2? Idk if that makes sense. KEKW

umbral zealot
#

no, the bot cannot DM a user it does not share a server with.

craggy pine
#

Aight good to know ty.

umbral zealot
#

However

#

ALL DMs are handled by Shard 0

#

And if your bot is in the same server it doesn't matter if they're not in the same shard

craggy pine
#

oh?

cinder patio
#

Actuallyyyyyyy

lost heath
#

hello. does someone know how i can make a node.js file send the command npm start in a specific folder?

cinder patio
#

sending a DM is a HTTP request

#

shards don't matter

umbral zealot
#

oh right sending wouldn't matter. that's true

#

but receiving is shard 0

cinder patio
#

shard 0 only receives DMs though

pale vessel
#

๐Ÿค“

lost heath
#

hmm. okay

cinder patio
#

exported by the child_process module

earnest phoenix
#

is it possible a bot one to get into it?

cinder patio
#

yeah

earnest phoenix
#

...

cinder patio
#

I know it's possible I can't give you any more info because I've never tried doing it myself

frigid mountain
#
const Discord = require('discord.js')

module.exports = { 
    name: 'quiz', 
    description: '42ball <mesage>', 
    run(message, args){ 
    const sayMessage = args.join(" ")
const messages = [
    "What is the most common colour of toilet paper", 
    "Henry VIII introduced which tax in England in 1535?",
    "The average person does what thirteen times a day?",
    "Who invented the word vomit?",
    "What is Scooby Dooโ€™s full name?", 
    "**True or false:** You can sneeze in your sleep",
    "who was the first black president of United states",
 
];

const randomMessage = messages[Math.floor(Math.random() * messages.length)]; 
   
       message.channel.send(randomMessage)
    }
}

How do I make it so when the bot sends a random quiz after 15 seconds it sends the answer for the quiz

lost heath
#

but like... once the bot is ready.
i need it to go into the folder ./myapp and run the command npm start

cinder patio
#

Make sure to cancel the timeout when the user answers

cosmic forum
#

Anyone know if it's possible to make <a href="link">text</a> POST instead of GET.

vivid fulcrum
#

only via js

cosmic forum
#

ah ok

vivid fulcrum
#

depending on what you want, you can maybe try html5 forms

cinder patio
#

pass that to the exec function, replace path with the actual path and you're done

lost heath
#

i still have no idea how the exec function works

cinder patio
#

have you tried reading the docs

lost heath
#

yes

#

i understood nothing

cinder patio
#

So you understand absolutely nothing?

lost heath
#

basically

cinder patio
#

Nothing from the examples, too?

lost heath
#

i looked at it. looked back at my code. and had no idea what to do

cinder patio
#

you literally just call it with the command you want to run

#

and you're done

lost heath
#

i still have no idea what im looking at or where to put it

cinder patio
#

That sounds like a you problem ๐Ÿ˜•

lost heath
#

obviously

earnest phoenix
#

Well, anyone knows where I can learn to develop bots in python?

pale vessel
#

do you not know how to use a console?

earnest phoenix
cinder patio
#

You should start with a general python guide / tutorial

#

and then move to bot development, it'll make your life a lot easier

#

That is if you don't know python of course

#

if you do then look up a bot tutorial

sand walrus
#

i don't understand it

earnest phoenix
frigid mountain
# cinder patio Instead of storing only the questions in the array, store objects containing the...
const Discord = require('discord.js')

module.exports = { 
    name: 'quiz', 
    description: '42ball <mesage>', 
    run(message, args){ 
    const sayMessage = args.join(" ")
const questions = [
    {questions: "What is the most common colour of toilet paper", answer: "white"},
    {questions: "Henry VIII introduced which tax in England in 1535?", answer: "beards"},
    {questions: "The average person does what thirteen times a day?", answer: "Laugh"},
    {questions: "Who invented the word vomit?", answer: "Shakespeare"},
    {questions: "What is Scooby Dooโ€™s full name?", answer: "Scoobert Doo"}, 
    {questions: "**True or false:** You can sneeze in your sleep", answer: "No you cant"},
    {questions: "who was the first black president of United states", answer: "Barack Obama"},
 
];

const randomMessage = messages[Math.floor(Math.random() * messages.length)]; 
   
       message.channel.send(randomMessage)
    }
}

how to I use the setTimeout ?

cinder patio
#
const timeout = setTimeout(() => {
   message.channel.send("...");
}, 60000); // 1 minute

For example

#

and you do clearTimeout(timeout) to prevent it from it getting executed

#

Also message.channel.send(randomMessage.question) and questions.length

earnest phoenix
#

Help, the user counter of my botinfo command does not count all the users I have, what do I do?

#

This is my code

cinder patio
#

Not all users get cached

copper cradle
#

use the built in embed class tho

crimson vapor
#

users is a fucked up metric imo

#

since not all members of guilds are "users"

copper cradle
#

yeah, and most people don't care about the user count of your bot anyway

cinder patio
#

You know what would be a cool metric, average users per guild

crimson vapor
#

something like taco shack can say they have x users because you need to create a shack

cinder patio
#

do that instead

copper cradle
#

I'd rather know the command usage stats rather than my users

crimson vapor
#

then you aren't a user

frigid mountain
# cinder patio Also `message.channel.send(randomMessage.question)` and `questions.length`
const Discord = require('discord.js')

module.exports = { 
    name: 'quiz', 
    description: '42ball <mesage>', 
    run(message, args){ 
    const sayMessage = args.join(" ")
const questions = [
    {questions: "What is the most common colour of toilet paper", answer: "white"},
    {questions: "Henry VIII introduced which tax in England in 1535?", answer: "beards"},
    {questions: "The average person does what thirteen times a day?", answer: "Laugh"},
    {questions: "Who invented the word vomit?", answer: "Shakespeare"},
    {questions: "What is Scooby Dooโ€™s full name?", answer: "Scoobert Doo"}, 
    {questions: "**True or false:** You can sneeze in your sleep", answer: "No you cant"},
    {questions: "who was the first black president of United states", answer: "Barack Obama"},
 
];

const randomMessage = question[Math.floor(Math.random() * questions.length)]; 
const timeout = setTimeout(() => {
   message.channel.send(answer);
}, 15); // 1 minute
   
       message.channel.send(randomMessage)
       
    }
}

question is undefined

cinder patio
#

It's questions

#

you've defined the array as questions

#

Also the second parameter of the setTimeout function is the time in milliseconds, not seconds

#

Also, you want to use awaitMessages to await the user's response and check if the answer is correct or not

#

And if the user has answered, cancel the timeout

tulip ledge
#

is there a way to add a "copy to clipboard" in a discord embed?

cinder patio
#

no

tulip ledge
#

sad

prime glacier
#

TypeError: methods.has is not a function

cinder patio
#

I'm wondering if branchless javascript is faster than regular ifs

prime glacier
#
const methods = ['test']
if(!methods.has(msg.content)) msg.reply('abhe saale')

error

TypeError: methods.has is not a function```
cinder patio
#

it's .includes

prime glacier
#

if(!methods.includes(msg,content))?

#

like this

#

?

cinder patio
#

yes

prime glacier
#

ok thanks

frigid mountain
cinder patio
#

Read the docs

boreal iron
#

finally itโ€™s done

earnest phoenix
#
const moment = require("moment")

module.exports = (client, err) => {
    
    client.channels.cache.get("825012560138076232").send("Date de l'erreur : `"+moment().format('MMMM Do YYYY, h:mm:ss a')+"`\n\nErreur : `"+err+"`");

}

All my events work but my error event doesnโ€™t work, why?

vivid fulcrum
#

you shouldn't log errors to discord anyway

neat beacon
#

tests with python language

frigid mountain
#

I'm so freaking confused now

neat beacon
cinder patio
#

if your bot gets denied you just have to wait a few weeks to submit it again

neat beacon
#

Same cooldown?

cinder patio
#

I dunno

#

ask a reviewer

#

probably still a cooldown though

neat beacon
#

k

earnest phoenix
ancient nova
#

does anyone know why an on error event might not work

umbral zealot
#

maybe it's not getting any error? lol

thin apex
#

anyone know how to record audio from a voice channel in discord.js?

main trench
#

Does anyone know of a way to log categories I've tried message.category.id and a few other variations of that but no luck. I've looked on the docs as well but haven't found anything that looks like what I'm after

pale vessel
#

What category

main trench
#

Channel categories

pale vessel
#

then message.channel?

main trench
#

I'm trying to log their id's using a command

pale vessel
#

message is message

#

not a channel

main trench
pale vessel
#

no, message.channel

#

where are you getting the channel from

main trench
pale vessel
#

how did you create the channel

#

you can provide an option to set the category id

main trench
#

thats how the channel is being made

#

and thats how the category is being logged

#

im wondering if there is a more ideal way of logging it

pale vessel
#

what are you stuck on?

#

for ideal way, create the channel along with the category id

#

you can reduce your requests that way

umbral zealot
#

I wouldn't advise using the username to create a channel

main trench
#

tag wasnt quite what i wanted thats why i use username

umbral zealot
#

cuz, taking a username at random, what do you think the channel name's gonna be on ๐—š๐—ฎ๐—น๐—ฎ๐˜…๐—ถ ๐—ฒ๐—น ๐—ฝ๐—ฒ๐—น๐—ถ๐—ด๐—ฟ๐—ผ๐˜€ ?

#

because that ain't alphanumeric, which is the only thing that can go in channel names

main trench
#

hmm what would you suggest in place of username?

umbral zealot
#

ID, usually

pale vessel
#

id

umbral zealot
#

hold up one damned second since when do channels accept unicode ia_think_thonk

main trench
#

interesting

blissful coral
#

So I have a array

quartz kindle
#

so you have an array

umbral zealot
#

yeah actually that's real interesting for unicode-like usernames, but... like what about that weird owo?

#

I did not expect that channel name

blissful coral
#
chosenroles = [];
for() {
chosenroles.push({label: role.name, value: role.id })
} //my loop stuff

#

How can I search for a role ID inside of that array?

umbral zealot
#

find()

#

find(role => role.value === 'some id')

main trench
#

i guess i could make a category then a channel and parent it that way. Not what im looking for but should stop any errors

blissful coral
#

so if I am doing a filter

#

guild.roles.cache.filter(r => r.id !== guild.id && chosenroles.find(role => role.value !== r.id))

umbral zealot
#

yeah probably!

#

or actually in this case maybe .some instead of .find - same code, jsut different method

#

so you get a boolean

quartz kindle
#

you want to filter by what?

#

roles that are chosen or roles that are not chosen?

blissful coral
#

Ok ok

#

So

quartz kindle
#

try running the bot in your own pc

#

try running a barebones version of it

#

try making a request to /gateway/bot with your bot's token in the authorization header and see what response it gives

#

ye

blissful coral
#

Anyone here by chance used SelectPure before?

quartz kindle
#

do custom authorization

#

and do it like this: Bot 7n38723n97y29c3y579237nc92735c

#

so you're cloudflare banned

#

what do the headers say?

#

show them all

#

theres nothing sensitive there

#

huh, theres no retry-after?

#

what was the value?

fierce ether
#

TypeError: this.client.on is not a function could mean what?

quartz kindle
#

weird

#

try contacting discord support then

umbral zealot
#

would mean this.client isn't actually a discord client

#

oh wait this is the actual discord app?

#

no confusing different things here

earnest phoenix
#

someone can help me ? (dm me pls)

umbral zealot
umbral zealot
#

no one wants to be responsible for single-handedly resolving all your issues in DMs, man.

quartz kindle
#

(unless they're paid for it)

umbral zealot
#

yeah but no one can afford my rates ๐Ÿ˜›

quartz kindle
#

many can, they just dont want to

earnest phoenix
#

I need the bot to send a message to a different member every 30 sec

quartz kindle
#

theres rich kids everywhere

#

:^)

#

what message, which members, which discord library

earnest phoenix
#
client.guilds.cache.forEach(guild => {
           guild.members.cache.forEach(member => { 
            setTimeout(() =>  { 
            member.send("test")
        }, 30000)
        });
           });
quartz kindle
#

nonono

umbral zealot
#

to don't do that

quartz kindle
#

that will send thousands of messages at once

umbral zealot
#

that's spamming everyone

earnest phoenix
#

yes :/

umbral zealot
#

use setInterval and choose a member at random from the cache in that interval

#

thjough if you're gonna do that make sure they have a way to opt-out

quartz kindle
#

use a recursive function or a for loop with async/await

earnest phoenix
quartz kindle
#
// recursive function
function bla() {
  doseomthing()
  setTimeout(() => {
    bla();
  }, 30000)
}

// for loop with async/await
for(let member of guild.members.cache.values()) {
  doseomthing();
  await new Promise(r => setTimeout(r, 30000))
}
#

tell them you have been cloudflare banned but there is no retry-after information about when the ban will be lifted

earnest phoenix
#

ow ok