#development

1 messages ยท Page 1207 of 1

half elm
#

how

#

why

earnest phoenix
#

U wanna flex that u got ur bot to give Embed messages...

half elm
#

bruh

#

im asking

earnest phoenix
#

:/

half elm
#

a valid question

ionic dawn
#

You have to do something like: *const chn = client.channel.cache.get("ChannelID")

And then chn.send(Embed)

#

@earnest phoenix

earnest phoenix
#

HUHH?

#

Thats confusing because i dont know where to put the codes

ionic dawn
earnest phoenix
#

I'm new to creating bots, u can't doubt me :<

ionic dawn
#

@half elm try not using the ||

#

Only check forcauthor and see if it works

half elm
#

okay

golden condor
#

@half elm user.avatarURL()

half elm
#

()?

ionic dawn
#

True its a function

golden condor
#

Yes

#

It's a function

half elm
#

i see

ionic dawn
golden condor
#

That's why it isn't working

pale vessel
#

yes it's a method

golden condor
#

Same thing

pale vessel
#

use displayAvatarURL() if you want to support default avatars

golden condor
#

^

ionic dawn
#

Otherwise wont show if the user has no avatar realstate

worthy glacier
#

??

half elm
#

if (!user.avatarURL()) {
displayAvatarURL() code here

#

?

ionic dawn
#

@worthy glacier its literally giving you the answer

#

Use an async function

half elm
#

yep

#

need async function

worthy glacier
#

so i do function = async (stuff) => {}

golden condor
#

no don't do that @half elm

ionic dawn
#

async function bla(){
// code
}

earnest phoenix
#

so, exactly like this?
@ionic dawn
You have to do something like: *const chn = client.channel.cache.get("ChannelID")

And then chn.send(Embed)

golden condor
#
const user = message.mentions.users.first() || message.author;
const avatarEmbed = new Discord.MessageEmbed()
      .setColor(0x000000)
      .setAuthor(user.username)
      .setImage(user.avatarURL);
message.channel.send(avatarEmbed);

@half elm make this be member instead

#

Like

half elm
#

member.username?

golden condor
#

const user = message.mentions.members.first() || message.member

half elm
#

ah

golden condor
#

It would be the samd

half elm
#

so where would this change

#

and what makes it work?

golden condor
#

well

#

Instead of getting a user

#

It gets a member of the server you are currently in

#

Meaning you can still access their user data

#

But you can see displayAvatarURL iirc

worthy glacier
golden condor
#

Oh wait no nvm

#

Keep it as it is

half elm
#

?

#

ah okay

golden condor
#

but

#

change avatarURL => displayAvatarURL()

#

@worthy glacier async (err, server)

worthy glacier
#

oh thank you

weak rain
#

i have seted my interval as 180000 but it sends every 1min

half elm
ionic dawn
#

Code again?

half elm
#
const user = message.mentions.users.first() || message.author;
const avatarEmbed = new Discord.MessageEmbed()
    .setColor(0x000000)
    .addField(`${user.username}'s Avatar`)
    .setImage(user.displayAvatarURL());
message.channel.send(avatarEmbed);
#

do i need a title

ionic dawn
#

Fields vace 2 values

half elm
#

im guessing thats the issue

#

link and inline right?

ionic dawn
#

Have*

half elm
#

oh wait

#

right

weak rain
#

user is undefined

#

no

half elm
#

lmao no

ionic dawn
#

^ no

#

Fields require 2 values

half elm
#

true

weak rain
#

oh yeah

half elm
#

can i use that in place of title?

weak rain
#

set it to title

#

no

#

yes

#

xD

half elm
#

xD

ionic dawn
#

Like val: "hey", val: "nice"

weak rain
#

i have seted my interval as 180000 but it sends every 1min

ionic dawn
#

Use title instead ye

weak rain
#

@ionic dawn

half elm
#

@weak rain

ionic dawn
#

?

half elm
#

send code pls

weak rain
#

kk

ionic dawn
#

Cant fix my own bot but can help others

half elm
#

๐Ÿ˜‚

weak rain
#
        const channel = message.guild.channels.cache.find(channel => channel.topic === "Memes");
        if(!channel) return;      let data = await random.getMeme()
        channel.send(data)
  
    }, 180000)  ```
golden condor
#

Do you have multiple intervals?

weak rain
#

no

ionic dawn
#

I dont think this is the right way to set the interval tbh

weak rain
#

its okay i guess

ionic dawn
#

Actually in on phone and read that is kinda crazy

golden condor
#

Same

half elm
#
var interval = setInterval (async function (guild) {
    const channel = message.guild.channels.cache.find(channel => channel.topic === "Memes");
    if(!channel) return;
    let data = await random.getMeme()
    channel.send(data)
}, 180 * 1000); 
#

try this

#

i guess

ionic dawn
#

Mathemagician

golden condor
ionic dawn
half elm
#

๐Ÿ˜‚

ionic dawn
#

const num = 1
const num = 1 * 1

half elm
#

lmao no

ionic dawn
half elm
#

typo

#

lemme fix

robust furnace
#
 const user = message.mentions.users.first() || message.author;
 const avatarEmbed = new Discord.MessageEmbed()
     .setColor(0x000000)
     .addField(`${user.username}'s Avatar`)
     .setImage(user.displayAvatarURL());
 message.channel.send(avatarEmbed);
ionic dawn
#

^

half elm
#

i did that

robust furnace
#

YEP

half elm
#

so that he can multiply with min

robust furnace
#

Just with js

half elm
#

oh no my problem was solved

#

thanks anyway Iceter

robust furnace
#

๐Ÿ˜ฆ

#

๐Ÿ™‚

half elm
#

lmao

robust furnace
#

\๐Ÿ˜ด

#

bruh

half elm
#

it was pretty much clarified before

#

but thanks anyway

#

damn i cant talk today

ionic dawn
#

8.30AM time to wake up

half elm
#

tf

sharp thicket
#

any help

#

or

#

