#development

1 messages · Page 1212 of 1

white vapor
#

how do you make the bot say something and then the username

delicate shore
#

.join(%20) something like this

thick gull
#

you can use mongo atlas if your willing to learn mongo

delicate shore
#

Don't know if it will work

thick gull
#

.join('%20')

earnest phoenix
#

i found this https://corona.lmao.ninja/v2/states/${country.replace(/\s/, '%20')}

opal plank
#

urlEncode() is a thing btw

thick gull
#

or that

sudden geyser
#

or you could use encodeURI

delicate shore
#

Just use a npm package

sweet kestrel
#

wait, how to connect database to a remote database?

opal plank
#

encodeURI is what i meant

earnest phoenix
#

hmm oke lemme test it thanks guys

sweet kestrel
#

@thick gull

opal plank
#

@sweet kestrel get a database somewhere, use the ip as target, ezx

sudden geyser
#

which is far more reliable

thick gull
#

^^

sweet kestrel
#

huhhhhhhhhhhhhhhhhhhh

#

idk

#

😭

thick gull
#

ok

opal plank
#

same way you had your database locally, just change target to their IP/domain

sweet kestrel
#

;(

opal plank
#

theres literally no difference

thick gull
#

you can also just buy a VPS and completely avoid this issue

#

if you want

opal plank
#

you just changing ip

misty sigil
#

if you can’t understand that why make a bot?

sweet kestrel
#

oh

thick gull
#

@misty sigil cool gamer :sunglas;

white vapor
thick gull
#

wha?

opal plank
#

lightmode

thick gull
#

client mod by using white theme

misty sigil
#

you need message.author.tag in d.js

thick gull
misty sigil
#

and also — is that a message logger

thick gull
#

looks like it

white vapor
#

its a thing i made called quick emoji

thick gull
#

wait does ('quote', thing)

#

work

#

?

opal plank
#

thats an amazing way of poorly doing stuff

#

you just cloning message

misty sigil
#

No

opal plank
#

its not like messageDelete event exists, right?

misty sigil
#

it doesn’t

opal plank
thick gull
#

shouldn't it be like (`pog pog ${pog}`) or ('pog' + pog)

earnest phoenix
misty sigil
#

yes

#

yes

white vapor
#

it works for embed and it didnt give any errors so

thick gull
#

@earnest phoenix we told you, join args[1] and args[2]

#

your only using args[1]

#

which is the first one

#

args is being split by spaces

earnest phoenix
#

how

thick gull
#

.join

opal plank
#

or replace content

thick gull
#

yea

earnest phoenix
#

im replacing it

opal plank
#

replace(prefix+command+space, '')

earnest phoenix
opal plank
#

on message content

thick gull
#

country is args[1]

opal plank
thick gull
#

😔

earnest phoenix
#

bruh im lost

misty sigil
#

You need args[1] and [2]

earnest phoenix
#

yeah

opal plank
#

you trying to replace spaces on country, which is ONLY args[1]

misty sigil
#

and no spaces

thick gull
#

args[1]%20args[2] something like this

opal plank
#

args[1] DOESNT have spaces

#

well, it might

thick gull
#

but would suggest dynamically doing it

opal plank
#

but its being SPLIT on spaces to make args

earnest phoenix
#

args[1]%20args[2} and where i put this

thick gull
opal plank
#

stop

#

stop copying

#

pay attention

#

learn

earnest phoenix
#

ok ok

misty sigil
#

args.shift().join(" ")?

earnest phoenix
#

tell me

opal plank
#

look

earnest phoenix
#

args.shift().join(" ")?
@misty sigil not working

opal plank
#

i send hello world hi

#

what are your args?

sudden geyser
#

If you're trying to add user input in the URL, I recommend you use encodeURI

misty sigil
#

Did you include the ?

opal plank
#

@earnest phoenix

earnest phoenix
#

i send hello world hi
@opal plank hello?¿

thick gull
#

@sudden geyser thats not the issue currently, he is trying to get info on args[1] and [2] when the target is only [1]

opal plank
#

thats args[0]

misty sigil
#

if you did I’m honestly going away and out of this server never to be seen again

opal plank
#

what is args ?

earnest phoenix
#

arguments

opal plank
#

wrong

#

what is args?

misty sigil
#

it’s an array

opal plank
#

^^

thick gull
#

where did you get the args code if you dont get it 😔

misty sigil
#

arrays have indexes

opal plank
#

what is in that array @earnest phoenix ?

earnest phoenix
#

im diying

opal plank
#

you lacking too many fundamentals of js

#

you shouldnt be doing a bot without knowing those things

misty sigil
#

yea

#

^

opal plank
#

those are the most basic things you need to code

thick gull
#

what is an array

#

opal plank
#

what are objects? what are variables? what is an array?

#

it seems like you've been copying code thus far

#

which wont get you far

earnest phoenix
#

i didn´t copy, trust in me, i forget how args work

opal plank
earnest phoenix
#

i get the args code from my old bot

misty sigil
#

@earnest phoenix awnser what are objects? what are variables? what is an array?

earnest phoenix
#

ok

misty sigil
#

mdn time

thick gull
#

brrr mdn

eternal osprey
#

i still have no clue on how to filter the countries by command

thick gull
#

?

eternal osprey
#

so if you use !sunnyweather, you get all the countries that have sunny weather atm

fervent fable
#

Sa

eternal osprey
#

(not all, like 20)

fervent fable
#

Türk

#

Varmı

eternal osprey
#

i already have the code

fervent fable
#

Türküm

misty sigil
opal plank
#

@fervent fable english only

earnest phoenix
#

A variable is an element that is used to store and refer to another value @misty sigil

eternal osprey
#

just need to filter the objects

thick gull
#

.filter()?

#

wait

#

it took you

#

ok

fervent fable
#

@opal plank why ? Nooo , ı am turkısh

misty sigil
#

A variable is an element that is used to store and refer to another value @misty sigil
@opal plank check if that’s taken from mdn

thick gull
white vapor
#

i still need a solution

thick gull
#

to?

white vapor
#

i cant find anything on this

opal plank
#

@earnest phoenix a variable is a thing you declare, be it with a value or not

thick gull
#

message.author.tag?

white vapor
#

let me send it again

thick gull
#

you arent combing the string and tag right

opal plank
#

a variable is just a memory variable thats declared, assigning it comes after

thick gull
#

you did "", variable

#

"" + variable

opal plank
#

but you technically right, you can reference stuff

misty sigil
#

what are objects? what are variables? what is an array?
@opal plank

  1. {foo:"bar", bar:"foo"} (a way of storing things)
  2. A defined thing (e.g. let a; they don’t have to have data)
  3. A list of things
thick gull
#

or `test ${variable}`

opal plank
#

@earnest phoenix in my example Hello world hi what are the args?

thick gull
#

@white vapor do you have a solid understanding of JS

#

because it seems you dont know how to put variables in strings 😔

white vapor
#

no not really, ive just been getting stuff from documentation and tutorials

eternal osprey
#

boys

misty sigil
#

in my example Hello world hi what are the args?
@opal plank I know the awnser and I have the urge to say it

thick gull
#

please learn the base of JS before making a bot

eternal osprey
#

how do i filter my info i scraped from weather-js.

#

so if i use !weather sunny, it returns countries with sunny weather

opal plank
#

@misty sigil i know you know, let the fella answer for themselves, otherwise its pointless

white vapor
#

kinda a bit too late because its literally finished

thick gull
#

read the introduction here

misty sigil
#

I want to see what they say

thick gull
#

they took like 10 minutes to define a variable

#

idk what your expecting here

opal plank
#

i dont mind if they are googling it, as long as by the end they know what it is, its fine

#

they wont get far copying code

thick gull
#

kinda tempted to make a bot just copying code and see how far i can get with it just to have fun kekw

white vapor
#

my bots finished im just trying to fix things

misty sigil
#

it isn’t hard

#

no need for comma

thick gull
#

wh

misty sigil
#

just +

opal plank
#

since i dont know py too well, i might try that

thick gull
#

i mean i learned js mostly copying code

#

but i didnt just like

opal plank
#

no-code challenge

thick gull
#

copy paste and then

#

im done

opal plank
#

you cannot do anything other than change variable values

misty sigil
#

you observed what the code done

thick gull
#

yea

opal plank
#

you arent allowed to change code

#

that sounds like fun

thick gull
#

ok @opal plank do you want to race, first to 20 servers owned by completely random people with copied code

misty sigil
#

I got to 104

opal plank
#

hell yeah lmao

thick gull
#

bet

lament meteor
#

@thick gull i mean... all my code is from stackoverflow with the variable names change

opal plank
#

i guess there isnt much point in trying it if people done it unironically lmao

thick gull
#

i mean

#

maybe

opal plank
#

they never answered

#

here i was trying to help, and they ghosted me

#

feelsBadMan

misty sigil
#

guess they just really didn’t have a fucking clue

opal plank
#

probably right

#

i wonder...

#

well, i guess even twitch has undocumented stuff

charred geyser
#

can anyone point me in the best way of making your bot send a message upon joining a server

#

basically im not sure how to make it find a channel to send the message in

misty sigil
#

client.channels.cache.get("channel ID") for discord.js

#

you can send to that

charred geyser
#

but how can i get a channel id if the bot has never joined the server

opal plank
#

then you cant

charred geyser
#

exactly

opal plank
#

you arent suppose to be getting your hands on servers that you dont have access to

charred geyser
#

wdum?

thick gull
#

he said upon joining

charred geyser
#

litterally like

#

yeah

thick gull
#

so once the bot joins

opal plank
#

oh

charred geyser
#

once the bot joins

thick gull
#

iirc guild.send()?

charred geyser
#

send the help embed

opal plank
#

then once it join it should cache the guild

thick gull
#

im not sure abt that

#

kekw

opal plank
#

nah

#

guild.channel should exist

misty sigil
#

No need to send a help embed

opal plank
#

even when the event is fired

#

it returns guild, then you can get channels out of that

thick gull
#

iirc guild.send()?
@thick gull meant this

#

i looked into it a while ago but never really used it

opal plank
#

is that a thing?

misty sigil
#

if they’re interested, they will get the help themselves

charred geyser
#

bruh

slender thistle
#

guild.channel should exist
PLURAL, not singular

charred geyser
#

thats your opinion lol

misty sigil
#

no

opal plank
#

@slender thistle yes indeed

proven lantern
thick gull
#

i dont think its a thing

#

actually

#

nvm

misty sigil
#

no need to shovel the embed down their throat

opal plank
#

send() is a method from Channel>

misty sigil
#

they will use the help command themselves

proven lantern
#

guildCreate

opal plank
#

thats the event

#

which returns a guild object

slender thistle
#

for-loop over guild text channels, for each element check if bot has permissions to send a message. If yes, send and break the loop, otherwise, continue

charred geyser
#

yeah i have it inside the event guildCreate

slim ravine
#

!help

opal plank
#

check @ everyone perm

thick gull
#

!help
@slim ravine #commands and common prefixes dont work

opal plank
#

incase your bot has high permissions

#

say your bot has admin perm(which it shouldnt), it may post on announcements channel or somewhere it shouldnt

charred geyser
#

this is what i was using

opal plank
#

prob best to check for @ everyone permission to send

charred geyser
#
    let joinChannel = "";
    guild.channels.cache.forEach((channel) => {
        if(channel.type == "text" && joinChannel == "") {
            if(channel.permissionsFor(guild.me).has("SEND_MESSAGES")) {
                defaultChannel = channel;
            }
        }
    })
    joinChannel.send(BotJoinMessage)
#

oops

#

lol

#

BotJoinMessage is already defined

opal plank
#

wait what

sweet kestrel
#

guys

opal plank
#

where even is that nested on?

sweet kestrel
#

if i have databases in my code, i want to host it

#

how

thick gull
#

we told you

sweet kestrel
#

to do it free

thick gull
#

you cant host a db on heroku

opal plank
#

you dont have database in code

sweet kestrel
#

😦

thick gull
opal plank
#

if you do, its bad

#

database in code is stored in memory

sweet kestrel
#

😦

thick gull
#

he means sql

#

i think

sweet kestrel
#

yes

#

mysql

thick gull
#

im not sure what hes doing

opal plank
#

sql is stored locally, its not related to the code

#

the code is just what sends/reads from the db

thick gull
#

hes trying to use it on a heroku host

sweet kestrel
#

how to do it again? lol

thick gull
#

use a remote host

#

if you want to use heroku

opal plank
#

^^

charred geyser
#

where even is that nested on?
@opal plank i have ./events/ setup

thick gull
#

or change to a proper vps

opal plank
#

@charred geyser which language is that?

charred geyser
#

so its in the guildCreate event

#

js

opal plank
#

d.js

charred geyser
#

yea

opal plank
#

hmm

#

guildCreate, okay

#

why you doing a forEach?

faint prism
#

I mean, I have an admin DM-only command that tells me something like this

<redacted>
    ** BOT-TO-USER IMBALANCE **
    ** BOT IS ADMIN **
    Admins: <redacted>
    Total Users: 168
    Users to Bots ratio: 98.21 %
    Real Users: 3
    Bots: 165
charred geyser
#

cause its like

faint prism
#

Useful for making my bot leave bot farms

opal plank
#

that'll send message on every channel it has perm

charred geyser
#

for each channel check if it has permissions to send

#

nah it doesn't

thick gull
#

Useful for making my bot leave bot farms
@faint prism wait what is a bot farm

opal plank
#

@faint prism im using something similar

charred geyser
#

i dont think

#

what would you suggest i do?

faint prism
#

@faint prism wait what is a bot farm
@thick gull Looks like it

thick gull
#

cause my bot got added to a server called "bot overtaken" within minutes of being added to a list

opal plank
#

those are my limits for my bot

#

i havent added bot % yet

sweet kestrel
#

I will search host up

opal plank
#

if guild has less than 10 members, and doesnt user 5 commands in the span of a week, nor have 20 messages in the span of a week, it auto leaves

thick gull
#

okay boys be b ack in like an hour spanish clASS

charred geyser
#

gl

opal plank
#

@charred geyser you could get a loop and get first one that matches

fluid basin
#

that isn't the best idea tbh, it stops those who actually want to test your bots before using it in their servers

opal plank
#

also should check for @ everone rather than your own perms

sweet kestrel
#

@thick gull ?

opal plank
#

@fluid basin a whole week to test the bot?

charred geyser
#

permissions isn't really a problem

thick gull
#

you need a remote DB

#

im not sure how

#

but thats what

sweet kestrel
#

is that it?

thick gull
#

instead of doign localhost you do <ip>/<website>

sweet kestrel
#

ok

charred geyser
#

how would i make it find the first text channel regardless of permissions? @opal plank

fluid basin
#

I'm talking about the member min part

#

also heroku is not cpanel and does not have cpanel

opal plank
#

@fluid basin the kick event only fires if ALL of them match

#

not OR

fluid basin
#

bruh ok

charred geyser
opal plank
#

@charred geyser doesnt cllection have a first() method?

faint prism
#

bruh.
@charred geyser What, you don't do that?

charred geyser
#

i do but i close it often

opal plank
#

i stay a couple days awake due to my old bad habits from gaming ARK

charred geyser
#

lol

opal plank
#

and before you ask, no, im not running the bot on VSC

#

its running on a proper vpn

#

lemme check something

charred geyser
#

lol

drifting wedge
#

how do i embed images?

charred geyser
#

.name?

opal plank
#

as i thought, collection does have first()

charred geyser
#

yea

opal plank
#

just needed something to output that isnt a big ass object to hit 2000 char limit

charred geyser
#

oh ok

opal plank
#

then use that

charred geyser
#

i can use that without message?

#

right

opal plank
#

though

#

remember

charred geyser
#

cause message would be undefined in a guildCreate

opal plank
#

information isnt a channel

#

its a category

charred geyser
#

oh

opal plank
#

check for type

drifting wedge
#

how do i embed msgs?

charred geyser
#

if(channel.type == "text")

#

?

opal plank
#

that'd work

charred geyser
#

ok neat so i want like

opal plank
#

3 =

#

btw

#

equal type

#

not just equal

charred geyser
#

oh yea

#

mb

opal plank
#

equal causes bugs sometimes

#

just like var

restive furnace
#

what's diffence in js of === and ==? is === less buggy

3 =
btw
equal type
not just equal
equal causes bugs sometimes
just like var

opal plank
#

this is how stupid js is

#

this is a bug believe it or not

charred geyser
#

=== means its the same and the same type

opal plank
#

you arent meant to multiply string vs number

charred geyser
#

== means its the same

#

i think

opal plank
#

correct, equal TYPE

charred geyser
#

by the same i mean equal

opal plank
#

checks type too

charred geyser
#

yes

opal plank
#

ts is smart about this

#

js is like, fuck it

charred geyser
#

guild.channels.cache.first()

restive furnace
#

kk

charred geyser
#

so i could do like

#

const channel = guild.channels.cache.first();

opal plank
#

again, it might return a category

#

actually, itll LIKELY return a category

restive furnace
#

so basically "1" == 1 returns true, "1" === 1 returns false?

opal plank
#

@restive furnace correct

charred geyser
#

how would i put a if statement into that

thick gull
#

i mean you could look for a channel called general first before

opal plank
#

loop with for instead of first()

charred geyser
#

const channel = guild.channels.cache.first();

    if(channel.type === "text") {
        joinChannel.send(BotJoinMessage)

    }
opal plank
#

incorrect

charred geyser
#

f

#

will channel.type not recognise channel

#

it wont

#

uhh

drifting wedge
#

how do i embed images?
discord py

slender thistle
#

Does anyone know any good Python formatter plugins for Sublime Text 3?

opal plank
#

@charred geyser

let channel:<Discord.TextChannel|undefined>;
for(let c of guild.channels) {
if(c) return;
if(type === 'text') channel.push(c)
}```
#

you can do more logic below like checking for @ everyone permissions in that channel

charred geyser
restive furnace
#

<type:another_type> is a TS 4.0 feature?

opal plank
#

youa rent suppose to copy shit

charred geyser
#

😦

opal plank
#

i downloaded ts 4.0 but i havent fully checked it yet

restive furnace
#

k

opal plank
#
let channel:Discord.TextChannel|undefined;
#

this would be the correct one currently

charred geyser
#

what happened to guild.channels.cache.first();

drifting wedge
#

how do i embed an image?

opal plank
#

nothing, i told you it will likely get category and its bad to use in this case

#

i provided that example so you'd learn from it, not copy it

#

specially cuz thats TypeScript, not Javascript

charred geyser
#

yea

#

i was gonna say

#

channel =

opal plank
#

you can declare variables without assigned values

restive furnace
#

you probably should learn basic fundamentals of JS first? [seasnail]

opal plank
#
let a;

is valid JS syntax

charred geyser
opal plank
#

you dont need to assign values on a variable right away

charred geyser
#

yea

#

i use that quite a lot

opal plank
#

then?

#

that : is me setting its type, not its value

#

: is type = is value

restive furnace
#

^ only TS has types

opal plank
#

^^

charred geyser
#

nice 😄

opal plank
#

Bot be vibing

charred geyser
#

beuh

#

TypeError: Cannot read property 'cache' of undefined

#

i just shouldn't use that should i

opal plank
#

check if whatever you trying to get is there

charred geyser
#

i litterally had it workiing

#

becuase i was using v11

#

and this worked

#
let defaultChannel = "";
guild.channels.forEach((channel) => {
  if(channel.type == "text" && defaultChannel == "") {
    if(channel.permissionsFor(guild.me).has("SEND_MESSAGES")) {
      defaultChannel = channel;
    }
  }
})
#

and then it would just defaultChannel.send

opal plank
#

upgrade

charred geyser
#

i did

opal plank
#

v11 is deprecated now

charred geyser
#

yeah i upgraded and started using a database

opal plank
#

also forEach bad

#

do a for loop

charred geyser
#

yeah now it is

restive furnace
#

and why assign defaultChannel as a string, and then assing it as Discord.Channel?

sonic lodge
#

instead of just guild.channels, v12 implements managers, so you need to use guild.channels.cache

restive furnace
#

(ik this isnt TS, bt still)

charred geyser
#

yea

earnest phoenix
restive furnace
#

npm rebuild?

sonic lodge
#

try uninstalling and reinstalling the module

earnest phoenix
#

Tried npm install or npm rebuild, didn't work

#

try uninstalling and reinstalling the module
@sonic lodge Also tried, nothing

sonic lodge
#

interesting

charred geyser
#

so i can use for(let c of guild.channels) { if(c) return; if(type === 'text'){ channel.send(BotJoinMessage) } }

#

but i need to define channel as something

#

i think

faint prism
#

just get guild default

charred geyser
#

what

faint prism
#

the system txt channel

restive furnace
#

and you literally assigned the channel as c.

sonic lodge
#

guild.channels is a collection, right?

charred geyser
#

yea i guess so

sonic lodge
#

when you iterate it using for of, c will be an array

charred geyser
#

Not Erwin wrote it pepe_shrug

restive furnace
#

dont copy paste

#

and you're returning if c isn't nullable??

faint prism
#
for(let c of guild.channels) {
        if(c) return;```
Won't that return if it isn't null..?
restive furnace
#

if (c) return;

#

^^ yep

faint prism
#

Did he forget the logical not ! ?

restive furnace
#

he just copied the pseudocode

charred geyser
#

if (!c) return; ?

faint prism
#

Well think about it

#

what would that do?

#

If c is null, it would return

#

Is that what you want?

charred geyser
#

i guess

#

well since c shouldn't be null

faint prism
#

Well, you wouldnt want it to be null and try to do something with it, right?

charred geyser
#

yea

faint prism
#

Exactly

#

🙂

charred geyser
#

if c was null there would be no channels in the server

#

i think lol

faint prism
#

Lol, pretty much

#

I can't think of another scenario where it'd be null

#

Maybe in a DM

charred geyser
#

yea

sonic lodge
#

wouldn't the collection just be empty

faint prism
#

good point

charred geyser
#

yea

#

i guess

faint prism
#

It may never actually be null

charred geyser
#

anyway

#

its better safe then sorry

#

so for the next bit i want to check if the channel type is text

faint prism
#

🤷‍♂️ wouldn't hurt

drifting wedge
#

whats the on typing

#

like make the bot say is typing

charred geyser
#

and if it is i want it to send the message

#

guild.channels will give all the channels right?

#

so i need to pick a channel

#

which would be guild.channels.cache.first()

#

right?

faint prism
#

I believe so

charred geyser
#

so would i let channel = guild.channels.cache.first()

faint prism
#

Mhmm

charred geyser
#
        let channel = guild.channels.cache.first();
        for(let c of guild.channels) {
        if(!c) return;
        if(channel.type === 'text'){
            channel.send(BotJoinMessage)
        }
#

but i dont think that will work

sonic lodge
#

you aren't doing anything with c

charred geyser
#

oh

faint prism
#

That for loop is unnecessary in that snippet lol

charred geyser
#

how else would i find the first channel

faint prism
#

you aren't doing anything with c
@sonic lodge Correct me if I'm wrong but isn't fisrt() the same as guild.channels.cache[0]?

charred geyser
#

guild.channels.cache.first(); apparently returns a category

sonic lodge
#

no

faint prism
#

well, ig one would be nullable, the other throws an exception if the array is empty

sonic lodge
#

guild.channels.cache[0] would be undefined

charred geyser
#

i do this

#
    let link = client.generateInvite(["ADMINISTRATOR"]);
    console.log(("INVITE: ")+(link));```
#

i think

#

something like that

#

it generates a invite with admin permissions

#

oh shit

faint prism
#

it'd be a method

charred geyser
#

mine is bot invite

#

you said server invite

#

sorry

faint prism
#

oh d.js has a bot invite generator? neat

charred geyser
#

yea

#

well it worked in v11 i haven't tried after updating

faint prism
#

I've always done:
discord.com/oauth2/authorize?client_id={clientId}&scope=bot&permissions=0

charred geyser
#

that gives the bot no perms

#

i always use =8

faint prism
#

wdym?

#

Bot's can join via a server invite

drifting wedge
#

how do i add commands to cogs?

earnest phoenix
quartz kindle
#

it failed to install canvas

#

did you install all the canvas dependencies?

earnest phoenix
#

I got canvas 2.6.1

#

It seems like it's trying to install canvas 2.5.0 but fails

quartz kindle
#

weird lol

#

try going into node_modules/color-thief

#

and edit its package.json

#

to use canvas 2.6.1

misty sigil
#

pacakg.json editing are we

#

hi tim

earnest phoenix
#

How to when i don't even have the package installed?

#

Like it fails doesn't it?

misty sigil
#

it might be in node_modules still tho

quartz kindle
#

use -s

misty sigil
#

ok

earnest phoenix
#

What does that flag do

misty sigil
#

i'll accept that as a solution because tim

charred geyser
#

ok after many attempts i still cant get it working

quartz kindle
#

-s / --save

charred geyser
#

tim how do i make the bot send a message upon joining a server @quartz kindle

#

it worked in v11 but now that ive upgraded it just doesn't

misty sigil
#

I wanna play a music stream 24/7 in my channel, but FFMPEG stops playing 1-12 hours later

still merlin
#

I’m thinking of using auth with my discord bot to fetch global guild counts and other stuff, Except I don’t know what to do first, I’d assume I need to give my bot scopes etc, But what would I do then? I’d guess id make a “auth.json” and require it, And shove something like this in auth.json (On a phone and don’t have code blocks, sorry)

{
client_id: 'bot id',
client_secret: 'client secret',
grant_type: 'authorization_code',
redirect_uri: 'redirect url with permissions api calculator or smthin',
scope: 'the scopes',
}
but like json formation, could someone explain setting up auth to me please?

earnest phoenix
#

@quartz kindle Tried the save flag but it's not found in the node_modules folder

steep shale
#

Does anyone mind walking me through css for my bot’s description?

charred geyser
#

on the discord server list?

steep shale
#

yeah

#

Like how this guy did for example

misty sigil
#

you can't do it for servers iirc

steep shale
#

Background?

#

What about the background

drifting wedge
#

embed=discord.Embed(colour=self.random_color, title='Have any ideas? Leave them in our discord!')
embed.set_image(submission.url)

    await channel.send(f'{embed}')
#

this is wrong

#

but like whats wrong:

#

i want it to send the embed with the picture

slender thistle
#

set_image(url=submission.url)

charred geyser
#

@slender thistle can you help me make my bot send a message upon joining a server

drifting wedge
#

@slender thistle

#

saying command meme not foun

slender thistle
#

Send code

drifting wedge
#

1 sec

slender thistle
#

@charred geyser on memberjoin event, member.send

charred geyser
#

no

#

i mean the bot joining

#

like guildCreate event

slender thistle
#

guildjoin

charred geyser
#

yeah but

slender thistle
#

Oh it was you from a few somewhat minutes ago

charred geyser
#

what i can't figure out is how to get the channel

#

yea

slender thistle
#

Tbh I'd suggest not doing it at all

charred geyser
#

it worked in v11

#

rip

#

in v11 i was able to do let defaultChannel = ""; guild.channels.forEach((channel) => { if(channel.type == "text" && defaultChannel == "") { if(channel.permissionsFor(guild.me).has("SEND_MESSAGES")) { defaultChannel = channel; } } }) defaultChannel.send(BotJoinMessage)

drifting wedge
#

0Exe#9581

earnest phoenix
#

wait you can store multiple objects in the same JSON file

{
  "lmao": "lmao"
}
{
  "lmao":"lmao"
}

doesn't look valid JSON to me there are no commas between objects
||@quartz kindle is my crush||

charred geyser
#

same

#

tim is our saviour and messiah

slender thistle
#

If you need 2 separate JSONs in one file, you'd have to make keys for each one or make it an array

earnest phoenix
#

If you need 2 separate JSONs in one file, you'd have to make keys for each one or make it an array
@slender thistle discord markdown said it is correct syntax

misty sigil
#

no i dont think you can

#

you can however

earnest phoenix
#

lol wut

slender thistle
#

I wouldn't rely on Markdown highlighting

earnest phoenix
#

no i dont think you can

you can however

yeah it's big brain time

misty sigil
#
{
"1": {},
"2": {}
}```
slender thistle
#

or use an array

broken jay
#

Hi

slender thistle
misty sigil
#

or that but thats no fun shibaco

earnest phoenix
#

that's not what i said

slender thistle
#

it just doesn't work

sudden geyser
#

{} alone makes a new scope

earnest phoenix
#

k

#

seriously need to start reading MDN and be a real man rather than follow grasshopper app (BY GOOGLE) and still remain confused

#

why did i quote that message

misty sigil
#
{
"1": {"foo": "bar"},
"2": {"a": "b"}
}``` would work if my json knowledge is good enough
earnest phoenix
#

that's not wut i asked

#

see the pic that SHEEVACU sent

real niche
#

what about it?

misty sigil
#

yea what bout it

slender thistle
#

You can see that it was highlighted in the browser too but didn't work

real niche
#

It's a javascript console. It parses json.

#
[
  {
    "lmao": "lmao"
  },
  {
    "lmao":"lmao"
  }
]```
earnest phoenix
#

k

steep shale
#

So can someone walk me through using css for my bot description?

#

I wanna customize the background of my bot

drifting wedge
#

@slender thistle

#

did u see the pastebin?

slender thistle
#

creating new client objects on each command usage

#

Again, bad practice

#

but I'll just ignore that from now on

earnest phoenix
slender thistle
#

Are you sure the cog is being loaded

real niche
#

I can't remember if non-certified bots are allowed to use style tags (I don't think so though). I'm pretty sure you can use the style attribute though.

#

You can also use markdown.

#
<h1 style="asjkfsj">Bot name</h1>```
slender thistle
#

JS is restricted for certified bots, HTML and CSS are not

real niche
#

So html <style> style { style1: true; } </style> is allowed?

slender thistle
#

mhm

#

<script> isn't

real niche
#

Oh. I thought both script and style tags were.

fringe axle
#

How can I get if the user is boosting and since when? (discord.js v12)

steep shale
#

Which library

fringe axle
#

discord.js v12 (forgot that, sorry)

steep shale
#

Sorry Im only discordpy

fringe axle
#

Okay, no problem

digital ibex
#

wrong url

misty sigil
#

How can I get if the user is boosting and since when? (discord.js v12)
@fringe axle <member>.premiumSince

fringe axle
#

Oh, thanks!

#

And how can I check it if he‘s boosting @misty sigil?

steep shale
#

Idk if its like py but use a bool

undone salmon
#

probably premiumSince will return 0 if they are not boosting

#

dont take my word for it though

#

just a guess

misty sigil
#

it will

undone salmon
#

how do i get my bot to say watching

steep shale
#

What library

fringe axle
#

Okay

undone salmon
#

wait wrong server

restive furnace
#

{ type: "LISTENING", name: "Hi", url: null } for presence object iirc

undone salmon
#

sorry

#

meant to put that in discord js server lol

#

thanks

steep shale
#

Damn everyone does js

undone salmon
#

yeah

steep shale
#

Am i the only one here who uses py

undone salmon
#

my bot is for music so im not sure how to do music bots in py

steep shale
#

Using lavalink

undone salmon
#

oh

restive furnace
#

because it's probably more beginner friendly (and more error prone cough cough)

steep shale
#

js more beginner friendly?

#

nah

#

It looks complicated when I saw some code from it

#

Im used to py

high blade
#

Is there a reliable way to get embeds from a message that your bot just sent?

#

It seems really unreliable

undone salmon
#

what do you mean by get

high blade
#

Ok so basically

#

My bot allows you to define custom commands

undone salmon
#

Ok

high blade
#

To give info to people

restive furnace
#

Im used to py
yeah cause, you're used to py, but for beginners, the syntax might look easier, or who knows ¯\_(ツ)_/¯

high blade
#

This info often includes links

#

We don't want the link embeds to show up

undone salmon
#

ohj

high blade
#

Because they're way too big

#

But we do want image embeds to show up if we linked an image

undone salmon
#

oof idk how to do that

high blade
#

I'm struggling to find a reliable way to do this

#

Like everything I do that works is a hack

#

Currently I get the embeds, filter for image embeds, suppress embeds if there's non-image embeds (embeds.length > imageEmbeds.length), and then edit the message to re-add each image embed

#

But sometimes it just returns an empty array for the embeds...

#

So some of the time it won't remove the embeds

undone salmon
#

yeah i dont know that deep into it i think you should ask in discord js server

high blade
#

😢

undone salmon
#

if you are using js

#

which i guessign you are?

high blade
#

Yeah I am

#

I'm gonna ask there now, cheers

undone salmon
#

i cant post link but you should be able to ask there

#

just a warning some people there are EXTREMELY good at it and might seem a bit rude

#

but they will solve your issue 100%

#

i expect

charred geyser
#
        const user = message.mentions.users.first() || message.author;
        if (!user) return message.channel.send("Please specify a user!")
        const avatarEmbed = new Discord.RichEmbed()
            .setColor(0x333333)
            .setAuthor(user.username)
            .setImage(user.avatarURL);
        message.channel.send(avatarEmbed);
#

TypeError: Cannot read property 'users' of undefined

#

what am i doing wrong

undone salmon
charred geyser
#

its html

#

thats not really anything to do with my issue i dont think

undone salmon
#

oh my bad lol

charred geyser
#

np

#

i guess its something to do with message.mentions.users.first()

#

is that not a thing in v12?

#

or should it be users.cache.first

misty sigil
#

no?

charred geyser
#

what is wrong then

restive furnace
#

user.cache.first() probably returns the clientuser iirc

charred geyser
#

how can i get mentioned then

#

alr

restive furnace
#

message.mentions.first()

#

go look the docs or smth

charred geyser
#

TypeError: Cannot read property 'first' of undefined

#

i guess i will just thought it would easier to ask here

fringe axle
#

Then message.mentions is not defined.

earnest phoenix
#

@charred geyser what mentions u mentioned ?

#

members, roles, channnel ?

#

what

charred geyser
#

member

#

@earnest phoenix

earnest phoenix
#
const member = message.mentions.members.first()

@charred geyser ^^^

#

you need to get member from all mentions

charred geyser
#

so members not users

#

TypeError: Cannot read property 'members' of undefined @earnest phoenix

earnest phoenix
#

hmm show what did u typed

charred geyser
#

this is my code

#
        const user = message.mentions.members.first() || message.author;
        if (!user) return message.channel.send("Please specify a user!")
        const avatarEmbed = new Discord.RichEmbed()
            .setColor(0x333333)
            .setAuthor(user.username)
            .setImage(user.avatarURL);
        message.channel.send(avatarEmbed);
earnest phoenix
#

rich embed ?

#

hmm you are v11

charred geyser
#

ii was

#

iim updating

earnest phoenix
#

THEN UPDATE

charred geyser
#

i can change that but thats not the issue

earnest phoenix
#
npm install discord.js@12.x.x

First then we will see what is the problem

charred geyser
#

i already updated

mental rivet
#

i made a bot that does absolutly nothing

charred geyser
#

lol

#

i made a bot that does absolutly nothing
@mental rivet nice

earnest phoenix
#

@charred geyser did you mentioned a user when testing ?

charred geyser
#

i am just fixing all my old v11 commands

earnest phoenix
#

now test it again

charred geyser
#

TypeError: Cannot read property 'members' of undefined

earnest phoenix
#

hmm

#

console.log(message.mentions) ?

#

@charred geyser and try without

|| message.author
charred geyser
#

ok

#

nope TypeError: Cannot read property 'members' of undefined

#

console didn't log

earnest phoenix
#

huh ?

#

wtf

#

show console

#

@charred geyser Show all of ur file

charred geyser
#

thats console

#
const Discord = require("discord.js");

module.exports = {
    name: "avatar",
    category: 'general',
    description: "Displays the mentioned users profile picture in an embed.",
    usage: "avatar \@username",
    run: (message, args, users) => {
        const user = message.mentions.members.first();
        console.log(message.mentions)
        if (!user) return message.channel.send("Please specify a user!")
        const avatarEmbed = new Discord.MessageEmbed()
            .setColor(0x333333)
            .setAuthor(user.username)
            .setImage(user.avatarURL);
        message.channel.send(avatarEmbed);
    }
}
#

thats the command file

earnest phoenix
#

what is users ?

#

but nvm

#

show me ur message.js event

charred geyser
#

the whole thing?

earnest phoenix
#

just the message event

#

client.on("message") or some thing like that

charred geyser
#

i have it like modules in an events folder

earnest phoenix
#

yes taht file

charred geyser
#

this is the main bit

earnest phoenix
#

message.js

charred geyser
#
    const prefix = settings.prefix;

    if (!message.guild) return;
    if (!message.content.startsWith(prefix)) return;
    
    if (!message.member) message.member = await message.guild.fetchMember (message);

    const args = message.content.slice(prefix.length).trim().split(/ +/g);
    const cmd = args.shift().toLowerCase();
    
    if (cmd.length === 0) return;
    
    let command = client.commands.get(cmd);
    if (!command) command = client.commands.get(client.aliases.get(cmd));
    
    if (command)
        command.run(client, message, args);
#

the rest is just for mongodb

earnest phoenix
#

bruh

#

command.run(client, message, args)

#

so it will be

run : async(client, message,args) => {}
#

@charred geyser ^^^

#

._.

charred geyser
#

in the command?

earnest phoenix
#

in ur avatar command

charred geyser
#

yea

#

=> {*

#

yeah

#

ok

#

let me test

earnest phoenix
#

ok

charred geyser
#

oh shit

#

ok so it returned

#

but it isn't actually getting the user

earnest phoenix
#

btw this is wrong

    if (!message.member) message.member = await message.guild.fetchMember (message);
charred geyser
#

[20:29] seasnail: %avatar @pliant gorge
[20:29] BOT█▀█ █▄█ ▀█▀: Please specify a user!

earnest phoenix
#

huh ?

#

show code

#

what u have done

charred geyser
#
        const user = message.mentions.members.first();
        console.log(message.mentions)
        if (!user) return message.channel.send("Please specify a user!")
        const avatarEmbed = new Discord.MessageEmbed()
            .setColor(0x333333)
            .setAuthor(user.username)
            .setImage(user.avatarURL);
        message.channel.send(avatarEmbed);
earnest phoenix
#

@charred geyser console.log(args[0])

#

uhmm

#

wut

#

why it is red ?

#

console.log(args[0])
@charred geyser

charred geyser
#

instead of console.log(message.mentions)?

earnest phoenix
#

yes

green bison
#

hi anyone know whats this
(node:180544) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit

#

hi anyone know whats this
(node:180544) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit

#

hi

earnest phoenix
#

hi

green bison
#

hi anyone know whats this
(node:180544) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit

earnest phoenix
#

u added too much eventListenters

#

maybe

charred geyser
#

brb]

earnest phoenix
#

??

misty sigil
#

hi anyone know whats this
(node:180544) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit
@green bison show code

green bison
still merlin
#

Are you using “client.on” for all of your commands?

green bison
#

yes

misty sigil
#

What

#

use an if/else statement

#

please

still merlin
#

To fix your issue use a command handler, or all in one client.on event

earnest phoenix
#

@charred geyser wut happned ?

green bison
#

@still merlin ok ty

#

ty

#

ty

opal plank
#

finally i think i stabilized the cache enough

#

very little ram as well

#

take that d.js

misty sigil
#

i mean

#

d.js-light

opal plank
#

its not discord

#

its twitch

#

just banking on d.js for being ram hungry

misty sigil
#

yes

#

as i could tell by serving streams

opal plank
#

and offline events being emitted just fine too

#

im happy now

misty sigil
#

happy time?

opal plank
#

happy time

earnest phoenix
#

@opal plank bruh how ur bot is so big ?

opal plank
#

This rn is just stress testing, my numbers a bit lower than that

earnest phoenix
#

._.

#

1000 stream

opal plank
#

yes

earnest phoenix
#

YOU LIER

opal plank
#

no, theres 1000 streams rn with it

earnest phoenix
#

wut

opal plank
#

yeah

earnest phoenix
#

so it is real 1000 stream

opal plank
#

yes

earnest phoenix
#

nvm i will go sleep bye

opal plank
earnest phoenix
#

@green bison

#

still need help?

#

its easier to just do

#

import random
message.channel.send(f'{random.choice(myquotes)}')

drifting wedge
#

how do i embed images?

worldly nebula
#

Via embedding

misty sigil
#

@earnest phoenix that isnt js is it

earnest phoenix
#

its python

misty sigil
#

legend's in js mmulu

earnest phoenix
#

its python my g

earnest phoenix
#

😂

#

cant tell if ur being sarcastic

opal plank
#

im not

#

this is what Legend sent

#

did not scroll further than that, but i assume is their's, and this is js 100%

earnest phoenix
#

im a retard

#

lowe me

opal plank
earnest phoenix
#

i go so confused for a sec

#

my brain just malfucntioned

#

cant even type

charred geyser
#

@opal plank what server is that from 😁

opal plank
#

@charred geyser ?

charred geyser
#

:02pat:
@opal plank

opal plank
#

Meow

#

/catgirl

charred geyser
#

oh

#

okay

marsh lava
#

so i set up my bot on heroku but after about 5 minutes it just stops

#

w h a t

charred geyser
#

whats the error?

#

like when it shuts down

proven lantern
#

heroku just shuts down after no actvity

marsh lava
#

well is there a way to keep it online even if there is no activity

charred geyser
#

v<@&751140053933228104>

opal plank
#

without breaking Tos? No

charred geyser
#

oops

#

lol

marsh lava
#

that sucks

proven lantern
#

listening to bot messages requires a constant socket connection

charred geyser
#

anyone know how to get a users avatar and username

#

in an embed

opal plank
#

actually

#

wait

#

i dont think heroku needs uptimers

#

only glitch

#

i already asked them, glitch and rep.l before to once and for all confirm wether discord bots are allowed on their platform

misty sigil
#

who is erwin

opal plank
#

Not me for sure

charred geyser
#
.setAuthor(user.username)
.setImage(user.displayAvatarURL);
misty sigil
#

and why are you in their emails

#

you aren't erwin

opal plank
#

#HAxxd

charred geyser
#

lol

marsh lava
#

after displayavatarurl u need to put ()

charred geyser
#

and username?

marsh lava
#

uh

opal plank
#

avatarURL is a method

#

not a property

marsh lava
#

depeneds on who u want the name of

charred geyser
#

const user = message.mentions.members.first();

#

thats user

opal plank
#

though i have a feeling i said that before and there was one instance in v11 where it had an avatarURL property in it

marsh lava
#

then user.username

#

i think

charred geyser
#

but user.username gives undefined

steep shale
#

So to change my bot’s background pic is this how you do the html?

marsh lava
#

are u mentioning a user

#

in the message

charred geyser
#

yeah

earnest phoenix
#

curly bracket at the end

#

change it for a normal bracker

charred geyser
#

tha command is %avatar @granite pagoda

steep shale
#

It goes ...url("url-link"; and then the }

earnest phoenix
#

show the full code

steep shale
charred geyser
#

of the entire module or just what is run

earnest phoenix
#

do this

#
<style>
body{
background-image: url('HERE');
}
</style>
steep shale
#

Oh I forgot the )

#

<html>
  <style>
    body{
    background-image: url("https://images.app.goo.gl/56jXM17CEnESWa927);
    
    }
</style>```
#

Like that then?

#

oh sht forgot the "

earnest phoenix
#

add the "

#

yyhhy

steep shale
#

<html>
  <style>
    body{
    background-image: url("https://images.app.goo.gl/56jXM17CEnESWa927");
    
    }
</style>``` still nothing
earnest phoenix
#

show me the full html file

#

because idk if u have added

#

</html> at the end