#development

1 messages ยท Page 1131 of 1

shy turret
#

@earnest phoenix here's a simple bot setup you can use ๐Ÿ™‚

#
// Note: I highly recommend using a command handler instead which you can find here: https://discordjs.guide/command-handling/
const prefix = "!"; // Set a variable called "prefix" to "!"
const fs = require('fs'); // It opens up the "fs" module. The "fs" module lets you manage files.
const Discord = require('discord.js'); // "discord.js" is a module (https://discord.js.org/) for Javascript that lets you make Discord bots.
const client = new Discord.Client(); // This makes a "client" which would be the "(bot) user"
client.on('ready', () => { // When the bot turns on,
  console.log('Bot is ready!'); // Sends the message "Bot is ready!" to the console
});
client.on('message', message => { // When there is a new message,
  try { // This checks for any errors
    if (message.content.startsWith(prefix) && message.content !== prefix) { // If the message starts with the prefix and the message is not just the prefix,
      let cmd = message.content.toLowerCase().slice(prefix.length).split(' ')[0]; // This gets the command name. "message.content" is the "message". ".toLowerCase()" makes the message lowercase. ".slice(prefix.length)" removes the prefix from the message. The ".split(' ')" makes the variable into an array which looks something like > ["hello", "this", "is", "part", "of", "the", "command"] < and "[0]" gets the first part of the array. So it would be like getting only "hello" from the array ["hello", "this", "is", "part", "of", "the", "command"].
      if (cmd == "help") { // If the command is "help", (so the message should be "!help")
        message.channel.send("Hi."); // The Discord bot replies back the message "Hi."
      };
    };
  } catch(err) { // If there is any errors, it sets the variable "err" as the error.
    console.log(err); // This sends the error variable.
  };
});
client.login("token here"); // I think you know how to get this. You can get this on "https://discord.com/developers" by creating a new application and making it a bot user.
odd lichen
#

big spam

solemn latch
#

Big spoonfeed

shy turret
#

complete spoonfeed

odd lichen
#

giant spoonfeed

shy turret
#

ikr

solemn latch
shy turret
#

i was bored

odd lichen
solemn latch
#

Still against rules

shy turret
#

(wait it is?)

odd lichen
#

anyways back to my question? Is there a way to check if the bot reacted on the message with โŒ ?

shy turret
#

that's exactly 2048 characters i think

odd lichen
#

there probably is some way

shy turret
sudden geyser
#

Like if the bot was the one who added the reaction when the event was emitted, or who has reacted to it in total

misty sigil
shy turret
#

or make the number very long

solemn latch
shy turret
#

oof

odd lichen
#

two

shy turret
#

i dont even know if that code above works lmao

odd lichen
#

if the bot stops

#

it will reset everything

#

so i want it to be able to check in case bot randomly crashes

sudden geyser
#

I like how the try block won't even catch anything lol

shy turret
#

@odd lichen store them all in an array

#

or something

#

and use a database

odd lichen
#

well i would rather not fill up a database with useless data

#

i mean i could ยฏ_(ใƒ„)_/ยฏ

#

but I dont see a point

shy turret
#

me well you can make the timer continue after...

#

bot restart

#

or something

#

wait i got an idea

odd lichen
#

you cant

shy turret
#

cant you just use the reaction event

odd lichen
#

im doing that ...

shy turret
#

and if the reaction is "โŒ"

solemn latch
#

Youd need partials

shy turret
#

and the message author is your bot

solemn latch
#

For non cached messages

shy turret
#

it deletes the message

odd lichen
#

but if the bot itself didnt react on it

#

i dont want the message to be deleted

#

you can probably check it somehow

shy turret
#

well if the reaction user is your bot (using ids), return;

solemn latch
odd lichen
#

already done

#

Woo

#

i have it

solemn latch
#

Which is likly why your author is null

odd lichen
#

already

#

enabled

solemn latch
#

Message.member may also not be in the partials

shy turret
#

if the reaction user id is "bot id" return;

knotty steeple
#

i mean that is how our bot does reaction roles

solemn latch
#

Correct me if I'm wrong, but fetching the message again would give you the author

#

And all the reactions

odd lichen
#

hm

knotty steeple
#

it should

solemn latch
#

Since you only have the partial structure

jolly wave
#

I need help every of my commands with values are not working

#

In the script

shy turret
#

code?

odd lichen
#

maybe there should be multiple development channels to prevent cross posting xP

jolly wave
#

ok waiy

knotty steeple
#

the java script?

jolly wave
#

wait

shy turret
#

yep js

#

you didnt need to require("discord.js") twice but ok

jolly wave
#

?

#

where do u see that

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

const Collection = require('discord.js');
jolly wave
#

oh

shy turret
#

line 1 and 3

odd lichen
#

just have

#

const { Collection, Client } = require('discord.js')

#

idk

shy turret
#

just use the same variable for it

pure lion
#

Imagine
{ peepee } = require ('pkg1')
{ poopoo } = require('pkg1')

shy turret
#

because Discord.Client() !== require("discord.js")

jolly wave
#

wdym two

odd lichen
#

hm

earnest phoenix
#

hmmm

#

im trying to make a discord bot with python

#

but its hard asf

shy turret
#

@jolly wave you dont use the collection variable anyways

solemn latch
#

generally, you should know the basics of python before making a bot

jolly wave
#

so

earnest phoenix
#

gifbase_192 ๐Ÿ˜”

jolly wave
#

the ram,usercount,and servercount,members command are not working

solemn latch
jolly wave
#

wait

#

first ik why members don't work

solemn latch
#

your a vsc user right?
right click, format document

jolly wave
#

where do i find hat

#

that

jolly wave
#

i can't

knotty steeple
#

holy shit holy shit

solemn latch
#

also, so many vars

knotty steeple
#

that code makes me cry

jolly wave
#

yes

solemn latch
#

dont use var, use let

knotty steeple
#

wtf

jolly wave
#

ok

solemn latch
#

only use var if you have a specific reason

knotty steeple
#

indent properly

solemn latch
#

^ format document button

#

amazing for lazy people