im sad :(

golden condor
#

Used more than your YouTube API limit

sharp thicket
#

hmm

#

what that mean Think1

#

so my other code is fine?

fathom topaz
#

@no xp

sharp thicket
#

wot

#

@golden condor is my other code fine tho (sorry for ping plz no bulli )

golden condor
#

Your API key

#

Has run out

#

Of daily quota

sharp thicket
#

oh

#

can i just get a new one?

#

as im using my friends LOL

golden condor
#

You can or you could just wait

sharp thicket
#

24h?

golden condor
#

Yes

sharp thicket
#

um uh

golden condor
#

Or until the time it says

sharp thicket
#

ill just change it Think1

golden condor
#

ok

sharp thicket
#

is my other code ok tho

#

as im scared about that

#

it gib me anxiety

pure lion
#

@sharp thicket which code

sharp thicket
#

here i get this error

#
(node:4) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'queue' of undefined
 at play (/app/commands/utility/system.js:9:23)
    at Object.run (/app/commands/config/play.js:132:9)
     at processTicksAndRejections (internal/process/task_queues.js:97:5)
 (node:4) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
2020-09-01T06:52:25.278105+00:00 app[worker.1]: (node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
#

@pure lion wait ima get a bin real quick

#

this is my play.js

#

@pure lion u there?

#

ok ytping..

#

sry

pure lion
#

Where is queue

sharp thicket
#

ok wait

#

here

#

@ me when u reply

pure lion
#

try doing bot, message, args

#

@sharp thicket

sharp thicket
#

also

#

lol i did

#

thats my index.js

#

@pure lion

#

also i changed my api token

#

@pure lion sorry for the pings im getting a new error...

#
(node:4) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined
    at play (/app/commands/utility/system.js:8:29)
     at Object.run (/app/commands/config/play.js:132:9)
     at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:4) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
 (node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
#

anyone any help

#

?

#

:(

pine aspen
#

Hey! How could I make a custom time format. Like 1h = 60m = 3600s = 3600000ms?

#

@sharp thicket send your code.

#

oh

#

wait nvm

#

discord.js v12?

#

can i have the play command

#

that's where the issue is.

slender thistle
#

A fuckton of .replaces is an option if not through regexes

pine aspen
#

LOL

#

.repace

#

@slender thistle, how? Find filter and then get the hour in ms * the time?

slender thistle
#

.replace("h", "*60") and run the expression through a package for math expressions

pine aspen
#

ok ty

slender thistle
#

60 minutes converted to seconds being m replaced with *60 etc

earnest phoenix
#

how do i make a bot send messages every 10 minutes?

pine aspen
#

@earnest phoenix you need to use the setInterval.

earnest phoenix
#

ntf

pine aspen
#
setInterval(() => {
  // code
}, time in ms);
earnest phoenix
#

thats it?

pine aspen
#

Yep ;p

earnest phoenix
#

Aight, thanks mate

pine aspen
#

np

#

๐Ÿ™‚

earnest phoenix
#

๐Ÿ™‚

pure lion
#

๐Ÿ˜„

earnest phoenix
#

i feel scared

golden condor
#

Why

earnest phoenix
#

idk l;-;

#

Where do i put the time?

#

setInterval(() => {
// code
}, this is where i put time?);

slender thistle
#

See the time in ms part?

earnest phoenix
#

yes

slender thistle
#

What do you think that would be?

earnest phoenix
#

;-;

#

ik

#

idk

slender thistle
#

What exactly are you confused about?

earnest phoenix
#

idk ;-;

#

setInterval(() => {
// code
}, 1000000000000000000000000000000000);

slender thistle
#

The first parameter (the () => stuff) is the function to run
The second parameter is... yeah, that's where you put the time (measured in milliseconds). It will be the interval between each function execution

earnest phoenix
#

hehe

#

1 Billion

#

(i think)

slender thistle
#

Why not just Google 10 minutes in milliseconds

#

Time conversion is a helpful skill in life :p

earnest phoenix
#

Smart

slender thistle
#

or, hell, calculate it yourself

earnest phoenix
#

600,000

slender thistle
#

a minute consists of 60 seconds
a seconds of 1000 milliseconds

#

so, that's 10*60*1000

earnest phoenix
#

huh ;-;

slender thistle
#

which, when calculated, does actually give you 600 thousand milliseconds

earnest phoenix
#

why are u people so smart

slender thistle
#

They don't teach this shit in early grades anymore?

earnest phoenix
#

nope ;-;

honest perch
#

They don't teach this shit in early grades anymore?
@slender thistle no

earnest phoenix
#

In my grade we're still learning 1+1

honest perch
#

Its poothon now

#

Atleast in the uk

slender thistle
#

I get trigonometry and generally calculus, but

#

this is like the very basic thing that's quite helpful in life

honest perch
#

I get trigonometry and generally calculus, but
@slender thistle you get what and what

earnest phoenix
#

anyways, how do i put a mesage into it?

slender thistle
#

you want to send a message to a certain channel, correct?

earnest phoenix
#

uhh, yessir

slender thistle
#

Well, get the channel (not exactly familiar with d.js nowadays, I suggest looking up the documentation) and send the message? :^)

earnest phoenix
#

huh ;-;

#

im trying to get the bot to send a message every 10 minutes

#

;-;

pale vessel
slender thistle
#

Where will the message param be received though?

pale vessel
#

the message event?

slender thistle
#

๐Ÿ‘€ I thought they wanted an interval?

earnest phoenix
#

Wdym?
i'm making something like pokemon, but the pokemon are dinosaurs

pale vessel
#

interesting

#

you can create a command that creates an interval

earnest phoenix
#

Its gonna go with the theme of my MC realm (DinoSMP)

#

what does an interval even do?

#

still learning ;-;

slender thistle
#

Do you know the definition of "interval"?

earnest phoenix
#

n o

slender thistle
earnest phoenix
#

Wdym?
i'm making something like pokemon, but the pokemon are dinosaurs
oh

#

ahh, interval means a time, or break in certain activity like a plug in a pipe making it stop from water going through?

#

ye

#

I see

#

what do u want the bot to do

slender thistle
#

do X, wait Y time, do X
Y being the interval

earnest phoenix
#

I just want to get it to send messages every 10 minute, and then i want to code leveing and stuff

#

oh

#

will u make the bot public

#

or only use it in ur server

#

It depends on if there is already a bot like that

#

with dinosaurs

#

dinos?

#

nice

sharp thicket
earnest phoenix
#

maybe u can put a loop which runs every x minutes in on_ready function

sharp thicket
#

me?

earnest phoenix
#

no

#

@earnest phoenix

sharp thicket
#

oh lol

earnest phoenix
#

huhh

#

i have a big brain, but my big brain is filled with stupidity, i dont unerstand what that means ;-;

#

oh

#

its like..

slender thistle
#

You're confusing them with python code

#

they're js

earnest phoenix
#

u need to code a loop which executes as soon as the bot comes online

#

isnt there a function

slender thistle
#

throwback to the setInterval function

earnest phoenix
#

oh

#

no on_ready in js?

#

huhh?

slender thistle
#

You'd need to use setInterval, as suggested before

earnest phoenix
#

where in the code?

slender thistle
#

in the ready event possibly

earnest phoenix
#

Oh, setInterval(() => {
// code
}, 1 billion ?);

#

.-.

#

yeah, alright, but now i just need it to send message

#

grab channels

#

and send messages

slender thistle
#

600000

#

not 1 billion

earnest phoenix
#

no its 1 billion

slender thistle
#

10 minutes is 600 thousand milliseconds though

earnest phoenix
#

So where do i put the message code? on top of setInterval, or?

#

10 minutes is 600 thousand milliseconds though
@slender thistle
i know

slender thistle
#

Replace the // code part with your code that will fetch a channel and send a message to it

earnest phoenix
#

so i replace code with channel name or ID

pale vessel
#

are users allowed to run the command multiple times?

#

that would create duplicates

earnest phoenix
#

huh

mossy slate
#

I need help adding a role to a user so like [p]add @mossy slate [role]

earnest phoenix
#

discord.js?

mossy slate
#

yes

earnest phoenix
#

role mention or id

mossy slate
#

I'm thinking of plain text

#

so like [role] = Smart

near bone
#

hey uh, is it kinda bad that im just now tryna learn jsx so i can script a bot of my own

earnest phoenix
#

eeh

mossy slate
#

hey uh, is it kinda bad that im just now tryna learn jsx so i can script a bot of my own
@near bone I don't think so

pale vessel
#

you can do both mmLol

#

make a resolver

near bone
#

also, are we allowed to try and hire teams here

pale vessel
#

no

near bone
#

k

mossy slate
#

I need help adding a role to a user so like [p]add @mossy slate [role]

#

HELP ME \๐Ÿ™‡

pale vessel
#

be patient

mossy slate
#

ok sorry \๐Ÿ™

near bone
#

does anyone here know any good code things for chrome os devices

#

for future reference

earnest phoenix
#

Replace the // code part with your code that will fetch a channel and send a message to it
@slender thistle
message.channel.send(' ')?

pale vessel
#

looks correct but make sure that's what you want, the bot sending in the message's channel

earnest phoenix
#

huh?

#

did u speak English?

pale vessel
#

bulli

earnest phoenix
#

heh

cinder sandal
#
setInterval(() => {
// your code
}, 600000);```
earnest phoenix
#

yup

cinder sandal
#

600000 can be any time in ms

earnest phoenix
#

600000 is 10 mins

near bone
#

lazy and bot designing do not mix well

cinder sandal
#

you can use an time to ms conventor

near bone
#

so this will be tough

#

for me

earnest phoenix
#

the your code is replaced with message.channel.send('test')

cinder sandal
#

yes

earnest phoenix
#

How to host my discord bot free?

#

How to host my discord bot free?
@earnest phoenix top.gg

#

How

cinder sandal
#

How to host my discord bot free?
@earnest phoenix Local Host, heroku

earnest phoenix
#

just get on top.gg and there is a thing where u can add ur bot

pale vessel
#

they said host

slender thistle
#

that's not hosting the bot

earnest phoenix
#

idfk

#

im an idiot ;-;

slender thistle
#

-vps @earnest phoenix

gilded plankBOT
#

@earnest phoenix

A VPS or virtual private server is a virtualized server instance run in the cloud. It acts like a normal server, allowing you to remotely login and manage it just like a physical server or computer. If you're looking for a way to keep your bot online 24/7, a VPS is a great option.

Having trouble choosing a VPS provider or don't know where to start? Click here for a list of common and affordable VPS providers.

near bone
#

question

#

is it a good idea to go and try to use google docs as a thing to put all my code into

wild current
#

Does anyone have a translate Api?

earnest phoenix
#

Does anyone have a translate Api?
@wild current google

near bone
#

killua

earnest phoenix
#

Lol, yes

near bone
#

do u know any good coding things for chrome os

#

preferably ones that use jsx

earnest phoenix
#

i'm new to coding overall, so i dont really know

wild current
#

I didn't found on google

earnest phoenix
#

i know, that was a joke

sterile thicket
#

code:

const input = message.content.slice(prefix.length).toLowerCase().replace(/\s+/g, ` `).trim();
const [, cmd, commandArgs] = input.match(/(\w+)\s*([\s\S]*)/);```
When I type "/........."
error:

TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))
at Client.<anonymous> (.\code.js:2:30)```

near bone
sick cloud
quartz kindle
#

{ [key]: value }

sick cloud
#

oh ok

#

and that does the same thing right

quartz kindle
#

yes, its a dynamic object key

sterile thicket
#

im doing a tutorial for react.js and im not sure what this even means
@near bone this things are html
you defined p1 as "poo" inside an html paragraph tag
then, a button tag with id "mybutton".
then again, you defined p2 as "bar" in another html paragraph tag

sick cloud
#

so

const key = 'bob'
const value = 'fred'

that'll produce { "bob": "fred" } right

quartz kindle
#

yup

sick cloud
#

sweet

#

ty

sterile thicket
#

can anyone help me understand the error?

#

code:

const input = message.content.slice(prefix.length).toLowerCase().replace(/\s+/g, ` `).trim();
const [, cmd, commandArgs] = input.match(/(\w+)\s*([\s\S]*)/);```
When I type "/........."
error:

TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))
at Client.<anonymous> (.\code.js:2:30)```

near bone
#

oh hey

#

it's just come to my attention that there's a full reference thing in a certain thing on discord's website

#

under the resources tab on the developer portal

sick cloud
#

yes why wouldn't there be one lmao

#

part of any good api

quartz kindle
#

@sterile thicket that happens if input is empty

near bone
#

so

#

is it just like some sort of crossword, where i just have to match along certain keywords to make the system do something

sterile thicket
#

@sterile thicket that happens if input is empty
@quartz kindle but input it "/......."

#

not empty

#

And I used if (!input.length) return; before input.match()
so, it shouldn't give me the error

quartz kindle
#

match found no matches

sterile thicket
#

how do I fix this?

quartz kindle
sterile thicket
#

ok, so I can do if (!input.match()) return; right?

quartz kindle
#

yes

sterile thicket
#

thanks

quartz kindle
#

save it in a variable so you dont parse it twice

sterile thicket
#

ok

#

what happens if you parse things twice?

quartz kindle
#

let test = input.match()
if(!test) return
const [,cmd,args] = test

#

nothing, just waste of cpu

sterile thicket
#

lol ok

#

thanks

earnest phoenix
#

hey guys

#

i just made my first bot with discord.python

sick cloud
#

ok

tight plinth
#

if i console.log the message via my eval command author is properly set

#

weird

rose bobcat
#

Your Line 2 is hardcoded

earnest phoenix
#

!msg.guild || msg.channel.type === "dm" :D?

slender thistle
#

Pointless to do both imo

tight plinth
#

in case of guild is not properly cached

#

but yeah

cinder sandal
#

why node.js for linux is outdated? (v10)
installed with sudo apt-get install nodejs

honest perch
#

install using the proper method then

cinder sandal
#

can't install from the website, unpacked the archive (tar.xz) to /usr/local/bin/lib/nodejs
says to install nodejs

honest perch
cinder sandal
#

is there a node command prompt for linux?

tight plinth
#

use node version manager

cinder sandal
#

i am on inux and i can't do heroku commands it needs to install a snap, but i have installed the npm package heroku in my bot folder

quartz kindle
#

@tight plinth supposedly some messages have no author fields, try checking the webhook id before you check for bots

tight plinth
#

k

quartz kindle
#

if you're using the message editing script, then thats especially true

#

since some messageUpdates only contain an ID and embed, and nothing else. so just do if(!message.author)

cinder sandal
#

i am on linux and i can't do heroku commands it needs to install a snap, but i have installed the npm package heroku in my bot folder
@cinder sandal

tight plinth
#

idk why but it seems that it works now

#

ty

quartz kindle
#

@cinder sandal why do you need heroku commands?

warm marsh
#

why node.js for linux is outdated? (v10)
installed with sudo apt-get install nodejs
Depends on the distro. Sometimes something depends on it.

cinder sandal
#

to login in the heroku cli

quartz kindle
#

fast developing packages are always outdated on linux

cinder sandal
#

i don't want to install the snap

#

the npm package is installed

warm marsh
#

If you're on linux why use heroku?

quartz kindle
#

^

#

if you have a vps why do you still need heroku?

warm marsh
#

Unless it's not a VPS and it's their desktop OS then maybe.

cinder sandal
#

it's my desktop os

warm marsh
#

You don't need to use snap.

#

They provide a standalone installation (on Debian systems without snap).

quartz kindle
#

you probably dont need the npm package either, unless you want to control heroku from inside your bot

cinder sandal
#

i need to run a command

#

heroku login

#

to push the bot

warm marsh
#

To push the bot from within the bot?

cinder sandal
#

maybe

#

i found heroku on Discover

warm marsh
#

Well, you can install the heroku cli using npm install -g heroku

#

Then from there you run your needed commands.

earnest phoenix
warm marsh
#

Read the docs?

cinder sandal
#

anyway, will install from Discover

warm marsh
#

The CLI?

cinder sandal
#

yes

earnest phoenix
#

Docsu okusam burada yazmazdฤฑm zaten

warm marsh
#

English.

sick cloud
#

this would work to get the content of an embeds footer, right
message.embeds[0].footer.text

#

pretty sure i'm right but too tired to be 100% sure

split hazel
#

Yes

sick cloud
#

i know but you get lazy sometimes mmLol

tight plinth
cinder sandal
#

Well, you can install the heroku cli using npm install -g heroku
@warm marsh sry for ping, but worked
ty

quartz kindle
tight plinth
#

no, didnt see that you edited it

warm marsh
#

np

sage meadow
#

if I am using Bot ghost but the status is offline can the devs able to know that i am using Bot Ghost

cinder sandal
#

@sage meadow maybe botghost is in maintanance, or wrong token

honest perch
#

how could i hide a div but only show it if the user is at url#divname

sage meadow
#

if I have made the status offline, can the devs able to know that i am using Bot Ghost

honest perch
#

dont spam the same question over and over again

split hazel
#

That's stupid anyways, it would circumvent bot ghosts free usage policies

#

And won't work

sage meadow
#

ok

quartz kindle
#

pokecord 2.0 using botghost

#

imagine

tight plinth
#

lol

#

more like rythm hosted on glitch

honest perch
#

pokecord 2.0 using botghost
@quartz kindle yes

still merlin
#

Can someone help me, I get this error and I'm not sure what to do, I've never used aysnc before

C:\Users\Jon\Desktop\SpiderBot Command Handler\commands\purge.js:20
        await message.channel.messages.fetch({ limit: amount }).then(messages => {
        ^^^^^

SyntaxError: await is only valid in async function```
fringe axle
#

