#development

1 messages · Page 1483 of 1

mellow kelp
#

wdym by valid?

earnest phoenix
#

an existent ID

opal plank
#

fetch

earnest phoenix
#

an id that can be dmed

mellow kelp
#

cache.get or fetch

opal plank
#

wait what

#

why would you dm a user?

earnest phoenix
#

for responding suggestions

opal plank
#

hmmm aight

mellow kelp
#

yea dming isn't too bad

#

i dm users for voting rewards

opal plank
#

there isnt much you can do since they might not have dm's open

#

its going to have to be a try/catch

#

there isnt a very reliable way afaik to check if a user is dm'able

#
users.fetch(id).then(u => u?.send(text).catch(console.error)).catch(console.error)```
#

thats the shortest mess i can think of right now

mellow kelp
#

the virgin console.error vs the chad console.trace

opal plank
#

or just log it

opal plank
earnest phoenix
#

but

mellow kelp
#

good point KEKW

earnest phoenix
#

i wanna check if the number introduced is a valid ID

mellow kelp
#

well

#

first check if its a 18-digit number

opal plank
#

wrong

mellow kelp
#

o

opal plank
#

1 is a valid id

mellow kelp
#

rlly

#

gasp

opal plank
#

also there are discord ids with 17 and 16 length

earnest phoenix
#

ID 1 is clyde

opal plank
#

^^

#

the best you can do is check if tis a number, and then dump it into the API to see if it returns a user

sudden geyser
#

Can you even fetch Clyde

mellow kelp
#

maybe

earnest phoenix
#

There are IDs that are few chars in length, but not exposed to the rest API

mellow kelp
#

maybe not

sudden geyser
#

I swear you could then you couldn’t

earnest phoenix
#

You can't

#

IDs that are exposed to the REST API are at least 17 to 19 chars in length

uncut swallow
#

hi

#

xd

earnest phoenix
#

Hey sandwich

#

🥪

earnest phoenix
# opal plank the best you can do is check if tis a number, and then dump it into the API to s...

cause i used this for check if the channel's ID is valid

if (isNaN(channelS)) return message.channel.send(':warning:Debes proporcionar una ID, evita usar letras o palabras:warning: **vuelve a ejecutar el comando para intentarlo nuevamente.**');
    let CanalReal = guild.channels.cache.has(channelS)
    if (!CanalReal) return message.channel.send(':warning:La ID proporcionada es inválida o pertenece a otro servidor:warning: **vuelve a ejecutar el comando para intentarlo nuevamente.**')
opal plank
#

welcome to wendies, how may we help you today?

earnest phoenix
#

Did you realize that if statement would always pass right

#

Because IDs are strings

mellow kelp
#

hes using it on user input i think

earnest phoenix
#

You can just

earnest phoenix
#
/^\d{17,19}$/.test(<User input>)```
opal plank
#

message has a mention input

#

its much easier to work with since im fairly certain discord sends you the channel its in

earnest phoenix
#

not mention input

opal plank
#

but why?

earnest phoenix
#

it uses the channel's ID

opal plank
#

why?

mellow kelp
#

just get the channel id from the mention if that's what you want

earnest phoenix
#

idk i just made that

opal plank
#

i ask why because of 2 things

#

first, mentions are easier to deal with

earnest phoenix
mellow kelp
#

then use user mentions

opal plank
#

second, if you are fetching info about a channel in a different server, thats not cool

earnest phoenix
#

You can make it work by both mentions and IDs

opal plank
#

the only reason why you would use id's realistically is to use another channel thats not in the guild, otherwise its much better to use mentions. To grab a channel ID you need to have developer mode on, which most users dont. However, mentions are enabled by everyone by default

earnest phoenix
#

Just get the channel from mention or get the channel from cache by using ID

#

And check if it's valid

opal plank
#

alright, time to eat and then code until my fingers or my eyes give up again

mellow kelp
#

sounds like fun

carmine summit
#

How do I create a new package in JDA

shrewd hazel
#

How to change bot permission

round vortex
#

i feel like you should maybe clarify your question more MegaThonk

shrewd hazel
#

How to change bot permission request

round vortex
#

its in the dev portal

shrewd hazel
#

How?

earnest phoenix
#

or use a permissions calculator

shrewd hazel
#

Im new at bot making

#

268684337

earnest phoenix
#

and change it in the url

hidden knot
#

Can you code my discord bot? I need it to Mod Dream Utilities

earnest phoenix
#

na, can't u code it yourself

hidden knot
#

Nope. I can't find a web/app to do it.

@earnest phoenix

fossil canyon
#

Hi

earnest phoenix
#

what

fossil canyon
#

Can someone help me

#

?

earnest phoenix
#

dont ask to ask

hidden knot
#

I don't know how. @earnest phoenix

earnest phoenix
#

u dont need to keep pinging me

#

what is your library and language?

hidden knot
#

Sorry

fossil canyon
#

I need to detect if user is in HypeSquad Bravery team, how to make it?

#

Btw iam beginner

earnest phoenix
#

check the user's flags

#

what is your lib and language?

#

Martin

hidden knot
earnest phoenix
#

and u

hidden knot
#

 English

shrewd hazel
#

:D im so stress

#

🙂 🔫

opal plank
earnest phoenix
#

Guys how to handle Discord Missing Perms? When SEND_MESSAGE is disabled?

earnest phoenix
#

uh

#

use discordapi calculator

hidden knot
#

@earnest phoenix? It's Discord.js & English

earnest phoenix
#

oh right discord.js is from JavaScript