jolly wave
#

i can't find it

knotty steeple
#

use a linter

solemn latch
#

right click

knotty steeple
#

please

solemn latch
#

format document

#

or shift + alt + f

jolly wave
#

wait i found it

#

time to retest

solemn latch
#

format document just makes your formatting correct

#

it doesnt fix code

jolly wave
#

ah

solemn latch
#

imagine, "fix all my bugs" button

#

one day

jolly wave
#

who do format document do then

#

what

solemn latch
#

see how your spacing is all weird

#

and hard to read?

jolly wave
#

no

solemn latch
#

format document normalizes the way you format for you

misty sigil
#

infact, once you have this much else ifs it gets hard to read anyways

jolly wave
#

so none of my commands are fixed

#

nice

solemn latch
pure lion
#

Else if else if else if else if

solemn latch
#

^ thats the next problem

jolly wave
#

yes else if but it still work

#

but not for commands with let

solemn latch
#

you should look into switch cases

pure lion
#

Ever heard of switch case

jolly wave
#

wdym

pure lion
#

It's fast

jolly wave
#

nope

pure lion
#

And clean

solemn latch
#

or even a proper full blown command handler

jolly wave
#

i am not english

misty sigil
#

command handler is better

pure lion
#

Hello not English I am dice

solemn latch
jolly wave
#

ok

restive pebble
#

its always better

jolly wave
#

let me read it

solemn latch
jolly wave
#

oh

solemn latch
#

random pings okeh

jolly wave
#

Woo

#

i did like in the guide bruh

solemn latch
#

the guide has multiple sections

jolly wave
#

just writted every other comand in else if

solemn latch
#

if you follow the guide, it goes on to tell you if else if else if else is bad

cosmic kiln
#

I having a problem to invite bots in my server by using mobile and many are

solemn latch
#

for any more than a few commands

jolly wave
#

Alone forever

#

your client id

solemn latch
#

thats a problem with discord, not top.gg

jolly wave
#

so i can do it for you

cosmic kiln
#

Many are heading problem like me

jolly wave
#

what is your client id

restive pebble
#

discord is toxic on mobile x)

cosmic kiln
#

yap i guess so

solemn latch
#

its specifically oauth2 on the app

pure lion
#

dickord.jsno

solemn latch
#

everything else works fine

cosmic kiln
#

from 1 week i having problem invite bot in server

solemn latch
#

yeah, im sure discord is aware of the issue and working on fixing it

cosmic kiln
#

i asked many mobile users they also have same issues

#

๐Ÿ˜ฉ ๐Ÿ˜ฉ ๐Ÿ˜ฉ

pure lion
opal plank
#

wasnt mobile in testing?

#

also just open in the browser @cosmic kiln

jolly wave
#

i still need help

opal plank
#

in-app mobile auth was in testing iirc

solemn latch
#

fix the issues in your code first

#

๐Ÿค”

jolly wave
#

there is none

cosmic kiln
#

From one week I want to contact them but they are not give me reply

opal plank
solemn latch
#

didnt we list like 4 things

cosmic kiln
#

๐Ÿ˜ญ ๐Ÿ˜ญ ๐Ÿ˜ญ

jolly wave
#

...

opal plank
#

@cosmic kiln 14-27 days is the avarage response for tickets

cosmic kiln
#

Now this is frustrating me I can't invite bot I created new server for my friend

opal plank
#

you CAN invite

#

open in brower

#

-.-

jolly wave
#

you can't invite what

solemn latch
#

discord mobile app doesnt let you use oauth2

opal plank
#

so?

#

use browser

solemn latch
#

even tho if you open a link on your browser it opens your discord app

jolly wave
#

@cosmic kiln dm me your client id on the bot app i'll create the link

cosmic kiln
#

use browser
@opal plank I used but it is still not working

jolly wave
#

e

solemn latch
#

he is not making a bot @jolly wave

opal plank
cosmic kiln
#

@jolly wave ok

opal plank
#

:/

#

it does work dude

solemn latch
#

he is trying to invite a bot that exists

jolly wave
#

oooooh

opal plank
#

it works fine ON APP and on BROWSER

#

if you cant use it on the app, use the browser

jolly wave
#

which bot are you trying to invite @cosmic kiln

opal plank
#

if that still doesnt work, load the browser in Desktop mode

jolly wave
#

"what is desktop mode"

#

imagine

solemn latch
#

how do you open the app's browser from a link on top.gg ๐Ÿค”

opal plank
#

you copy link

#

you paste on browser

#

proft??

jolly wave
#

time to play Minecraft

solemn latch
#

you can paste links in the app browser?

#

tf

opal plank
#

bro

#

two things

#

you confusion what im saying

#

BROWSER

#

like chrome

#

mozilla

#

opera

solemn latch
#

chrome sends me to the discord app

opal plank
#

not the discord browser

solemn latch
#

any time any discord link is opened

opal plank
#

open in desktop

cosmic kiln
solemn latch
#

i dont think android one chrome has desktop mode

cosmic kiln
#

but again this page

opal plank
solemn latch
#

it was supported a few years back, but not anymore right?

opal plank
#

It dods

solemn latch
#

ANDROID ONE

opal plank
#

wrong

solemn latch
#

not android

opal plank
#

Chrome has it

#

see bottom right corner

solemn latch
#

are you on android? or android one

opal plank
#

its a feature in chrome

#

android

solemn latch
#

diffrent apps

#

lol

opal plank
#

tryitandsee

#