Do you use run or execute

#

To run/execute the code

still merlin
#

execute

fringe axle
#

async execute

#

Done.

still merlin
#

thankyou very much

#

Do i need to change my other files or my index.js?

fringe axle
#

You need to change it to async execute where you need an async

still merlin
#

Oki, thankyou

fringe axle
#

No problem

golden condor
#

and i have no idea why

earnest phoenix
#

i forgot the syntax of client.user.setPresence can someone quickly link me the docs cuz i am too lazy

fringe axle
#

Can we see the code?

#

Yea, wait

earnest phoenix
#

You need to change it to aync execute where you need an async
@fringe axle spelling of async wrong

slender thistle
earnest phoenix
#

thanks

fringe axle
#

Faster :0

earnest phoenix
#

working on a smol repl.it template which people can use to make bots

#

does this mean which properties we can set to the activity object or are they parameters we can pass in client.user.setPresence???

#

i seriously need to learn how to read docs

slender thistle
#

activity.x - properties of the activity object parameter
activity, shardID, and status being parameters

earnest phoenix
#

shardID ain't a property of activity

#

imagine fixing someone's errors when they're the one trying to fix your errors

slender thistle
#

it's a parameter

earnest phoenix
#

i seriously need to learn how to read docs

#

lol

slender thistle
#