#

he mean programming language

shrewd hazel
#

@opal plank then are im just gonna copy the link?

earnest phoenix
#

ya

#

just do that

#

or update the current link with the new perms

earnest phoenix
# earnest phoenix wdym with that?

I have if (!message.guild.me.hasPermission("SEND_MESSAGES")) return; in my code but when I disable the bot's permission to Send Messages it gives me an error, (node:2504) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions. How could I possibly solve this issue so I won't get the error when my bot cannot send messages into a chat.

#

oh right

#

try if(!message.channel.me.hasPermission("SEND_MESSAGES")) return;

#

Ok

#

because the bot probably got send messages perm but if you use the command in a specific channel where the bot can't send messages

#

Yes channel has perms disbaled.

#

the code wouldn't return cause their role has that permission

boreal burrow
#

Blc mod

earnest phoenix
#

This is where bot gave err

#

if you uses guild

boreal burrow
#

Yes

earnest phoenix
#

the bot first look if their highest role has that perm

#

not the channel.

earnest phoenix
shrewd hazel
#

Me who just new dev:😵What you just say?

earnest phoenix
#

Else it's fine

#

try this: if (!message.guild.channel.me.hasPermission("SEND_MESSAGES") return;

shrewd hazel
#

I want to remove the perm because when they see how many perms needed they will decline me

#

100% predicting

earnest phoenix
earnest phoenix
#

and then update the link with the new perms

shrewd hazel
#

What link?

earnest phoenix
#

the invite link

#

uh

shrewd hazel
#

Ok

boreal burrow
#

Blc mod bot

#

How to add

earnest phoenix
#

all you have to is update the number

#

at bot&permissions=

#

with the new perms number

#

That's Adminstrator permission

#

Topgg doesn't allow

#

uh?

#

With Adminstrator permission bot works fluently

shrewd hazel
#

Invite url

earnest phoenix
#

Hmm

#

oh wait what's the number 2?

#

i mean perm

#

wich perm

#

It's hidden probably

shrewd hazel
#

No its just too long

earnest phoenix
#

kick members

#

it's 2

earnest phoenix
#

oh

earnest phoenix
shrewd hazel
#

Im not

#

This bot not for mod 👍

earnest phoenix
shrewd hazel
#

I scared if too many perm or adminis they will decline me

#

But i need those to make sure they get max peform

earnest phoenix
#

Last time

#

bruh

#

that's because you make it request any permission for any command that doesn't need it

#

an example is : "Admin is required to run help command"

#

What command needs adminstrator permission dude?

earnest phoenix
boreal burrow
#

How to Add blc mod bot on my server

earnest phoenix
#

._.

boreal burrow
#

I Know

earnest phoenix
#

@mellow kelp tu inglés es mejor, explícale a este men

boreal burrow
#

I Am Owner

earnest phoenix
#

@mellow kelp >:c

earnest phoenix
shrewd hazel
#

I use variable as set prefix

earnest phoenix
#

ok, so

shrewd hazel
#

Im big brain

earnest phoenix
#

i mean, the bot maybe require that perm to attach files, attach embeds, delete messages, kick and ban members, and some stuff more

#

uh

#

@mellow kelp come here

#

!

boreal burrow
#

Why this problem ????

earnest phoenix
#

that's because the bot has reached 100 servers without verification

#

You must aply for verification and wait for the bot gets verified

#

then you may invite the bot for more servers

#

xd

#

join here

#

if you have questions about verification

#

how can i add connection check for this code?

    /*Get the players.json*/
    const getPlayers = async server => {
        try {
        return axios.get(`${server}/players.json`, { responseType: 'json', timeout: 10000 });
        } catch(e) {
        console.log(e);
        }
    };```
i meant like if(e.status=404){channel.send} but i dont know what is the true one for this
shrewd hazel
#

Im new,i just know basic,im dumb,everyone knoe it

misty sigil
#

pass channel into the function?

shrewd hazel
#

"im new,im dumb".what that mean

#

Pass channel

mellow kelp
#

use cron jobs

drifting wedge
#
function math(x, y, op) {
    return(eval(x, op, y));


}
console.log(math(1,2,+));```
#

how can i like run the operation

#

so like whatever the operation is, it does it

mellow kelp
#

um

#

string concatenation?

drifting wedge
#

wdym?

mellow kelp
#

joining two or more strings

drifting wedge
#

i wanna like add it by math

#

not like put the strings together

mellow kelp
#

um

#

use a switch statement to determine the operation?

drifting wedge
#

switch statement?

mellow kelp
#

switch case

#

switch statement

#

that thing

drifting wedge
#

?

#

i dont do js lmao so this stuff is new to me

mellow kelp
#

well i hate to be that guy but like

#

learn js

drifting wedge
#

i am learning lmao

#

this is me learning it lmao

mellow kelp
#

search about switch statements

drifting wedge
#

what does it mean with case?

#

case is like if it is this

#

do this

mellow kelp
#

yeah

#

"check this value"

drifting wedge
#

so basically just ifs?

mellow kelp
#

"if it's this, do this thing"

#

yeah

drifting wedge
#

o ok

mellow kelp
#

like a long else-if chain but optimized

drifting wedge
#

i mean i could do that

#

but i wanted to see if there was a way to do it like with the var

#

but alr

mellow kelp
#

wdym var?

drifting wedge
#

like so

#

x operation y

#

so it replaces operation with what it is

mellow kelp
#

well you can't pass operators as values

drifting wedge
#

mhm

mellow kelp
#

they're special syntax KEKW

drifting wedge
#

mhm

#

alr

#

if i set a value in a for loop

#

can i access it outside of it?

mellow kelp
#

nope

#

unless you use var, which you shouldn't

drifting wedge
#

shit

#

alr

#

uhh its not working

#
function count(array) {
    let list = 0;
    for (i in array) {
        if (i === true) {
            list += 1;
            console.log(list);
        }
        
    }
}
count([true, false, false, true, false]);```
#

u got any ideas why?

mellow kelp
#

well

drifting wedge
#

basicaly trying to log the amount of times, true shows up in list

mellow kelp
#
  1. i think you can't use 'array' as variable name
#
  1. it should be for (const i of array) {
#

and some other stuff

#

to add 1, you can just use list++

#

and you don't need to check if i === true, just use if (i) {

drifting wedge
pale vessel
mellow kelp
#

it will work

#

oh well

#

ignore that one

drifting wedge
#

function count(array1) {
    let list1 = 0;
    for (i in array1) {
        if (const i === true) {
            list1 ++;
            console.log(list1);
        }
        
    }
}
count([true, false, false, true, false]);```
#

still giving problems

mellow kelp
#

you're declaring a variable in that if

#

i told you to add the const in the for loop

#

and it's for/of, not for/in

drifting wedge
#

wait what

#

the const should be the list?

#

i declare list on the top

#

as the num 0

pale vessel
#

you're comparing the variable

#

const/let/var is only for assignment

drifting wedge
#

WHAT

pale vessel
#

WHAT

drifting wedge
#

pls explain in dumb works

#

words

pale vessel
#

basically you don't put that const there

drifting wedge
#
function count(array1) {
    let list1 = 0;
    for (i of array1) {
        if (const i === true) {
            list1 ++;
            console.log(list1);
        }
        
    }
}
count([true, false, false, true, false]);``` this is my current code
mellow kelp
#

const/let/var is when you're declaring the variable for the first time

drifting wedge
#

mhm

#

ik, u told me to put the const there

pale vessel
#

bruh

mellow kelp
#

i told you to put it in the for loop

#

not in the if

drifting wedge
#
function count(array1) {
    let list1 = 0;
    for (let i of array1) {
        if (i === true) {
            list1 ++;
            console.log(list1);
        }
        
    }
}
count([true, false, false, true, false]);```
pale vessel
#

yes

mellow kelp
#

okay that should work

drifting wedge
#

alr

mellow kelp
#

and i'd still say

#

just use if (i) {

drifting wedge
#

and how would i like take it out of the for loop?

mellow kelp
#

wut?

drifting wedge
#

if (i) { it can be false doe

#

like i is either true or false

mellow kelp
#

but false isn't true

pale vessel
drifting wedge
#

if i

#

yes

mellow kelp
#

the if condition won't apply if the thing is false

drifting wedge
#

but if i checks if i isnt undefinied

#

no?

mellow kelp
#

thats another thing

#

but imagine it as this:

#

if i is true:

#

it would be

#

if(true){

drifting wedge
#

wat?

mellow kelp
#

like

#

nvm

drifting wedge
#

sorry, im fairly new to js lmao

pale vessel
#

if i == True:
if (i === true) {}

mellow kelp
#

if the value is false, the if block won't execute

drifting wedge
#

the second one is js, and is wat im doing

mellow kelp
#

the undefined thing you mentioned is another thing

pale vessel
#

but in js you can omit that === and it will booleans it

drifting wedge
#

oh

#

so if its false, it wont run?

mellow kelp
#

yeah

drifting wedge
#

nice

pale vessel
#

anything that is zero, undefined, null, and empty string will be false

mellow kelp
#

thats the point of an if statement

drifting wedge
#

cool

#

alr cool

mellow kelp
drifting wedge
#

and can i take the var out of the for loop?

#

so like only return the final value?

pale vessel
mellow kelp
#

wdym?

drifting wedge
#
            list1 ++;
            console.log(list1);
        }```
pale vessel
#

you return list1 after the loop

drifting wedge
#

return yes

#

but i want to only return it once

pale vessel
#

yeah

#

outside the loop

drifting wedge
#

like after its over

#

oh

#

i can use the var outside of it?

pale vessel
#

yes

#

because you declared it outside the loop

drifting wedge
#

nah

#

it doesnt work

#

if (i)

#

doesnt work

mellow kelp
#

yeah it does

#

you must be doing something wrong ig

pale vessel
#

why not xd

mellow kelp
#

what's the code?

drifting wedge
#
function count(array1) {
    let list1 = 0;
    for (let i of array1) {
        if (i === true) {
            list1 ++;
        }
        console.log(list1);
        
    }
}
count([true, false, false, true, false]); ``` with it fixed
#

with the if (i) ```1
1
1
2
2````

#

wit

#

gimme a min

#
1
1
1
2
2```
#

this is output with the if i

mellow kelp
#

yeah thats how it works

drifting wedge
#

still happenin

#

wat

mellow kelp
#

the result is 2

drifting wedge
#

wait

#

it was indside the forloop

#

OHHH

ionic dawn
#

Hi, im trying to replace some characters inside of array, any hint?

// INPUT:
let arr = ["-Hey-","-Hello-"]

// WHAT I NEED:
["Hey","Hello"]
drifting wedge
#

pog works

drifting wedge
#

try removing the first and last ones?

mellow kelp
#

with regex

drifting wedge
#

or replace ye

#

replace with ""

ionic dawn
#

i tried looping using replace but on a loop it only removes 1 of the chars

drifting wedge
#

?

mellow kelp
#

use regex with a g flag

#

that will replace all occurrences of the regex

drifting wedge
#

can i do a forloop for the num of a array

ionic dawn
#

like replace(/g/-, "") ?

pale vessel
#

use for in

ionic dawn
#

or something like that?

mellow kelp
#

no

drifting wedge
#

so like for i of (list of amount of things in array)

mellow kelp
#

you got it in reverse

#

/-/g

ionic dawn
#

oh

drifting wedge
#

why /-/g?

mellow kelp
#

/regex-here/flags

ionic dawn
#

What does the G means?

mellow kelp
#

the g flag is for global search

ionic dawn
#

I see

#

thanks

#

ill try it

mellow kelp
#

makes it so the regex matches all the occurrences

#

np

drifting wedge
#

can i do a forloop for the num of a array so like for i of (list of amount of things in array)

mellow kelp
#

yeah

drifting wedge
#

how?

#

just wondering

mellow kelp
#

you can loop through anything iterable

#

like with the other list

#

for/of

drifting wedge
#

ye like the number doe?

#

like so for i of list

#

and if i do

#

list[i]

mellow kelp
#

for(const i of list)

mellow kelp
drifting wedge
#

ye ik

pale vessel
#

thats for in

drifting wedge
#

like i want the number of it

pale vessel
#

use for in

#

not for of

drifting wedge
#

so like i would be the index of it

mellow kelp
#

for in is for objects

drifting wedge
#

so the list

pale vessel
#

and arrays

#

arrays are objects

drifting wedge
#

would be a array of numbers

mellow kelp
pale vessel
#

they have numbers as index

#

just use for in

#

way simpler

drifting wedge
#

wdym in?

#

so like for i in list

pale vessel
#

yeah

drifting wedge
#

i is the number?

pale vessel
#

yes

#

the index

drifting wedge
#

TYYYY

mellow kelp
#

oh yeah that works

drifting wedge
#

alr pog

pale vessel
#

so you can use list[i]

drifting wedge
#

im just starting js lmao

#

u should check this stuff out

#

imma go, ty guys

mellow kelp
#

cya

light gorge
#

is it worth switching my bot to typescript after most of it is done?

drifting wedge
#

From js?

light gorge
#

node.js

#

yeah

drifting wedge
#

Typescript is literally js

light gorge
#

then why do i have 76 errors

drifting wedge
#

Js code = typescript

misty sigil
#

because of the added typings

#

@drifting wedge No.

drifting wedge
#

But typescript isn't js

misty sigil
#

JS does not directly = typescript

light gorge
#

you don't have to use the typings

misty sigil
#

i mean yea but you get errors with d.js

#

i've tried

light gorge
#

you can turn that off in tsconfig

#

iirc

#

yep found uit

misty sigil
#

its not just that

#

iirc

light gorge
#

yeah

#

i can work with 21 errors now

#

most of them are Discord is already defined

mellow kelp
#

i got another idea

#

js == ts

#

js !== ts

opal plank
#

ts == js
js != ts
ts !== ts

mmulu

mellow kelp
opal plank
#
{
"noImplicitAny": true,
"allowJs": false,
"strict": true
}

There, now you part of the cool kids gang

#

you are writing js code, in ts, to transpile to js, with extra libraries and compilers bloating your workspace, for what? lol, the intellisense comments instead of the jsDocs? xD

light gorge
#

i am going to add types

#

just trying to get it to work rn

trim saddle
#

@pale vessel how do i dm someone http style

light gorge
#

the main reason was that it is compiled which means it catches the errors at compile time

mellow kelp
#

yeah

#

ts is infinitely better for decently-sized projects

pale vessel
trim saddle
#

wait

mellow kelp
#

you don't realize you forgot to pass a number or a string when your bot is already in prod

#

or that you accidentaly reassigned a const

light gorge
#

^^^

trim saddle
#

dm channels use seperate ids from user ids?

pale vessel
#

yes

trim saddle
#

W HY

pale vessel
#

idk

light gorge
#

there should be a method for doing it

trim saddle
#

go make discord better

pale vessel
#

no

#

you use the id from the object

#

post to channels/id/messages

trim saddle
#

@pale vessel so once i initiate a dm, how would i retrieve it for later

pale vessel
#

you cache it

trim saddle
#

aaaand when the process exits?

pale vessel
#

recreate dm 4head

trim saddle
#

whyyy discord whyyyy

pale vessel
#

yes

blissful coral
#

because yes

uncut swallow
#

you have the command of work is for economy

#

pls

#

help

crimson vapor
#

What?

uncut swallow
#

ehhh sistem of economy?

#

friend do you have the work command for an economy system?

crimson vapor
#

Just increase the amount of money stored in the db

uncut swallow
#

ehh I have no economy I want to start one on mi bot

trim saddle
#

@pale vessel how would a make a file safe to send

pale vessel
#

wdym

trim saddle
#

how do i make a data string

near stratus
#

I think you already know that

trim saddle
#

if i do then why would i ask

near stratus
#

So you wanna send a dataString or make a dataString ?

earnest phoenix
#

Need help again can I ask?

trim saddle
#

make one to send?

keen crane
#

what is this

#

?

trim saddle
near stratus
earnest phoenix
#

How to Handle this SEND MESSAGE disabled missing permission.?```
#

Any help is appreciated.

keen crane
#

oh sorry I didn't see it's the dev channel

lyric mountain
#

Stop using inline code like that plz

#

Wasn't that already solved by erwin?

earnest phoenix
#

Nope

near stratus
earnest phoenix
#

Already did

lyric mountain
#

Use .catch

earnest phoenix
#

I just want to handle missing perm for send message

lyric mountain
#

Try-catch won't catch inside promises

near stratus
earnest phoenix
#
    at RequestHandler.execute (E:\OneNaut\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async RequestHandler.push (E:\OneNaut\node_modules\discord.js\src\rest\RequestHandler.js:39:14) {
  method: 'post',
  path: '/channels/792743596021121054/messages',
  code: 50013,
  httpStatus: 403
}``` Err
trim saddle
#

no permissions

#

you don't have SEND_MESSAGES

#

so ofc you can't send messages

earnest phoenix
#

I know

#

But how to handle that

near stratus
#

can you show the rest of the code not the error

trim saddle
#

catch it and do nothing

#

it's an error that should really just be silent

pale vessel
#

don't waste api calls

#

add a check

near stratus
trim saddle
#

well it didn't so just catch lol

earnest phoenix
#

let helpingEmbed = new Discord.MessageEmbed()
.setAuthor(client.config.FOOTER_BOT_NAME)
.setTitle(${prefix}${cmd.name})
.setDescription(Description: ${cmd.description}\n)
.addFields(
{name:"Usage:", value: ${prefix}${cmd.usage}, inline:true}, {name:"Aliases:", value: \${cmd.aliases}, inline: true},
{name:"Cooldown:
", value: ${cmd.cooldown/1000} seconds, inline: true}
)
.setColor(client.config.SUCCESS_COLOR)
return message.channel.send(helpingEmbed)

trim saddle
#

pls code block

near stratus
#

@earnest phoenix hey bro put the whole code in if the hard way

pale vessel
#

they didn't check for channel overwrites

#

you can just check for channel overwrites if (!message.channel.permissionsFor(message.guild.me).has("SEND_MESSAGES"))

near stratus
earnest phoenix
near stratus
#

Look up

earnest phoenix
#

Oh ok

#

I'll try

rocky hearth
#

I've isRajrishi getter on Piece which always returns false. But on Rajrishi which extends Piece has a getter which always returns true.

mellow kelp
#

Pretty sure find() doesnt take generics

#

Does it tho?

rocky hearth
#

yes it does

mellow kelp
#

o

#

Well

#

I think you should use instanceof instead

#

I dont think a getter that always returns the same think is a good idea

rocky hearth
#

so should I create a boolean member, instead on Piece?

mellow kelp
#

No

#

I think

#

Like

#

yourThing instanceof Rajrishi

lyric mountain
#

What lang is that?

mellow kelp
#

Js

rocky hearth
#

ts!

mellow kelp
#

Oh you meant the problem

#

Yea

lyric mountain
#

Ah, that explains the different stuff I'm seeing there

rocky hearth
mellow kelp
#

Oh okay that makes sense

#

Well

#

A type predicate isn't a boolean

rocky hearth
#

Actually, what a type predicate is?

mellow kelp
#

It determines if an object is of a certain type

#

Its on the docs you sent

#

But since you're working with classes, instanceof should be fine

rocky hearth
#

hmm, lemme see

earnest phoenix
#

how can i add connection check for this code?

    /*Get the players.json*/
    const getPlayers = async server => {
        try {
        return axios.get(`${server}/players.json`, { responseType: 'json', timeout: 10000 });
        } catch(e) {
        console.log(e);
        }
    };```
i meant like if(e.status=404){channel.send} but i dont know what is the true one for this
molten cobalt
#

Can Anyone tell me how Can I program the bot that the bot send message by choices? JS

molten cobalt
#

@rocky hearth I mean a random message

#

from choices

rocky hearth
#

ooh!, keep a array of your text messages. Get a random index within the array and access the array with it.
And Boooom!

molten cobalt
#

@rocky hearth amm can you send me a little code sorry for saying

rocky hearth
#
const myTextMessages = [];
const randomMessage = myTextMessages[Math.random() * myTextMessages.length | 0];

molten cobalt
#

oo thanks

rocky hearth
#

the | 0 removes the decimal places, so u hv a numeric value

molten cobalt
#

ok thanks

#

@rocky hearth I am a biggner

#

const Command = require('../Structures/Command.js');

`module.exports = class extends Command {

constructor(...args) {
    super(...args, {
        aliases: ['hallo']
    });
}

// eslint-disable-next-line no-unused-vars
async run(message, args) {
    const myTextMessages = ['hello','wassap'];

const randomMessage = myTextMessages[Math.random() * myTextMessages.length | 0];
}

};`

#

Is this code okay?

rocky hearth
#

Its ok, u can also use, Math.floor(), if not comfortable with | 0

molten cobalt
#

@rocky hearth bot is not responding

rocky hearth
#

Whaat?? Do u know, how to send messages in a channel?

#

The above code is fine, but you're not sending the message to any channel

dusky marsh
#

probably not, he obviously copied all of whatever code he has now pandasad

molten cobalt
#

@rocky hearth message.channel.send

earnest phoenix
#
2020-12-28T07:52:49.870319+00:00 app[worker.1]:              ^
2020-12-28T07:52:49.870319+00:00 app[worker.1]: 
2020-12-28T07:52:49.870319+00:00 app[worker.1]: ReferenceError: config is not defined```
solemn latch
#

define config

unique summit
#

ha

earnest phoenix
#

not work why?

#

👀

opal plank
#

that should ALWAYS work

#

cuz thats a string

#

'1234' !== "hehe im a string" will always return @earnest phoenix

#

config.guildid is just a random string, you arent getting the actual value

pale vessel
#

you need to eval the string /s

earnest phoenix
#

👀

earnest phoenix
opal plank
#
let config = { guildid: '1234' }

if(message.guild.id !== config.guildid) return // this returns if '1234' is different than '1234';

if(message.guild.id !== "config.guildid") return // this returns if '1234' is different than "config.guildid"
#

does that make sense?

queen needle
#
import express from "express";
let app = express();
import indexroute from "./routes/index/index.js";
app.use("/", indexroute)
app.listen(3000, () => {
    console.log("App started on port " + 3000)
})``` my index file ```js
import { Router } from "express";
const router = Router();
export default () => {
    router.get("/", async (_req, res) => {
        res.send("Hi there");
    });
    return router;
};
``` my index route file 
the site starts up but the page doesnt load
lusty quest
#

your express ap starts without any error?

earnest phoenix
#

not work

old cliff
#

console.log(client.config.token);

lusty quest
#

you made your config a string

earnest phoenix
#

ihave

lusty quest
#

yes but you want a string from your config

old cliff
#

oof

earnest phoenix
#
     "guildid": "582498581395800064"
}```
old cliff
#

console.log(process.exit());

#

!eval console.log(process.exit());

earnest phoenix
queen needle
rocky hearth
fossil canyon
#

Hi, where is problem? member.guild.channels.get('792896021935947806').send("Welcome")

lusty quest
#

what did you want to do?

rocky hearth
#

That channel might not be in cache.

#

Always get a channel with a id, from the fetch method.

lusty quest
#

yesnt

#

if you use the same channel over and over. fetch the Channel once on Bot Startup and then get it from the cache

rocky hearth
#

by default, fetch method already, first try to get the channel from the cache.
obviously, which can be override

lusty quest
#

if you fetch all the time you can spam the API at some point. and Discord.js forced the entire Cache thing to reduce the load on the API

rocky hearth
#

As I said, fetch dont actually always fetch the channel.
It first tries to get the channel from the cache

lusty quest
#

if you dont disable it

restive furnace
jovial nexus
#

how can i turn a emoji to a image in js?

rocky hearth
jovial nexus
#

ye

rocky hearth
#

That's not possible, as I can understand

#

but there might be some way, of the regular (device specific) emojis

small prairie
rocky hearth
#

that url is for custom emojis

pale vessel
#

use a parser (like twemoji-parser in js) for twemojis and regex for emojis (https://cdn.discordapp.com/emojis/id.extension)

small prairie
#

he asked "A Emoji" not unicode emoji

#

he wasnt clear on what he wanted

pale vessel
#

parse(text, { assetType: "png" })

eternal osprey
#

hey i had a question.

#

I actually planned to buy a vps off at galaxygate.

#

however, i planned to do it using paypal.

#

once at the check-out page, I had to link a cc to my paypal? I don't even have a cc.

small prairie
#

also this isnt related to development.. at all

jovial nexus
#

what i want is a command like /emoji 👍 that sends a photo of the emoji

wintry stream
#

why photo of emoji?

jovial nexus
#

why not

pale vessel
#

brojs const [emoji] = require("twemoji-parser").parse(content, { assetType: "png" }); send(emoji.url);

#

literally

wintry stream
#

discord emojis are photos already and utf emojis work where photos don't

jovial nexus
#

and for custom ones?

pale vessel
#

regex

rocky hearth
#

<Emoji>.url to get the url for it

analog tinsel
#

hello

#

my embed images look like duplicate

#

how i can fix

#

left is original image

#

and right is image in embed

earnest phoenix
#

Guys need little assistance. let Message = args.slice(1).join(' ') || "Message"; I have (args[0], args[1],args[2]) I want to get message from only args 2 and beyond till limit 30 words.

jovial nexus
rocky hearth
#

every, custom emoji has a url. If its undefined than its not a custom emoji

jovial nexus
#

because that is undefined

rocky hearth
#

idk if its possible to get the emoji from the message.content!! 😦

pale vessel
#

use regex and get the emoji id

jovial nexus
#

regex?

rocky hearth
#

I once tried to log the message.content, and it was showing white boxes on place of emojies.
So I doubt, if the content actually has emoji.id

pale vessel
#

that's unicode emojis

#

you use a parser for them

#

they're talking about custom emojis

clever agate
#
(node:3024) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
    at MessageAttachment.setup (/rbd/pnpm-volume/3aa01355-32f2-40ec-8c97-6f9441e81801/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/structures/MessageAttachment.js:30:20)
    at new MessageAttachment (/rbd/pnpm-volume/3aa01355-32f2-40ec-8c97-6f9441e81801/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/structures/MessageAttachment.js:22:10)
at DabiClient.nsfw.real.thighs.then.json (/app/komutlar/nsfw-thigh.js:10:22)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:3024) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)```
rocky hearth
#

ooh yes, ur right

clever agate
#

MessageAttachment v12 how do i do v11

pale vessel
#

what

#

why v11 amandathink

clever agate
#

javascript

pale vessel
quartz kindle
#

v11 bad

clever agate
#

how will i transform

quartz kindle
#

use v12

jovial nexus
#

so if args[0] is :sent:49023932829229 why not only take the id part

pale vessel
#

yes

#

take it

jovial nexus
#

how doe

#

split

pale vessel
#

sure

quartz kindle
#

you can use a regex replace

jovial nexus
#

never heard of that

#

what is it

#

i konw regexp but

quartz kindle
#

regex = regexp = regular expression

lament rock
#

string.replace but instead of providing a string as the search, you'd provide a regular expression

rocky hearth
#

:sent:49023932829229 is this what ur able to log to console?

quartz kindle
#

for example, extract only numbers from a string

pale vessel
lament rock
#

r

jovial nexus
#

AAAAAAAH

quartz kindle
#

BBBBBBBBH

lament rock
earnest phoenix
#

Guys need little assistance. let Message = args.slice(1).join(' ') "I want to get message from only args 2 and beyond till limit 30 words.

#

any help is appreciated

lament rock
#

30 words or characters?

earnest phoenix
#

yes

#

chars

lament rock
#

args.slice(1, 31).join(" ")

earnest phoenix
#

oh nice

#

ok

jovial nexus
lament rock
#

emoji names can have numbers in them

jovial nexus
#

yes

lament rock
#

\D matches non numbers

#

:pog69:420691337
would replace to 69420691337 which is incorrect

jovial nexus
#

yes

#

thats the problem

quartz kindle
#

you're not supposed to match the emoji name

#

you're supposed to match the message content

#

and why does it break the command? what is the error?

lament rock
#

message content could still contain numbers. If someone sliced that string out of the content just for easier pick-apart, it should have more benefit since less string testing

quartz kindle
#

ah

#

so then yes you need to split

#

you can also use regex lookbehind

jovial nexus
#

how

lament rock
#

Or just /(:[\w\d_]+:)\d+/g

pale vessel
#

pretty sure you only need \w

jovial nexus
#

there is something missing there or is just me

pale vessel
#

that includes digits and _

lament rock
#

I forget if string.replace only replaces the capture group if there is one or if it replaces the entire regex match even if there is a cap group

#

\w does not include digits or _ last I checked

pale vessel
lament rock
#

I swear I've run into issues with that exclusively before

#

oh well?

jovial nexus
#

same error

earnest phoenix
#

Clublog is not working for me with Brawly Bot??

quartz kindle
#

by the way

#

discord.js has emoji parsers built in

jovial nexus
#

isnt easyer only take the args between : and >

quartz kindle
#

Discord.Util.parseEmoji(message.content or args[0])

lament rock
#

I dislike how they specify ID lengths since devs can arbitrarily insert IDs into the database

jovial nexus
#

let emote = await client.emojis.cache.get(disc.Util.parseEmoji(args[0]).id)???

pale vessel
#

emoji snowflakes are up to 19 length now?

lament rock
#

Yeah. They overflowed a while back

pulsar bone
#

hey how to the following properly

a = message.embeds.footer.content.split(" ") 
jovial nexus
#

command finished thanks guys

wintry stream
#

@pulsar bone what are you trying to do

umbral sentinel
#

Why did my bot get kicked out the server ??

quartz kindle
#

all bots did

wintry stream
umbral sentinel
#

Ye just read it

#

Thought my bot got hacked and got deleted or something 😂

near stratus
#

There were many servers who only contained bots and it was used to increase their member count. So Discord is developing a 50 bots rule and maybe some Dev contacted the owner of this server

restive furnace
#

i heard it was only bots with slash commands

near stratus
#

whatever

#

BTW slash commands are pretty much trash except /help

cinder patio
#

I disagree

quartz kindle
#

it was probably because it was not sustainable

#

top.gg relied on presence_updates to show all bot's online status on the website

#

and discord has a limit on guild presences, usually like 50k or something

#

they got discord to increase this limit for top.gg like twice i believe

#

but it was not a sustainable method, so they just dropped it altogether

pulsar bone
quartz kindle
#

a message can have multiple embeds

#

so message.embeds is an array

#

also footer doesnt have content, it has text

mellow kelp
#
interface Foo {
  bar: Foo;
}
#

Just woke up an thought about this

pulsar bone
stuck pike
#

what is this uri how to fix this lol

mellow kelp
#

the uri has to match any of the redirect uris on your oauth2 tab

stuck pike
#

i wanna know like how to fix it

mellow kelp
#

yeah well make sure you use redirect uris that are on your list

stuck pike
#

its a local host

mellow kelp
#

just add localhost to your redirect uris

boreal pewter
# stuck pike

on your discord developer portal, go to OAUTH2 and add the exact url you redirect to

#

you see i have for the local environment and the online one

stuck pike
#

like this

#

aah got it

#

rip same erorr this

#

this is the eroor

#

@boreal pewter

#

thx to help

mellow kelp
#

you have to include the same route

#

the uri must be exactly the same as the one on your query params

stuck pike
#

did that

mellow kelp
#

/authorize/callback ?

stuck pike
#

ye

mellow kelp
#

hm

#

well now it works for me

stuck pike
#

lol i forgot to keep a / at last lawl

#

fixed

quartz kindle
#

can you even oauth localhost?

#

lmao

cinder patio
#

yeah

fierce ether
mellow kelp
#

@low orbit you'd have to fetch the bot's guilds too, and use then to filter stuff out

slender thistle
#

Sometimes I regret using type annotations.

    def punishment_info(self, guild: discord.Guild, role_involved: bool) \
        -> Union[Tuple[Optional[discord.Role], str, str, Optional[discord.abc.GuildChannel]],
                 Tuple[str, str, Optional[discord.abc.GuildChannel]]]:
wintry stream
earnest phoenix
#

Why is This Not Working

cinder patio
#

explain how it's not working

pulsar bone
#

hey guys how to read embed footer text

cinder patio
#

does it not do what you expect it to do? Any errors?

mellow kelp
pulsar bone
mellow kelp
#

o

earnest phoenix
cinder patio
#

what actually happens

mellow kelp
#

i think what you want is embed.footer

earnest phoenix
#

When I Run gg!report IT does litterly nothing

pulsar bone
#

hey how to do the following properly

a = message.embeds.footer.content.split(" ")  
mellow kelp
#

what do you mean by properly

pulsar bone
#

it gives error

mellow kelp
#

probably because message.embeds is an array

earnest phoenix
#

@cinder patio You Got Any Solutions?

cinder patio
earnest phoenix
pulsar bone
mellow kelp
#

just grab the first element of embeds

quartz kindle
#

i already told you lol, message.embeds is an array, and footers dont have content, have text

earnest phoenix
mellow kelp
#

stop using bold text KEKW

earnest phoenix
mellow kelp
#

apart from that i got no idea why it doesnt work

#

you said there were no errors in console right?

boreal pewter
#

yo, does anyone here know how long does the refresh token lasts

earnest phoenix
mellow kelp
#

you mean to delete the message?

earnest phoenix
#

no

#

my code sends a report message to the bot owners channel (my private channel)
but it sends gg!report with it

#

i want it to only send the message not the prefix and command

mellow kelp
#

id say slice the content starting from the prefix's length

#

and then use replace on 'report' at the start

earnest phoenix
#

This is The Command I Run

mellow kelp
#

yeah ik

#

thats your solution

earnest phoenix
#

use .slice

#

?

mellow kelp
#

yea

earnest phoenix
#

so i putthe value of the prefix & command letters in the ()

mellow kelp
#

no

earnest phoenix
#

var res = str.slice(0, 5);

mellow kelp
#

the prefix length

earnest phoenix
#

...

mellow kelp
#

or wait

#

your command is case-sensitive

#

you can just use String.replace

earnest phoenix
#

Like This

var str = "That is like so not cool, I was like totally mad."; var cleanStr = str.replace(/like/g, "");//replace every "like" with blank ""

mellow kelp
#

you say that as an example of String.replace?

#

then yea thats how it works

earnest phoenix
#

Idk How to Use it in Discord js

#

...

molten yarrow
#

you sending message back its what you send to Bot

#

channel.send(message) <= change this line

earnest phoenix
#

change it to what

#

the replace string thingy?

molten yarrow
#

to your text?

earnest phoenix
#

i want users to send custom text

#

-_-

mellow kelp
#

dude it's just javascript

molten yarrow
#

define it... its called args

earnest phoenix
#

Like this

quartz kindle
#

you dont need to use .find() if you have the id. just use .get(id)

#

.find() is for when you dont know the id

cinder patio
#

also why are you splitting the report message, you are turning it into an array

earnest phoenix
#

array?

#

like [, ,]

molten yarrow
#

change ReportMessage to args

quartz kindle
#

if all you want to do is use .replace() on it, you dont need an array

earnest phoenix
quartz kindle
#

.get("34756394759")

earnest phoenix
quartz kindle
#

...instead of .find() like i said

mellow kelp
#

please learn js

earnest phoenix
quartz kindle
#

no

#

.get("3479345")

#

replace the number with your id

earnest phoenix
quartz kindle
#

yes

earnest phoenix
#

So it Sends report with it

#

how do i remove that

quartz kindle
#

slice it

#

.slice() takes a number of characters to remove

earnest phoenix
#

.slice(0, 5)

mellow kelp
#

no

quartz kindle
#

you are giving it prefix.length characters

mellow kelp
#

its .slice(start, end?)

earnest phoenix
#

start

#

i wanna remove from start

quartz kindle
#

your prefix is 3 characters long, so you have .slice(3)

#

just increase the character count until it removes also the word report

#

report is 6 characters long

earnest phoenix
#

so 9

quartz kindle
#

you can simply do prefix.length + 6

#

or 9 directly, if your prefix is never gonna change

mellow kelp
#

or straight-up use message.replace to remove 'report'

earnest phoenix
quartz kindle
#

remove the 0

#

the second parameter is if you want to remove stuff from the end of the text

earnest phoenix
#

yeah

#

ok

quartz kindle
#

you dont need to remove anything form the end

#

so remove the 0

earnest phoenix
#

Works

#

thnx

pulsar bone
#

can anyone answer how to read fucking read not send embed footer and do the following

a = message.embeds.footer.content.split(" ")  
cinder patio
#

before you can read the embed footer you first have to learn to read in general

pulsar bone
cinder patio
#

show us how you did it

old cliff
#

does anyone know about any way to know the framerate of a gif ?

opal plank
#

Fairly certain ffmpeg can get it @old cliff

silver monolith
#

so i have a currency system for my bot (i just developed it yesterday) and the currency can't save globally

#

i want my currency to be global

mellow kelp
#

store your data with user ids

gilded olive
#

^

#

you can do both at the same time

silver monolith
#

here wait

#

lemme send code

gilded olive
#

no need

#

whatever you're passing to store data

#

should be user_ids

silver monolith
#

i use quick.db

#

ok

#

whenever i used userids

#

it gives error

gilded olive
#

i have no idea what quick.db is

silver monolith
#

oh

gilded olive
#

I assume you're using discord.js

old cliff
gilded olive
#

I know 0 JS PepeLaughers

silver monolith
mellow kelp
#

pretty sure quick.db isn't really good for production

#

not completely sure tho

pale vessel
#

ikr

#

it uses sqlite

mellow kelp
#

its like

prisma oriole
#

its for beginners

mellow kelp
#

yea

silver monolith
#

oh

#

wellll