/shru[

#

its a feature from chrome, im confident it has in whatever platform you using

solemn latch
#

android one is a web based os

#

you dont install apps the same way

cosmic kiln
#

but still it's open this page

earnest phoenix
#

so this is the place to get a headache, I've only slept for 5 hours so we'll see how this goes

opal plank
cosmic kiln
misty sigil
#

so this is the place to get a headache, I've only slept for 5 hours so we'll see how this goes
@earnest phoenix yes it is

opal plank
#

bruh

#

okay hoold up

cosmic kiln
#

not like this

opal plank
#

@cosmic kiln First, hold click on the invite link. Then copy link. once you got that, go to CHROME and paste that link in the url bar. Make sure its in desktop site

#

ya'll overcomplicating this

#

its not a big deal

karmic compass
#

How do I check if something happened while trying to fetch API? For example if a user enters an invalid username, how do I check if it is infalid?

solemn latch
#

yeah, my android one phone doesnt support desktop mode, my s10 does

#

so the desktop mode solution will not work for everyone

opal plank
#

doesnt need to be in desktop

#

desktop and non desktop

#

both work just fine

#

the desktop is just to make sure its not redirecting to the app

shy turret
#

^ click chrome

#

not discord

#

when inviting a bot

#

and using andriod

opal plank
#

Thats what ive been saying

#

read chat before suggesting the same thing dude

karmic compass
#

Can anyone help with .catch? I was using it originally but it didnโ€™t work for some reason, it only did the error message no matter what

opal plank
#

huh?

#

what exatcly you trying to catch?

karmic compass
#

An error*

opal plank
#

no shit

karmic compass
#

Lmfao

#

Uh

opal plank
#

you can either do a .catch or a try {} catch{} block

karmic compass
#

It was in a command that tried to dm a user, but I didnโ€™t want the bot shutting down due to perms

opal plank
#

send the code you are trying to catch error

timid latch
#

owo cf all

earnest phoenix
#

@karmic compass send the code in a bin so we can see it

opal plank
#

you got unhandled rejections on strict? zoomeyes

#

bold of you

#

not the WHOLE code

#

just the snippet of what you trying to catch

earnest phoenix
#

Yeah ^

pure lion
#

Yooo teaching my gf to code day one

karmic compass
#
Message.channel.send(โ€œsuccessโ€)
}).catch```
misty sigil
#

you have a gf?

opal plank
#

||so you telling me that another porn bot is being produced @pure lion ?||

earnest phoenix
#

Uhh

opal plank
#

@karmic compass its a method

#

method()

#

not method

#

catch(something)

pure lion
#

you have a gf?
Why yes

karmic compass
#

Yeah

#

I cut that out but itโ€™s .catch(err => { message.reply("fail")})

opal plank
#

erm

#

that wont work tho i dont think

earnest phoenix
#

He's close

#

But I like try catch blocks

opal plank
#

not that

#

the orinigal

pure lion
#

You can't reply to a message

opal plank
#

does dm's have channel?

earnest phoenix
#

How do you send an embed object in a send method

pure lion
#

That's all I'm giving

opal plank
#

i forgot if channel exists on dm's

solemn latch
#

๐Ÿค”

karmic compass
#

There is message.channel.type

#

And โ€œdmโ€ is a value

opal plank
#

oh then ignore me

#

if it exists on dm its fine

karmic compass
#

Ok

opal plank
#

read this to see how catch works

earnest phoenix
#
msg.channel.send( embed: embed{ code of embed} );
#

that doesnt work

#

how can you send an embed like that

knotty steeple
#

wha

opal plank
#

@earnest phoenix you send an object

#

send( {embed: {fields...} })

earnest phoenix
#

thanks

opal plank
shy turret
#

@earnest phoenix are you using discord.js or eris????

earnest phoenix
#

oh yes ofc

#

discordjs

shy turret
#

if it is discord.js...

karmic compass
#

Wait, so if I defined my send message and dm commands in a function, then caught that, would it work?

earnest phoenix
#

i got it already but ty

shy turret
#

you can just use the embed builder

earnest phoenix
#

im stupid

opal plank
#

dont use embed builders

#

waste of code

shy turret
#

new Discord.MessageEmbed()

opal plank
#

bad

earnest phoenix
#

๐Ÿ’ฉ

#

but ty anyways @shy turret

shy turret
#

k

earnest phoenix
#

I GET IT

restive furnace
#

embed builders: ๐Ÿ’ฉ
embed object directly on the message: ๐Ÿ˜Œ

earnest phoenix
#

What I use all the time

opal plank
#
const embed = new Discord.EmbedBuilder();
embed.setImage();
embed.setDescription();

channel.send(embed)

// instead do this, rather than making new variables, calling builders, and adding methods

channel.send({embed: {
image: {
url: someUrl
},
description: ':)' 
}})

misty sigil
#

may i present to you

#

shit i forgot

restive furnace
#

its MessageEkbed

#

mehhh

opal plank
#

same shit

#

its trash

karmic compass
#

I get the catch a little bit, how would I apply it to grabbing API? If it didnโ€™t show โ€œIdโ€, how do I catch that?

restive furnace
#

i used ember builders like 2 mo. ago, thats how irmb

opal plank
#

wdym @karmic compass ?

karmic compass
#

Like

sudden geyser
#

embed builders can be helpful in a lot of case scenarios

#

they're just helpers after all. you don't need any helper really

opal plank
#

nothing that you just cant assign object

karmic compass
#

If I went to grab API for a username, and I wanted to check if it was valid, how do I do so?

opal plank
#

what the builder is doing is the same you'd be without calling the builder and sending a static object

#

@karmic compass how is your user being provideD? with args?

#

or via author?

karmic compass
#

Yes, via args

opal plank
#

so you are trying to do an api call with args

karmic compass
#

Like !verify (ign)

#

Yes

opal plank
#

okay next bit

#

once that catch fails with a rejection, you log ('Falied with '+ arg[0]) for example

#

since you are doing an api request with the argument, thats your input

karmic compass
#

Yeah

opal plank
#

you dont need to retrieve what argument is being error'ed on the rejection, since you know the input (aka, your argument)

karmic compass
#

Yes

opal plank
#

so, you still dont understand?

karmic compass
#

not really

opal plank
#

okay lets do this

karmic compass
#

Okay,

opal plank
#
message.author.send('hi')
#

that errors

#

so now we attach a catch method to it

shy turret
sudden geyser
#

ew

karmic compass
#

So:

opal plank
#
message.author.send('hi').catch((e:any) => { console.log(e) })
shy turret
#

then use { embed: embed.toJSON() }

stiff stream
sudden geyser
#

Two why not just create your own builder

opal plank
#

that would make it so it would LOG the error itself

shy turret
#

i can

sudden geyser
#

You're just adding an unnecessary dependency there.

#

Which takes up more space.

karmic compass
#

Okay so then if I add in another message.channel.send in there to say it failed, it would work?

stiff stream
opal plank
#

you got that bit @karmic compass ?

karmic compass
#

Yes

sudden geyser
#

or just ste-- I mean borrow the helper

shy turret
#

what's "PREFIX"?

solemn latch
#

whats not working

opal plank
#

so there are another way you can do this

stiff stream
#

im typing &help and it isnt sending

opal plank
#

this for example

solemn latch
#

sending what

stiff stream
#

the prefix is &

solemn latch
#

you never send anything in this code

shy turret
#

^

misty sigil
#

give us your full code

opal plank
#
try {
message.channel.send('hi')
} catch {}
misty sigil
#

preferably excluding token

shy turret
#

(dont give your token)

misty sigil
#

but if you wanna send that you're stupif

opal plank
#

this is the same example as the first, there isnt anything being caught

stiff stream
#

i have a help command

opal plank
#

what you can do tho, is tell it what to do with the error

misty sigil
#

oh

#

switch case

stiff stream
#

i have it too

misty sigil
#

nice

shy turret
#

(faster than else ifs at least)

opal plank
#
try {
message.channel.send('hi')
} catch(err:any) {
console.log(err);
}
misty sigil
#

can you send full code

stiff stream
#

i got the command its not sending the message

opal plank
#

this is just showing you how you can handle errors/rejections

misty sigil
#

and not just ss

ancient nymph
opal plank
#

@karmic compass think you can go from there?

karmic compass
#

Probably, Iโ€™ll ping you if I run into anything

opal plank
#

aight

stiff stream
#

and not just ss
@misty sigil i will send everything that are connected to the prefix

misty sigil
#

send everything

stiff stream
misty sigil
#

including help command

#

send it as text pls

stiff stream
#
bot.on('message', message =>{
  if (message.channel.type == "dm") return
  var args = message.content.split(" ").slice(1)
        
  if(!message.content.startsWith(PREFIX)) return
  if(message.author.bot) return;
  
misty sigil
#

everything in the message event

silver dust
#

Error: Cannot find module './config.json'

solemn latch
#

why not just send everything you need to send at once

misty sigil
#

what do you think that means @silver dust

silver dust
#

i tried to fix

#

didnt work

misty sigil
#

config.json doesn't exist in the same directory

stiff stream
#

everything in the message event
@misty sigil 500 lines.

misty sigil
#

hastebin

dense patio
#

<client>.users.fetch(<id>)
@sick cloud so i've updated to v12 but this just returns undefined

solemn latch
#

youve kinda reached the point where command files is beneficial

misty sigil
#

await it @dense patio

dense patio
#

alright

stiff stream
#

so someone know what to do?

misty sigil
#

hastebin

solemn latch
#

youve not given us enough to help

stiff stream
#

wdym?

misty sigil
#

then i can see the code

dense patio
#

nice, that worked. thanks a bunch

misty sigil
#

np

#

put the code into a hastebin

#

so we can see it

#

and help you

karmic compass
#

hey uh not erwin

#

you there

stiff stream
#

@misty sigil i will send one command.

misty sigil
#

ok.

opal plank
#

@karmic compass ping me

#

i have all servers muted

stiff stream
opal plank
#

i dont mind pings but i mind DM's, so dont sweat about pinging me

#

oops

#

someone posted token

karmic compass
#

oaky so

stiff stream
#

why its not sending it here?

karmic compass
#

its giving me an error with err:any

opal plank
#

cuz you likely have your token in it @stiff stream

karmic compass
opal plank
#

well, you shouldnt copy my snippet

sinful belfry
#

@stiff stream it had an invite in it

karmic compass
#

oh ok

stiff stream
#

ik.

opal plank
#

cuz its Typescript not javascript

sinful belfry
#

and @gilded plank deletes invites from users without a role

#

you'll need to remove the invite from that code in order to send it

opal plank
#

in Typescript we gotta specify the Type of the variable we are declaring @karmic compass

karmic compass
#

yeah, fixed that

wanton iron
#

hey it must be a recurring question but I'm developing a music bot and at the moment the music doesn't end I must have made a mistake but I don't see what I thought you could help me with.

karmic compass
sinful belfry
#

@wanton iron wdym by 'it doesn't end'?

karmic compass
#

got this error

#

even though i caught ithe error

gleaming glen
#

user's dms are closed

opal plank
#

it DID caught the error

#

remember? its logging the error itself

karmic compass
#

it termed the bot tho

#

yeah

opal plank
#

see that its blue and not red?

karmic compass
#

oh

opal plank
#

when you log an error, thats what it logs

karmic compass
#

but shouldn't it not terminate the proccess?

opal plank
#

if you dont want the error, just void it

gleaming glen
#

you can just ignore that basically

karmic compass
#

how would i void an error?

misty sigil
#

return

opal plank
#

() =>

#

ON nothing => do function

karmic compass
#

this is the coding analogy of picking up the phone then dropping it

wanton iron
#

there is no sound coming out but the music is still considered as being played and it remains stuck in this state, it's often towards the end of the music.

opal plank
#
catch() /*nothing*/ {
//do stuff

}```
misty sigil
#