:^)

#

Yeah, it's not a property

earnest phoenix
#

also in node.js fs if i pass a file name in fs.readFileSync(); without any path does it default to the directory name of the current node.js process + the name of the file?
example:

const fs = require("fs");
const config = fs.readFileSync("config.json");
config = JSON.parse(config);
pale vessel
#

yes

#

i'd put ./config.json to be sure

#

assignment to constant variable

#

smh

fringe axle
#

How can I see the users custom presence (The text or emoji what they wrote in)? discord.js v12

earnest phoenix
#

accidentally sent the message without typing the whole thign

#

so...

fs.readFileSync(__dirname + "/config.json");

is the same as...

fs.readFileSync("config.json");

and/or is the same as...

fs.readFileSync("./config.json");
slender thistle
#

./ is for parent folder

earnest phoenix
#

wait wut

pale vessel
#

that's ../

#

./ is cwd

slender thistle
#

ah, still fucking that up

earnest phoenix
#

cwd???

#

lmao

slender thistle
#

current working directory

opal plank
#

absolute path is usually not a good idea thouhg

#

specially if you eventually need to move stuff around

fringe axle
#

How can I see the users custom presence (The text or emoji what they wrote in)? discord.js v12

slender thistle
#

iterate through activities and find a status with type equal to something like custom or custom_status

fringe axle
#

Hm, okay

earnest phoenix
#
<User>.presence.activities``` use the `find()` method on this
#

Find the custom status type and get the custom emoji if available by accessing the emoji property

fringe axle
#

Okay

feral aspen
#

Hello

#

How can I make a code having a role heirarchy?

#

its like an if statement

#

idk

#

how to do it?

robust arrow
#

can someone help me,
TypeError: Cannot read property 'rowsAsArray' of undefined

this error comes from

Connection.createQuery(`SELECT * FROM money WHERE id = '${message.author.id}'`, (err, rows) => {
pale vessel
#

that statement monkaw

feral aspen
#

Flazepe

pale vessel
#

use role#position

#

it starts with 0, which is the bottom (@everyone)

feral aspen
#

Wdym.

pale vessel
#

you can compare the role position

feral aspen
#

yes

#

if higher than the author or bot, I want it to return

pale vessel
#

compare their highest role (member.roles.highest.position) with the bot's

#

like member.roles.highest.position > guild.me.roles.highest.position

feral aspen
#

wait

pale vessel
#

make sure it's a member

feral aspen
#

Like for example, I want to ban someone, and first, the bot will check something. It will check if I have my role above his role, if I have it below his role, it will NOT execute, it will return

pale vessel
#

i see

#

like if (memberHighestRolePosition >= botHighestRolePosition) return;

#

>= would be equal or higher than

feral aspen
#

I see

#

Does this check if my role is below the target role?

#

or?

pale vessel
#

if it is below, it won't return

#

you can continue your code like normal

#

it's just a check

feral aspen
#

I want that check

pale vessel
#

yes, you need that check

feral aspen
#

I want it to check if the author is above the target role, if not, it should return

pale vessel
#

yeah

feral aspen
#

But I cant seem to figure out the code

feral aspen
#

Take this for example.

#

I have the target for the ban defined as banMember, and I want to check that if my role is lower than his role, it will return

#

is it

pale vessel
#

you don't want to check the bot's role instead?

#

you should do both or the bot's only (if you use roles names)

feral aspen
#

Ill do it for both..

pale vessel
#

okay

#

check for both, use ||

feral aspen
#

I know

#

if(banMember.roles.highest.position > guild.me.roles.highest.position || banMember.roles.highest.position > author.roles.highest.position) return;

#

Like that?

pale vessel
#

use >=

#

if it's equal, it won't bypass that check

feral aspen
#

if(banMember.roles.highest.position >= guild.me.roles.highest.position || banMember.roles.highest.position >= author.roles.highest.position) return;

pale vessel
#

yes

feral aspen
#

๐Ÿ‘

#

Wait

#

I think || shouldnt be in the same brackets?

pale vessel
#

if you want to have different messages, then no

feral aspen
#

Which is better, different messages?

pale vessel
#

different messages for clarity

feral aspen
#

Better..

#

if(banMember.roles.highest.position > guild.me.roles.highest.position) return;

if(banMember.roles.highest.position > author.roles.highest.position) return;

#

Like that?

#

Last check

pale vessel
#

well you can combine them if you're just going to return

#

but yes

#

i'm assuming you will have different text for both

feral aspen
#

Nah

pale vessel
#

oh, combine them then

feral aspen
#

Ill make it send same embed! ๐Ÿ˜‚

pale vessel
#

lmao

#

my man

feral aspen
#

is author.roles.highest.position a thing?

pale vessel
#

nah, author is a user

#

if you're grabbing from message, it's message.member

feral aspen
#

Cause at, ```if(banMember.roles.highest.position > guild.me.roles.highest.position) return;

if(banMember.roles.highest.position > author.roles.highest.position) return;``` I wrote it like that

#

I check this first, if(banMember.roles.highest.position >= guild.me.roles.highest.position) return;

#

I check this second, if(banMember.roles.highest.position >= author.roles.highest.position) return;

pale vessel
#

>= and combine them

feral aspen
#

Yes.

#

I forgot..

pale vessel
#

since you're going to send the same embed

feral aspen
#

The first one is correct right?

pale vessel
#

yeah

feral aspen
#

banMember.roles.highest.position > guild.me.roles.highest.position

pale vessel
#

>= for both

feral aspen
#

yes.

#

Btw

#

Is the second correct?

pale vessel
#

yes

feral aspen
#

author.roles?

#

Or message.member.roles?

pale vessel
#

author needs to be a member

#

message.member, yes

feral aspen
#

ok

pale vessel
#

make sure you define guild too

feral aspen
#

if(banMember.roles.highest.position >= message.member.roles.highest.position) return;

pale vessel
#

yep

feral aspen
#

ok

#

why do I need to define guild?

#

isnt guild already defined from discord.js

pale vessel
#

because it's not defined

#

you mean message.guild?

feral aspen
#

make sure you define guild too
@pale vessel there is no guild on my code

#

nbm

#

nvm

#

woops

pale vessel
#

you mean message.guild?
@pale vessel

feral aspen
#

No

#

guild.me.roles.highest.position

pale vessel
#

what did you define it as then?

#

what's guild?

feral aspen
#

not defined yet

pale vessel
#

ah i see

feral aspen
#

it is like

#

if(target > you/bot) return:

#

;

#

the defined target changes depending on where the code location is

#

whether kick or ban

still merlin
#

My bot seems to be returning a 'channel isnt defined' error whenever I try to purge some messages with my purge command, My bot can purge them fine, But the bot only returns a channel isnt defined error, and not a success embed, https://hastebin.com/ukifihifog

faint prism
#

Well

#
await message.channel.messages.fetch({ limit: amount }).then(messages => {
                message.channel.bulkDelete(amount, true).message.channel.send(SuccessfullyDone);
            });
            const SuccessfullyDone = new Discord.MessageEmbed()
#

Not sure you can do this bit true).message.channel idrk tbh

#

Also, you're defining the success embed after you try to reference it. For some reason

#

You should probably put that one two new lines and not try to string them together with a .

#
message.channel.bulkDelete(amount, true);
message.channel.send(SuccessfullyDone);

For example

feral aspen
#

message.author.roles.highest.position

#

highest is not defined

faint prism
#

And move that embed above it

#

@still merlin

pale vessel
#

message.member, author is a user [@feral aspen]

feral aspen
#

@pale vessel

#

It still kicked the user.

#

Same roile, and kicked.

#

*role

#

wait

#

waittt

#

one sec

pale vessel
#

i gotta eat lol

still merlin
#

Now i get a 'send is undefined' trying to do this

 await message.channel.messages.fetch({ limit: amount }).then(messages => {
                message.channel.bulkDelete(amount, true).then(message => {
                    message.channel.send(SuccessfullyDone);
                });

            });```
faint prism
#

check your variable names ||messages != message||

#

@still merlin

still merlin
#

oh, ty

hard kettle
#

is there a way to specify a date and do - Date.now to see how many days, months left until that date?

#

im trying to make a countdown command that'll count down till new year

opal plank
#

Hmmm

quartz kindle
#

new Date(date info here)

hard kettle
#

thanks tim

#

ill try that

glass steeple
#
    channel = bot.get_channel(72246xxxxxxxxx)
    await channel.send("Hey!!")

schedule.every().day.at("18:00").do(job)

while 1:
    schedule.run_pending()
    time.sleep(1)```


```RuntimeWarning: coroutine 'job' was never awaited```
#

solution??

quartz kindle
#

it supports several different ways if inputting a specific date

#

check it out online for some examples

hard kettle
#

check it out online for some examples
will do, thanks again

opal plank
#

anyone know a quick way to patch this?

quartz kindle
#

you need to type cast

opal plank
#

fuuuuck

quartz kindle
#

let channel = message.channel as Discord.TextChannel
if(!channel.nsfw)

opal plank
#

thats going to be a pain in my ass down the line

#

ty tim

quartz kindle
#

just dont use ts :^)

opal plank
#

Js too lax for me

steel heath
#

or create your own context with channel, message and author etc.

opal plank
#

more work yet more reliable

#

type casting should work fine

#

cuz i already did a check for both of the other types

steel heath
#

yeah but you'll have to do that for each of your commands

opal plank
#

only 3

#

fortunately

#

i dont use nsfw as often as you'd think

#

though there might be other cases where it might come

quartz kindle
#

you can make a helper function

opal plank
#

wdym?

glass steeple
#
async def job():
    channel = bot.get_channel(72246xxxxxxxxx)
    await channel.send("Hey!!")

schedule.every().day.at("18:00").do(job)

while 1:
    schedule.run_pending()
    time.sleep(1)```


```RuntimeWarning: coroutine 'job' was never awaited```
#

help??

quartz kindle
#

for example

#