any errors?

#

any code?

sinful belfry
#

@wanton iron are you using something like ytdl?

#

and are you getting any errors at all?

karmic compass
#

but lets say im doing API right, and im checking for the part "id", and then it isn't there, is there a way to catch that?

wanton iron
sinful belfry
#

ah ok

opal plank
#

you arent doing anything with API misterdepth

karmic compass
#

well not right now

opal plank
#

you are just doing stuff from emssage object

karmic compass
#

but back to the "verification" thing

sinful belfry
#

@wanton iron have you set the 'highWaterMark' option?

karmic compass
#

as this was where i was wanting to go after

opal plank
#

well yeah, i remember you saying that

#

we tgetting ya to understand how to handle rejections first

wanton iron
#

@sinful belfry nope never heard of that option

karmic compass
#

oh ok

opal plank
#

lemme get something more workable one sec

karmic compass
#

alright

#

btw heres my code rn (gives console error but im not logging)

try {
            message.author.send('hi')
        } catch (error) {
            message.reply('a')
            return
sinful belfry
#

@sinful belfry nope never heard of that option
@wanton iron ok can you send the code of where you set the ytdl options please?

karmic compass
#

woah discord thanks for the lit organization

opal plank
#

@karmic compass take a look at this for example

karmic compass
#

hmmm

#

let me pop up something usable

opal plank
#

that should get ya a gist of how handling rejections work

wanton iron
opal plank
#

a .catch() would work similarly

sinful belfry
#

the options that you set is the bit where you've written 'filter: 'audioonly'

#

try adding the highWaterMark and setting the value to 1<<25

karmic compass
#

that's pretty decent, i tried to recreate it here:

#

try {
    theVariable.includes(theVariableIsntAnArray)
} catch {
    console.log('AAAAAAA it isnt working')
}```
#

woops

opal plank
#

you now should have 2 examples of how they work

karmic compass
#

y

#

es

harsh moon
sinful belfry
#

@harsh moon check if rnew is defined

wanton iron
#

@sinful belfry thanks i'll try

harsh moon
#

the let rnew should define it

opal plank
harsh moon
#

or do I have to do const?

sinful belfry
#

nah just check to see if it is definitely defined

#

console.log it or something

harsh moon
#

it should though...

sinful belfry
#

just check to see

harsh moon
#

let me do that

#

one sec

sinful belfry
#

you never know

#

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

sudden geyser
#

are you forgetting to await .createRole

harsh moon
#

await should not be there

karmic compass
sudden geyser
#

why

harsh moon
#

it printed null and the role is not there @sinful belfry

solemn latch
#

oopsies is the best error to get

sinful belfry
#

yup

#

so as Lite said, try awaiting the role creation

solemn latch
#

my libs all dont throw descriptive errors, they just say oopsies

harsh moon
#

ok..

sudden geyser
#

best error is "Oh, no!"

solemn latch
#

"shit happens"

harsh moon
sinful belfry
#

because you're making a request to discord's api, you need to wait for the request to be completed and fufilled to ensure the role has been properly created before you can add it to a user

#

yeah

harsh moon
#

ok

sinful belfry
#

it needs to be in an async block (if it isn't already)

earnest phoenix
#

For example:
Starting money---->$500
After i do work command it plus $50
How to do that?

#

How to do that?

misty sigil
#

database

radiant kraken
#

do you have database?

harsh moon
radiant kraken
#

like mongoDB or SQL

earnest phoenix
#

do you have database?
@radiant kraken what?

sinful belfry
#

@harsh moon yep, make the block it is in async

earnest phoenix
#

Ad im at mobile btw

misty sigil
#

dont do it

solemn latch
#

pretty sure you can also set the created role to something and apply it directly

const newRole = await msg.guildcreateRole...
msg.member.addRole(newRole)
earnest phoenix
#

And*

misty sigil
#

without db

harsh moon
#

???

radiant kraken
#

oh god

#

@earnest phoenix do you know what database is?

sonic lodge
#

async function func_name()

sinful belfry
#

so if it is in a function, put async function functionName for example

misty sigil
#

if not, use quick.db

earnest phoenix
#

@earnest phoenix do you know what database is?
@radiant kraken nope XD

solemn latch
#

its for storing data

sinful belfry
#

@misty sigil not helpful

earnest phoenix
#

Oh

solemn latch
#

even with the bot restarting

misty sigil
#

yea

#

wait i forgot about quick.db

earnest phoenix
#

So i cant do it?

radiant kraken
#

what library?

sonic lodge
#

you can, implement a database

misty sigil
#

you can use quick.db

harsh moon
#

its not a defined function

misty sigil
#

that is easy for beginners

earnest phoenix
#

you can, implement a database
@sonic lodge how?

harsh moon
karmic compass
#

@opal plank i finally got something to work, i made it so if i want to throw an error in console.log i put (name) and it prints "un oh" in console, otherwise it prints whatever i put in the function!

sinful belfry
#

@harsh moon alternatively, you could just put everything after it into the .then()

radiant kraken
#

@sonic lodge how?
@earnest phoenix there are a lot of database to choose from, like SQL, quick.db, MongoDB, etc

harsh moon
#

ok

sonic lodge
#

there's lots of ways to set one up too

misty sigil
#

use something like sql, quick.db (simplest) or mongo

earnest phoenix
#

What is your recommend?

#

Quick.db?

misty sigil
#

if you're starting i'd reccomend quick.db yea

radiant kraken
#

choose the simplest, duh

earnest phoenix
#

Ok

#

So how to do?

sinful belfry
#

choose the simplest, duh
@radiant kraken don't be rude. either help them or don't say anything

earnest phoenix
#

Im not good at this

misty sigil
#

what language

radiant kraken
#

sorry

earnest phoenix
#

How??

pure lion
#

*mongoose noises*

misty sigil
#

what language

earnest phoenix
#

what language
@misty sigil ??

misty sigil
#

what language are you developing in

earnest phoenix
#

English

pure lion
#

Are you js or py or developing a bot in another language for some reason

sudden geyser
#

Gruja what programming language

earnest phoenix
#

Js??

#

Bruh

harsh moon
misty sigil
#

send us some code

earnest phoenix
#

Im become confused

misty sigil
#

and we'll find it out for you

pure lion
#

English
photoblobs

sinful belfry
#

@harsh moon the .then needs to run a function

harsh moon
#

oh

pure lion
#

@harsh moon make it redefine a let or something

sonic lodge
#

what language = what programming language is your bot written in

sinful belfry
#

you you can do something like .then(() => {//put code to run here});

earnest phoenix
#

This might be long?

misty sigil
#

AH

sudden geyser
#

javascript

earnest phoenix
#

Ok

misty sigil
#

no thats

#

no what code do you have now

sonic lodge
#

that was documentation

misty sigil
#

thats literally stolen from the quick.db docs

radiant kraken
#

what library did you use?

earnest phoenix
#

Ohhh

harsh moon
#

how do I define a function in discord.js?

sinful belfry
#

you you can do something like .then(() => {//put code to run here});

harsh moon
#

oh ok

sinful belfry
#

just put the code you want to run inside the curly brackets

#

that is called an arrow function

earnest phoenix
#

Uhh i confused now

sinful belfry
#

and it is run when the rolecreate is complete

misty sigil
#

ok what language are you developing in

#

as in programming language

#

send us code from your bot

solemn latch
#

how do you look at documentation if your unsure what language your bot is in

earnest phoenix
#

Token?

misty sigil
#

no

solemn latch
#

it makes no sense

#

to me

radiant kraken
#

no

sonic lodge
#

where is the code that handles your bot starting

#

what does it look like

harsh moon
misty sigil
#

what is your code

earnest phoenix
#

Im still 15 and don't know about all of these because i never touch laptop or pc

solemn latch
#

you cant do catch on nothing

sonic lodge
#

remove the semicolon right before .catch

solemn latch
#

)
.catch()

misty sigil
#

wai

#

how are you making a bot

harsh moon
#

k

misty sigil
#

but you don't know what you're making it on

earnest phoenix
#

From yt

dusky wing
#

On a phone?

earnest phoenix
#

On a phone?
@dusky wing yes

harsh moon
#

fixed it ๐Ÿ˜

solemn latch
#

whats the title of the youtube video

misty sigil
#

send us a snippet of code.

dusky wing
#

BRUH

earnest phoenix
#

Ok i guess i have to watch it at yt again XD

misty sigil
#

send us a snippet of code

sudden geyser
#

Gruja do you have a good understanding of the language you're writing in

karmic apex
#

can someone gimme the link

#

to put up my bot

solemn latch
#

how many devs does it take to figure out a programming language

karmic apex
#

on web

sudden geyser
#

3

earnest phoenix
#

Hi spech spanish?

solemn latch
radiant kraken
#

what app did you use to code? @earnest phoenix

sinful belfry
#

@earnest phoenix english only in this channel

earnest phoenix
#

aah ok ok sorry

harsh moon
stiff stream
#

can i send someone my code and he will tell me why its not working?

solemn latch
#

we have asked you to send your code

sonic lodge
#

the function has to be async

solemn latch
#

like 5 times

misty sigil
#

send it here

stiff stream
#

const emojies = {

1: '1๏ธโƒฃ',
2: '2๏ธโƒฃ',
3: '3๏ธโƒฃ',
4: '4๏ธโƒฃ',
5: '5๏ธโƒฃ',
6: '6๏ธโƒฃ',
7: '7๏ธโƒฃ',
8: '8๏ธโƒฃ',
9: '9๏ธโƒฃ',
10: '๐Ÿ”Ÿ',

thumbup: '๐Ÿ‘',
thumbdown: '๐Ÿ‘Ž',
cross: 'โŒ',
nought: 'โญ•',
pane: 'โฌ›'

};

const Discord = require('discord.js')

const bot = new Discord.Client;

const token = '';

const PREFIX = "!";

const fetch = require( 'node-fetch' );

const { MessageEmbed } = require('discord.js');

const mongoose = require("mongoose");

const moment = require('moment');

const fs = require('fs');

const { type } = require('os');

bot.on('ready', () =>{
console.log('this bot is online')
setInterval(() => {
bot.user.setActivity(${bot.guilds.cache.size} servers | play help, {type: 'WATCHING'});
}, 60000);

})

bot.on('message', message =>{
if (message.channel.type == "dm") return
var args = message.content.split(" ").slice(1)

if(!message.content.startsWith(PREFIX)) return;
if(message.author.bot) return;

switch (args[0]){

case 'test':
message.channel.send("works great!")
break;

}
})

bot.login(token)

misty sigil
#

aHHH

sudden geyser
#

aandmcpro the error is quite self-explanatory: the async keyword can only be used in an async function

solemn latch
#

put it in hastebin

#

like we asked

stiff stream
#

changed it only for now

const emojies = {

1: '1๏ธโƒฃ',
2: '2๏ธโƒฃ',
3: '3๏ธโƒฃ',
4: '4๏ธโƒฃ',
5: '5๏ธโƒฃ',
6: '6๏ธโƒฃ',
7: '7๏ธโƒฃ',
8: '8๏ธโƒฃ',
9: '9๏ธโƒฃ',
10: '๐Ÿ”Ÿ',

thumbup: '๐Ÿ‘',
thumbdown: '๐Ÿ‘Ž',
cross: 'โŒ',
nought: 'โญ•',
pane: 'โฌ›'

};

const Discord = require('discord.js')

const bot = new Discord.Client;

const token = '';

const PREFIX = "!";

const fetch = require( 'node-fetch' );

const { MessageEmbed } = require('discord.js');

const mongoose = require("mongoose");

const moment = require('moment');

const fs = require('fs');

const { type } = require('os');

bot.on('ready', () =>{
console.log('this bot is online')
setInterval(() => {
bot.user.setActivity(${bot.guilds.cache.size} servers | play help, {type: 'WATCHING'});
}, 60000);

})

bot.on('message', message =>{
if (message.channel.type == "dm") return
var args = message.content.split(" ").slice(1)

if(!message.content.startsWith(PREFIX)) return;
if(message.author.bot) return;

switch (args[0]){

case 'test':
message.channel.send("works great!")
break;

}
})

bot.login(token)
@stiff stream

sinful belfry
#

@harsh moon remove the await

stiff stream
#

changed it only for now

sinful belfry
#

it isn't needed anymore

#

(because you're using the .then)

harsh moon
#

there is no await though ...

misty sigil
#

ahH no pls use ```

radiant kraken
#

i recommend put it using the ```

sonic lodge
#

the error is not coming from the snippet you sent

sinful belfry
#

@harsh moon have you saved your file?

harsh moon
stiff stream
#

  const emojies = {

    1: '1๏ธโƒฃ',
    2: '2๏ธโƒฃ',
    3: '3๏ธโƒฃ',
    4: '4๏ธโƒฃ',
    5: '5๏ธโƒฃ',
    6: '6๏ธโƒฃ',
    7: '7๏ธโƒฃ',
    8: '8๏ธโƒฃ',
    9: '9๏ธโƒฃ',
    10: '๐Ÿ”Ÿ',

    thumbup: '๐Ÿ‘',
    thumbdown: '๐Ÿ‘Ž',
    cross: 'โŒ',
    nought: 'โญ•',
    pane: 'โฌ›'
  };

  const Discord = require('discord.js')

const bot = new Discord.Client;

const token = '';

const PREFIX = "!";

const fetch = require( 'node-fetch' );

const { MessageEmbed } = require('discord.js');


const mongoose = require("mongoose");

const moment = require('moment');


const fs = require('fs');

const { type } = require('os');


bot.on('ready', () =>{
    console.log('this bot is online')
    setInterval(() => {
        bot.user.setActivity(`${bot.guilds.cache.size} servers | play help`, {type: 'WATCHING'});
    }, 60000);
    
    })

 bot.on('message', message =>{
  if (message.channel.type == "dm") return
  var args = message.content.split(" ").slice(1)
        
  if(!message.content.startsWith(PREFIX)) return;
  if(message.author.bot) return;
  


switch (args[0]){

case 'test':
  message.channel.send("works great!")
      break;

}
})


bot.login(token)

@misty sigil

harsh moon
#

yes

stiff stream
#

here you go

solemn latch
#

PLEASE STOP SPAMMING RON

radiant kraken
#

what is the error?

stiff stream
#

sorry

solemn latch
#

hastebin

misty sigil
#

well uh

#

idk

harsh moon
#

@sinful belfry my code is saved there is no await I restarted my bot and it throws that err ๐Ÿ˜

sinful belfry
#

it is probs from somewhere else then

earnest phoenix
#

I watched a video

#

And i super confused

#

Welp i guess i have to buy pc

harsh moon
#

line 199

sinful belfry
#

apply the same things as what i've told you

earnest phoenix
#

Or laptop

harsh moon
#

there is no await...

sinful belfry
#

it is probs from somewhere else then

harsh moon
#

console is snorting some real big stuff rn

sinful belfry
#

check you have the line correct

#

lol

thick gull
#

The console should log the line, no?

harsh moon
#

it is correct

thick gull
#

is the file saved

harsh moon
#

yes

#

I restarted the bot too

earnest phoenix
#

Hello a doubt is that I have this code but when putting the prefix in discord it does not take the command, nothing appears neither in discord as in the console

harsh moon
#

console is high af rn

misty sigil
#

its discord.js 12 right?

earnest phoenix
#

v11

misty sigil
#

oh

thick gull
solemn latch
#

djs v11 is deprecated

earnest phoenix
#

what?

solemn latch
#

its no longer being maintained by the djs developers

#

and will stop working entirely in october

sinful belfry
#

@harsh moon double check your whole code

harsh moon
#

new error

sinful belfry
#

just ctrl + f for await

sinful belfry
#

is the role defined?

harsh moon
#

yes

#

let rnew = msg.guild.roles.find('name', "Admin")

sonic lodge
#

right above that line i see console.log(rnew)

sinful belfry
#

what does the console.log say before it

sonic lodge
#

in the console it reads null

harsh moon
#

mhm

sonic lodge
#

and null is neither a role nor a snowflake

karmic compass
#

@opal plank i found a pretty good way to do the verification, what i did was i had it get the request for the api, and then i checked if(!id) which would say if it were valid or not. i've tested it out, it seems a pretty good way to go right now since i'm not totally getting the hang of .catch

harsh moon
#

it creates a new default role though ๐Ÿ˜

opal plank
#

@karmic compass you pinging the api with the user?

harsh moon
#

seriously console has been smoking pot for the last 2 hours

karmic compass
#

thats my code ^

misty sigil
#

you need to url encode that

opal plank
#

erm

#

not only that

#

ids are number only

#

check for type before spamming the api

karmic compass
#

how would this be done?

harsh moon
#

@sinful belfry it is not working and only creating a basic new role ๐Ÿ˜

sonic lodge
#

put the url inside encodeURI()

opal plank
#

parseInt and typeOf

#

parse the argument

#

then check if its type is number

#

or NaN it

#

should also work

sinful belfry
#

@harsh moon what discord.js version are you using?

harsh moon
#

1.12.2

karmic compass
#

where would i put this in my code? i think i get it put i don't know at which part to put it in

solemn latch
#

1.12.2

#

is so old

sinful belfry
#

@harsh moon ah, because your code looks like v11

opal plank
#

before you send it to the api, you need to narrow down some cases that would be useless to be trying

#

use isNaN() to check if the argument is a number

harsh moon
#

I used v11 but then some kid said that my code was not working because of version

opal plank
#

or do the long way i told you with parseInt + typeOf

harsh moon
#

but then I found out why it was because I was creating the role on the wrong layer

#

@sinful belfry you got any ideas?

sinful belfry
#

so are you on v12 now?

harsh moon
#

yes

sinful belfry
#

ok so either downgrade your discord.js version to v11 (which i wouldnt recommend)

#

or upgrade your code to v12

main badge
#

How do you guys go about your premium commands

sinful belfry
#

this is a great guide

harsh moon
#

it is v12

sinful belfry
#

your code isnt

solemn latch
#

your djs version is v12, your code is v11

sinful belfry
#

^

#

you'll need to update your code to work with v12

harsh moon
#

well how do I update the code?

main badge
faint prism
#

How do you guys go about your premium commands
@main badge I think people use roles in their support server

harsh moon
opal plank
#

theres a guide

#

one sec

sinful belfry
main badge
#

Ahh

sinful belfry
#

it should cover everything you need

harsh moon
#

..

main badge
#

@faint prism thatโ€™s a cool idea

opal plank
#

beat me to it

harsh moon
#

but it does not

#

I already looked at that

karmic compass
#

woudl this work: ```javascript
if(!isNaN(args[0)) {
message.channel.send('This is not a valid name!')
} else {
//other code
}

harsh moon
#

and the old code works fine its the new code

opal plank
#

tryitandsee

#

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

karmic compass
#

thankyouverymuch

opal plank
#

noproblemo

sinful belfry
#

well it doesn't work fine @harsh moon because you're getting errors

harsh moon
#

the new code does not work fine like I said

sinful belfry
#

for example, the client.users.exists('username', 'Bob'); method is not used any more

harsh moon
#

all my old commands 100% functioning

faint prism
#

If NaN on commands args? Why

sinful belfry
#

client.users.cache.some(user => user.username === 'Bob'); it is now this

#

(which is covered in the guide)

opal plank
#

to check type @faint prism

#

isNaN return true or false even on string

harsh moon
#

Never used any of that

sinful belfry
#

so please take a read of it, i promise it will help

faint prism
#

What if it's a mention?

opal plank
#

he is doing minecraft calls

harsh moon
#

it wont though because it has no code examples for creating a role ๐Ÿ˜

opal plank
#

wont work with mentions

faint prism
#

<@ID>

opal plank
#

it HAS to be type

faint prism
#

oh alright

opal plank
#

that wouldnt pass

#

he's specifically looking for ID for calling on minecraft users

faint prism
#

IDK what the command it either. Missing convo context lol

solemn latch
#

the djs user ID doesnt work for other api's

earnest phoenix
karmic compass
#

in order to test the new system anyone have a mc username they'd like to see the program run with?

earnest phoenix
#

Minecraft username???

opal plank
#

cant u try your own?

solemn latch
#

i dont even know my own minecraft username

karmic compass
#

yes but that's boring since i've done it already

solemn latch
#

ngl

opal plank
harsh moon
karmic compass
#

NOOO

#

DONT WHACK

opal plank
#

ErwinMarcos

#

go try it

karmic compass
#

nice name

solemn latch
#

you dont have to find the rnew i dont think

#

createRole will pass the role

opal plank
#

i thought uuid's arent compatible with name

earnest phoenix
#

NauticalJeans84

opal plank
earnest phoenix
#

I hope cracked mc usernames work KEKW

opal plank
#

if you testing for NaN it wont work if you providing a username

harsh moon
#

so I just do addRole()?

sinful belfry
#

@harsh moon to use .find correctly

karmic compass
#

uh

karmic compass
#

it's giving me an error now

solemn latch
#

yeah, itll pass the role

opal plank
#

your var is called uuid, a username isnt a uuid

solemn latch
#

then(rnew) => {}

sinful belfry
#

so .find(x => x.name === "Name of role"); for example

karmic compass
opal plank
#

i assumed the endpoint you touching is uuid only since your var is uuid

sinful belfry
#

@harsh moon but you need to do .roles.cache.find()

#

with d.js v12

earnest phoenix
#

cache

solemn latch
sinful belfry
#

yup, read that honestly

#

it covers everything

solemn latch
#

but still, dont even need find

earnest phoenix
#

they added cache for all collections or only a few?

solemn latch
#

since createRole gives you the new role

#

^ all the managers

harsh moon
#

is there a wait function for discord.js?

solemn latch
#

await

harsh moon
#

but one that I can actually use ๐Ÿ˜

solemn latch
#

why cant you use await?

#

djs uses promises a lot, you should have a firm understanding of promises before using djs

harsh moon
lusty quest
#

read the section in the d.js guide about async / await

karmic compass
#

wait can i just ask a question about async / await

solemn latch
#

sure

karmic compass
#

when using await message.channel.send does that mean it will not execute any code after that until it has done that

lusty quest
#

yes but no

solemn latch
#

await wont execute anything until the promise resolves

dire obsidian
#

commando allready have aawait action

      args: [
        {
          key: 'text',
          prompt: 'What gif would you like to watch?',
          type: 'string',
          validate: text => text.length < 50
        }
      ]
#

no need a async i think

#

well on commando

lusty quest
#

some stuff inside your command needs sometimes to be async

#

like if you fetch stuff

earnest phoenix
#

I made my whole command hamdler async

#

Because I use APIs too much

lusty quest
#

or most Databases return a promise you have to await

dire obsidian
lusty quest
#

if you use then its like awaiting the promise

solemn latch
#

your using then, rather than await. which is another way to handle async

dire obsidian
#

wow is rl easy commando, mabe a good start for the coders

earnest phoenix
#

???

#

English

dire obsidian
#

i hate autocorret

#

ill disable it

earnest phoenix
#

pretty sure auto-correct won't automatically put autocorret

lusty quest
#

i dont use commando didnt know about it when i started. And when i knew it exist my knowledge was large enought to not need it

solemn latch
#

even if using commando, id recommend understanding promises before using djs

earnest phoenix
#

what is the worst way to make a command handler

thick gull
#

one that doesnโ€™t work

lusty quest
#

tbh i dont know how to properly write async stuff when i started to code bots until i got into it more

earnest phoenix
#

The one I hate the most is case-sensitive if statements that don't have .toLowerCase()

solemn latch
#

async is kinda a pain, it feels really confusing at first

earnest phoenix
#

smh

dire obsidian
#

yep

solemn latch
#

then, when you understand it, its super simple

earnest phoenix
#

oh right

dire obsidian
#

run: async(message, args)

earnest phoenix
#

that's why i said smh

dire obsidian
#

smh

earnest phoenix
#

one that doesnโ€™t work
@thick gull that's kinda an awesome answer but there are worse command hamdlers

#

F quote with ping

solemn latch
#

i have seen people load their commands for every alias, which i think is silly

sonic lodge
#

what woudl be worse

#

if else for each command, for each alias

solemn latch
#

^ honestly i feel thats the equivalent but with each file being unique

main oak
#

hi

#

site background

#

I made a gif

karmic compass
#

oh and btw does anyone know a good website hosting service that's free?

solemn latch
#

github pages

main oak
#

but it broke into 6 parts

delicate shore
#

alr

#

so i found a turorial

#

on radio commadn

karmic compass
#

@opal plank you there or should i stop pinging you now