something like this lmao ```js
Discord.Structures.extend("message", M => class Message extends M {
get channel() {
switch(super.channel.type) {
case "text": return super.channel as TextChannel
case "dm": return super.channel as DMChannel
}
}
})

opal plank
#

idk why thats even passing tbf

#

ACTUALLY

#

one second

#

i would assume ts would be smart about this

#

i can probably cast it before sending, no?

#

idk if it'll be smart enough to know the only type coming is TextChannel

#

lets try it

#

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

quartz kindle
#

i dont think ts will automatically cast it as TextChannel from that

opal plank
#

this in the index

#

forcing the type to TextChannel before sending it over

quartz kindle
#

you can also try (<TextChannel>message.channel).nsfw

#

idk if thats how it works

#

edited

opal plank
#

hmmmm

#

it at least allows me to

#

lets see

#

those are two patches but i might still wanna dig into this to future proof it

clever lake
modest smelt
#

Hello

#

i have a question

#

how do i use discordpy to send a message in a specific channel?

#

like if someone joins a server, how do i send them a message in the discord server

#

i know how to send them a private message, but not in the actual server so that everyone knows

quartz kindle
#

you need to go through the list of channels the guild has and find one where your bot has permissions to send

modest smelt
#

so how would i do that?

warm marsh
#

Read the docs.

modest smelt
#

which ones?

warm marsh
#

The ones for your library.

modest smelt
#

ok

quartz kindle
#

you can try checking if the guild has a system channel

#

which is the channel you define for default welcome messages and server boosts

#

but if they dont have a system channel, then you need to do what i said before

#

something along the lines of
if member.guild.system_channel
member.guild.system_channel.send(content="hi")

honest perch
#

ok what are the actual benefits of ts

weak rain
#

i m unable to set

#

proper interval

#

can someone help me?

#

i want to set 3minutes

cinder patio
#

The main advantage is that it's a strictly typed superset of JS

faint prism
#

ok what are the actual benefits of ts
@honest perch It's closer to OOP

weak rain
cinder patio
#

that's 3 seconds

honest perch
#

@faint prism ok but what are the benefits of it over just using js

cinder patio
#

You have to multiply by 60 as well

restive furnace
#

3 * 60 * 1000 is 3 secs

faint prism
#

I don't use ts or js, but I've heard great things

cinder patio
#

no, that's 3 minutes

faint prism
#

lol

cinder patio
#

3 * 1000 is 3 seconds

restive furnace
#

i meant 3 mins

weak rain
#

yes its 3

#

@cinder patio

#

3 * 1000 is 3 seconds
@cinder patio ^^

cinder patio
#

Yes, and I told you to multiply by 60 as well

#

to make it 3 minutes

weak rain
#

3 * 60 * 1000

#

this?

#

right

cinder patio
#

yes

weak rain
#

oh ty

placid iron
faint prism
#

3 x 1000 milliseconds = 3000 milliseconds or 3 seconds
3000 milliseconds x 60 = 180,000 milliseconds = 3 minutes

#

Whenever you deal with milliseconds, it might be easier to *1000 to work with seconds

tight plinth
#

is discord.js internal sharding (not the d.js sharding manager) good?

weak rain
#

my bot sends messages after 3min after the command but when it starts sending then it sends after seconds

#

@cinder patio HEY

faint prism
#

Post code

weak rain
#
  
if(message.author.bot) return;
  if(!message.guild) return;
  let prefix = db.get(`prefix_${message.guild.id}`)
  if(prefix === null) prefix = default_prefix
    if (message.mentions.has(client.user.id) && !message.content.includes("@everyone") && !message.content.includes("@here")) {
      let mentionEmbed = new Discord.MessageEmbed()
      .setColor("RANDOM")
      .setAuthor(" ")
      .setDescription(`**My prefix for ${message.guild.name} is [  ${prefix}  ]**
      **Type ${prefix}help for commands of the bot**`);
     message.channel.send(mentionEmbed)
      }
var interval = setInterval (async function (guild) {
    const channel = message.guild.channels.cache.find(channel => channel.topic === "Memes");
    if(!channel) return;
    let data = await random.getMeme()
    channel.send(data)
}, 3 * 60 * 1000); ```
#

see interval one

#
var interval = setInterval (async function (guild) {
    const channel = message.guild.channels.cache.find(channel => channel.topic === "Memes");
    if(!channel) return;
    let data = await random.getMeme()
    channel.send(data)
}, 3 * 60 * 1000); ```
delicate shore
#

What does this error mean

faint prism
#

It's a 500 status code

#

Which means it's the server's fault

delicate shore
#

Which server

sudden geyser
#

discord

delicate shore
#

Then how did autjja banned

weak rain
#

and what about mine?

sudden geyser
#

If the error is 5xx, it's the server's fault. That's all you really need to know.

#

@weak rain I assume it's sending multiple messages in that 3-minute timespan.

weak rain
#

Yes

sudden geyser
#

If that's the case, it's because you're creating a setInterval (do something every X milliseconds) in the message event. Where and when are you clearing the interval?

weak rain
#

what should i do

#

then

sudden geyser
#

To put it simple: when the message event is emitted, you're adding another interval to run every X milliseconds.

#

What is the intended behavior.

#

Do you want it to do something after 3 minutes and only once

weak rain
#

Yes

sudden geyser
#

Consider using setTimeout

#

It's like setInterval but after the first run it stops so it's not repeating.

weak rain
#

sorry but do u have any example code as i m new

faint prism
#

yeah

sudden geyser
#

rename setInterval to setTimeout

faint prism
weak rain
#

isnt that for websites?

#

@faint prism w3 one

faint prism
#

still works the same. JS in node is outside html

#

Check my second link

weak rain
#

@sudden geyser but i think then it will

#

..

cinder patio
#

Don't set an interval / timeout directly inside the message event

weak rain
#

bot is still sending multiple messages

#
    const channel = message.guild.channels.cache.find(channel => channel.topic === "Memes");
    if(!channel) return;
    let data = await random.getMeme()
    channel.send(data)
}, 3 * 60 * 1000); ```
#

@cinder patio

#

@sudden geyser

earnest phoenix
#

My visual studio code is closed

#

My pc too

#

bot is still sending multiple messages
@weak rain mine too sometimes it sends 2 or 3 times the same answer

digital ibex
#

ads be like pog

earnest phoenix
#

@earnest phoenix sir i want

weak rain
#

@earnest phoenix not same

#

generated ones

#

every time new

#

but i only want 1 at a time

earnest phoenix
gritty bolt
#

If I'm running js exec("./core.js"); how can I add my client that I've started to this child process?

weak rain
#

ping? @earnest phoenix

earnest phoenix
#

How can I add to my status in how much servers and how much members the bot is in?

#

@gritty bolt?

gritty bolt
#

ok wait actually nevermind

#

doing this in an entirely separate process won't work

earnest phoenix
#

What?

gritty bolt
#

I was trying to start a seperate process for the key functions of my bot but I don't think thats gonna work well

#

So I'm gonna just turn them into functions instead

#

or actually that might work

#

pretty much what i was trying to do was spawn a child process and take my discord.Client into it with me

#

so if anyone could help me with that it would be great

weak rain
#

@earnest phoenix for servers

vagrant tree
#

hi all, it seems ctx.invoked_with only returns the first arg if its separated by spaces - is there a way to get the full arguments? eg command! abcd efgh i need abcd efgh but only getting abcd ?

opal plank
#

@earnest phoenix wtf is that?

weak rain
#

${client.guilds.cache.size}

earnest phoenix
#

@opal plank which?

weak rain
#

hey erwin @opal plank

opal plank
weak rain
#

my bot is sending memes multiple times not following the interval

#

what should i do

opal plank
#

follow what i told you to yesterday

weak rain
#

@opal plank i want it to be simple

opal plank
#

its code mah dude, as long as it works

#

if it aint working now, fix it

#

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

#

you asked me for help yesterday, i told you how to do it

weak rain
#

i m trying it to do

opal plank
weak rain
#

that was of undefined and all

#

well @opal plank i want to go easy and simple

#

without using a data base

#

as it will be better

#

i think so

opal plank
#

its the same command dude

#

memes and setInterval, dont needto be big brain to know this is the command you are currently mentioning lol

#

incorrect, you'll lose states if you disconnect your bot

weak rain
#

but

opal plank
#

hence why you should put it in a DB

earnest phoenix
opal plank
#

if you dare say 'i can put it in a JSON' ill legit bonk you irl

weak rain
#

but i only have problem with multiple messages

#

not channels now

opal plank
#

?

#

well yeah, setInterval doesnt end

weak rain
#

doesnt matter

opal plank
#

thats why i told you to set ONE setInterval() and everytime it runs, it sends messages onto the channels that are subscribed to your memes

weak rain
#

see

#

i m unable to get u

opal plank
#
//index
let channels = Map():
setInterval(() => {
for(let c of channels) {
client.channels_cache.get(c).send(meme);
}
})

//subscribe.js
channels.add(channel.id);
#

there, done

#

purposefully wrong so you have to work on it

#

but thats the framework

#

when someone subscribes? add the channel. Unsubscribe? remove it

weak rain
#

see but if u set topic it will auto sub

opal plank
#

simple as that

quartz kindle
#

then loop over ALL channels and read their topics

opal plank
#

prob bad design tbh

#

^^

#

rather than channels, loop via guilds cache then

weak rain
#

i just want to set that it does not send multiple messages

#

nothing else

opal plank
#

then why set an interval?

#

you using the wrong method if you only want it once

quartz kindle
#
for(let channel of client.channels.cache.values()) {
    if(channel.type === "text" && channel.topic === "meme") channel.send(meme)
}
weak rain
#

can u help me with that? @opal plank

opal plank
#

i cant spoonfeed you dude

weak rain
opal plank
#

i can help as best as i can, but i cant spoonfeed

forest whale
#

can someone tell me a little bit what sharding is or what itยดs use for ?

quartz kindle
#

@weak rain just make a global setInterval when you bot starts up

earnest phoenix
#

sharding is required to log your bot in once it hits 2.5k servers @forest whale

opal plank
#

one global setInterval on index, and then loop it as you wish thru the guilds/channels

quartz kindle
#

@forest whale sharding is splitting the discord connection into multiple connections, where each connection handles an X amount of guilds

#

for example a bot with 3 shards and 3000 guilds will have 1000 guilds per shard/connection

forest whale
#

@forest whale sharding is splitting the discord connection into multiple connections, where each connection handles an X amount of guilds
@quartz kindle aha okey nice isยดt hard to implement it in my code ?

quartz kindle
#

depends, there are many different ways to implement sharding

#

the easiest way is generally known as "internal sharding", which means that all discord connections are managed by a single process

still merlin
#

How do you bulk delete something in d.js? I tried message.channel.bulkDelete(amount, true) but i got a error-

quartz kindle
#

in discord.js you can enable internal sharding using shards:"auto" in your client options

sudden geyser
#

what was the error

still merlin
#

bulkDelete isnt defined

sudden geyser
#

You may want to log the value of message

opal plank
#

its in channel no?

sudden geyser
#

It's saying message.channel is returning undefined.

forest whale
#

depends, there are many different ways to implement sharding
@quartz kindle does it make it sense to implement it early ? even if my bot is under 150 Servers ?

still merlin
#

o, thanks

quartz kindle
#

@forest whale you can experiment with it in order to future proof your bot, but its only recommended once you hit 1500 guilds, and required once you hit 2500

weak rain
#

๐Ÿ˜ 

opal plank
#

dont be mad at us for not spoonfeeding you

quartz kindle
#

@weak rain i literally told you what to do lol

opal plank
#

both me and tim explained how to do it

still merlin
forest whale
#

@forest whale you can experiment with it in order to future proof your bot, but its only recommended once you hit 1500 guilds, and required once you hit 2500
@quartz kindle hmm okey Iยดm just not completly shure how i do that on JDA but thank you very much for the Explanation

quartz kindle
#

look into the JDA docs, there is surely something about sharding

earnest phoenix
#

hello

#

i want

#

i am do 1 bot

#

i want add my bot

honest perch
#

where

earnest phoenix
#

this bot list

weak rain
#

-faq1

#

xD

honest perch
still merlin
sick fable
#

Guys

#

I made a bot

#

Uploaded files

#

And want to host it

#

So, can someone guide me up?

opal plank
#

can
we
try
not
to
Speak
like this?

weak rain
#

o

#

k

sick fable
#

I am sorry

weak rain
#

not

#

e

#

r

#

w

#

i

#

n

honest perch
#

stop spamming

opal plank
weak rain
sick fable
#

Guys please help

honest perch
#

with?

opal plank
#

where are you even hosting it?

sick fable
#

Hosting

weak rain
#

how do i set it to a global interval?

sick fable
#

where are you even hosting it?
@opal plank Dude, I am literally dumb

honest perch
#

what hosting

sick fable
#

Bot hosting

weak rain
#

wtf