#development

1 messages · Page 714 of 1

earnest phoenix
#

oh..

#

it's- not needed to programming?

#

it's not, but it can help you understand documentation more

#

and keywords in languages are english based, e.g if else do while

#

?

stray wasp
#

I'd learn english first cause most docs for programming is in english

earnest phoenix
#

docs means documents?

#

documentation, yes

#

oh

#

ok ok, i'll go back on that site (Discord server) if i eventually could do anything here..

#

for now it's not place for me

vocal phoenix
#

Does anyone know, when calling channel.awaitMessages multiple times on the same channel, whether or not the resolved/rejected promises can interact with each other? I have a command that uses awaitMessages and it seems like the promise rejections from earlier calls to awaitMessages are causing the more recent calls to trigger thier catch.
I looked over TextBasedChannel.js, MessageCollector.js, Collector.js, and Client.js and the only channel-based connection I see is that the MessageCollectors stores the channel id. I would assume the _timeout's in the Collectors that are set in Client shouldn't have any connection between them either. After almost three hours of tinkering and digging through discordjs's code, I'm at a loss. Is there some subtle nuance about how the references, in the execute function of my command object, work that I'm missing here?

#

For reference, the code is at https://github.com/mattacer/ProvablyFairBot/blob/feat/poker-command/commands/Gambling/poker.js. It works properly when the user uses text responses like 1,2 presumably because the awaitMessages promise is resolved so it goes to the then block and can't be rejected anymore to reach any future catch. The problem is when you spam the command using the ok_hand reaction to end the game. The awaitMessages promise continues waiting until the Collector end/timeout is called. So after about 60 seconds the bot starts ending the games almost immediately. The attached picture is what it's doing.

quartz kindle
#

@vocal phoenix pokerGame appears to be a global variable

vocal phoenix
#

I must have accidently deleted the let or forgot it, either way I'm an idiot.

#

@quartz kindle yup that was it. Thanks Tim.

cerulean salmon
#

how to create a txt file on server

#

with bot

#

and also how to read that txt file

earnest phoenix
#

i n

#

w h i c h

#

l a n g u a g e

cerulean salmon
#

js

heavy marsh
#

Need help on a reaction menu - Discord.js
MY CODE

    n.on('collect', r => {
        embed.setTitle(`Paginator help`);
        embed.setDescription(`**•** :arrow_backward: goes to the previous page\n**•** :arrow_forward: goes to the next page\n**•** :wastebasket: deletes the whole message\n**•** :stop_button: stops the interactive pagination session\n**•** :information_source: shows this message`);
        embed.setFooter(`Rhino - Multi Purpose Bot | Page ${page} of ${pages.length}`);
        msg.edit(embed)
        r.remove(r.users.filter(u => u === message.author).first());
    })

When I do this the bots reaction gets removed & not the users reaction...
How to make the users reaction get removed?

#
const info = (reaction, user) => reaction.emoji.name === 'ℹ' && user.id === message.author.id;
const n = msg.createReactionCollector(info);
lament meteor
#

make sure you are declaring message, msg and the other things correct

late hill
#

And perhaps give them a name that clearly lets you and us know what they are

late hill
#

Check what r.users.filter(u => u === message.author).first() actually gives you

heavy marsh
#

it removed the bots reaction when i react and not mine

late hill
#

Your mixed use of message and msg seems right so I'm thinking maybe your filter doesn't actually find the user for some reason

#

If the user filter I put above returns undefined it'll remove the default, which is your bots reaction

#

So maybe that's what's happening?

heavy marsh
#

ammm ok

fallow spire
#

How can i update objects in mongoose?
like when i try to make an setprefix command, that when it already exists that it gets overwritten by the new prefix

snow urchin
#
        if (message.isMentioned(client.user)) {
            let mm = new Discord.RichEmbed().setAuthor(client.user.username, client.user.avatarURL).addField("Hello, my prefix is:", "--").setFooter(client.footer)
            if (message.content.toLowerCase().includes("<@!")) {
                var args = message.content
                    .slice(22)
                    .trim()
                    .split(/ +/g);
                if (!args) {
                    message.channel.send(mm)
                }
            } else {
                var args = message.content
                    .slice(21)
                    .trim()
                    .split(/ +/g);
            }
            if (!args) {
                message.channel.send(mm)
            }
        }

why does this not work?

fallow spire
#

Whats the Error? @snow urchin

#

Also, USE A FRICKIN COMMAND HANDLER

snow urchin
#

... i am using a command handler..

#

and there is no error

earnest phoenix
#

try catch to see if an error occurs, step through every if closure

#

do you not know how to debug?

late hill
#

split() always returns an array

#

Which even if empty, will still be seen as true inside your if statements

#

Meaning that because you invert them, that code will never be executed

snow urchin
#

at the start, before anything else, above let mm .. I put message.channel.send("test"), and that never even executed

late hill
#

You also shouldn't be using var unless you have a specific need that requires it

#

Your code actually makes use of that, possibly unknowingly

fallow spire
#

whats the Difference between let, var, const?

late hill
#
if (message.isMentioned(client.user)) {
    let mm = new Discord.RichEmbed()
        .setAuthor(client.user.username, client.user.avatarURL)
        .addField("Hello, my prefix is:", "--")
        .setFooter(client.footer);
    if (message.content.toLowerCase().includes("<@!")) {
        var args = message.content.slice(22).trim().split(/ +/g);
        if (!args) {
            message.channel.send(mm)
        }
    }
    else {
        var args = message.content.slice(21).trim().split(/ +/g);
    }


    if (!args) {
        message.channel.send(mm)
    }
}```
#

That's your code but slightly re-aranged

cerulean salmon
#

how to read /write in a .db file with bot

late hill
#

I don't think you meant the if and else statements to be ordered that way

#

args shouldn't actually exist in your last if, but it will because you used var

astral meteor
#

How do I get the total members of all the servers my bot is in?

late hill
#

You can go through all guilds and add the member counts but that will include dupes

astral meteor
#

So there isn't a thingy like guild count?

earnest phoenix
#

@astral meteor read the docs

astral meteor
#

client.guilds.size gets the guild count

late hill
#

there's client.users.size but that'll only be cached users

#

So unless you cache them all

astral meteor
#

Ah

#

ty anyway

late hill
#

awaitMessages expects a filter which should be a function

#

You're giving it args.join(" ") which is a string

#

Hence the error string and not a function

earnest phoenix
#

hello, is there some way to make a cooldown for reaction collectors? sometimes it's counted twice instead of once (discord.js)

#

especially in collectors with 2 users

sudden geyser
#

oh god

earnest phoenix
#

you're adding messages to the array, not their contents

#

also

#

your method is async

#

stop using then

#

and mixing sync and async

haughty mica
livid rivet
#

you mean

#

cant you just press enter after every line?

haughty mica
#

Would that affect the message outcome?

livid rivet
#

ahem

#

no

haughty mica
#

Nevermind

#

i got it.

livid rivet
#

lmao GWmemetownOMEGALUL

fallow spire
#

uh

#

My Bot wont turn on anymore.
Error: Something took to long.
(im using glitch.com)

earnest phoenix
#

tip: don't

quartz kindle
#

check if you dont have an infinite loop somewhere

fallow spire
#

Heroku is gay to setup @earnest phoenix

#

@quartz kindle whats a loop, sorry for asking

earnest phoenix
#

i'm aware, i'm suggesting not to use free hosting in general

quartz kindle
#

🤦

#

a loop is a piece of code that repeats

fallow spire
#

makes sense

quartz kindle
#

an infinite loop is a piece of code that repeats indefinitely

#

most programming languages have several types of loops, such as for and while

earnest phoenix
#

Hey any .js developer can do partnership with me please dm me

fallow spire
#

@earnest phoenix Why you want an Partnership?

earnest phoenix
#

@fallow spire I want a partner with whom I can create a bot

#

I could help

#

dms

#

ok its laggin

pearl jasper
#

I cant start up my bot

sudden geyser
#

discord probably being slow or you have something wrong

earnest phoenix
#

discord's api is having a stroke

pearl jasper
#

no

#

idk if its me or the discord is lagging

#

it took me 5 minutes to login

sudden geyser
#

then it's discord having a stroke

pearl jasper
#

i need to run pm2 but bot not logging in Kek

fallow spire
#

@earnest phoenix that API is gay af man

#

WTF

sick cloud
#

discord's api is just having issues quit complaining

heavy marsh
#

How to change the name and avatar of an web-hook on a command - Discord.js

earnest phoenix
#

🇫 🇺 🇨 🇰

fallow spire
#

Please just, just don't @earnest phoenix

eternal mesa
jade thistle
#

how do bots get ping/latency?

earnest phoenix
#

what

jade thistle
#

demonstration:
user: "!ping"
bot: "Pong! 24ms"

earnest phoenix
#

start a timer, send the message, stop the timer, edit the message with elapsed time from the timer

#

How can I see uptime in 2 shards

cerulean salmon
#

i tried to sent the txt to mentioned channel

#

but bot sending the text on current channel

#

🤦

sudden geyser
#

and how are you getting the mentioned channel

green kestrel
#

What's a "cog"? Is this something discord.py specific?

slender thistle
#

Yeah, cog in discord.py is a separate file that may contain several classes of commands and events

green kestrel
#

I've never heard of it in the discord API

#

Ah. Ok

slender thistle
#

It's easy to reload commands and events on the go with cogs

west spoke
#

Yep

green kestrel
#

Why not just call it a module or a plugin, like everyone else?

slender thistle
#

They're actually called extensions

#

You can call them anything really :^)

west spoke
#

Because python doesnt really have a unimport function

#

that would work the same way as a cog

#

If it exists

slender thistle
#

del all the way

west spoke
#

huh

#

ok

slender thistle
#
>>> def yeet(): print('test')
...
>>> yeet()
test
>>> del yeet
>>> yeet
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'yeet' is not defined
green kestrel
#

Can't you undefine a loaded module like you can undef one in perl?

earnest phoenix
#

Hey, discordapp has a api endpoint that goes like this: discordapp.com/api/v6/login, where you send the email and password of a user and get his token in return. i forgot the whole website url, can someone help me out here?

slender thistle
#

"undefine"?

#

Bad

green kestrel
#

Yeah, in perl you can go:

#

use my::mod::name;
Then when you don't want it any more,
no my::mod::name;

#

It removes the module and any local variables in the namespace

slender thistle
#

as far as I understand how it works, del in python does the same

lunar crystal
#
if (message.content === !7Brûle ${user.tag}) {
  const embed = new RichEmbed()
  .setTitle(${user.tag} est en train de brûler ${user.tag})
  .setColor(#df913a)
  .setDescription(${user.tag} est en train de brûler ${user.tag} sur une brochette)
  .setImage('')
}```
#

What's wrong with my code ?

topaz fjord
#

I'm pretty sure a garbage collector should automatically do that @slender thistle

slender thistle
#

Hm?

topaz fjord
#

for deleting variables and stuff

late hill
#

Many things

slender thistle
#

Garbage collector?

#

Something coming from a JS dev or I'm just not too smart?

topaz fjord
slender thistle
#

Does such thing exist in python dogeKek

late hill
#

Yes

green kestrel
#

@lunar crystal for starters missing quotes around the string in 2nd line

#

Same on line 4 and 6

valid frigate
#

sup 🅱ruhgust

vital lark
#

ok

#

did u add it vyso

valid frigate
#

i just set up a new gradle project

#

im thinking about making a bot in jda

vital lark
#

do u have an build.gradle file in the root directory

valid frigate
#

oh yeah i do

#

as well as a settings.gradle

vital lark
#

open the build.gradle and add this to the top of the file:

#
plugins {
    id 'java'
    id 'application'
    id 'com.github.johnrengelman.shadow' version '2.0.4'
}
valid frigate
#

mk

vital lark
#

you should have access to build fatJars

valid frigate
#

i've got the default that intellij made

#
plugins {
    id 'java'
    id 'application'
    id 'com.github.johnrengelman.shadow' version '2.0.4'
}
group 'bruhmoment'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
}
#

tbh

vital lark
#

yea

#

just leave it for now

valid frigate
#

ok

vital lark
#

actually

#

make a Main.java in src/main/java

valid frigate
#

i forgot

#

there were no java classes lul

vital lark
#

and do mainClassName = "Main"

#

u can make packages if u want (i.e: dev/august/libraries/uwu in src/main/java)

valid frigate
#

interesting

#

i still have to learn the syntax

vital lark
#

Gradle is easy to learn when you get used to it

valid frigate
#

it's definitely new to me mmLol

vital lark
#

yes

#

atleast ur not a fucking normie that uses Maven

#

anyway did u make a java class

valid frigate
#

i read about the differences between the two

#

yes

vital lark
#

where is at

#

u need to make a java folder

valid frigate
#

do i

vital lark
#

src/main/java/{stuff} -> java stuff

valid frigate
#

ok made

#

do i just slap everything into src/main/java or leave the main class under src/main

vital lark
#

u slap everything in src/main/java

valid frigate
#

bruh moment

#

yo where's dep

vital lark
#

but if ur making a big project, it's recommended to do this: dev.august.libraries.uwu (or src/main/java/dev/august/libraries/uwu)

#

@valid frigate he's probs sleeping

valid frigate
#

LOL

#

ok yeah

jagged grotto
#

Hi

earnest phoenix
#

Is there a way to list all users in every server the bot is in? Like grab the list and remove any duplicates?
Might seem like a weird question but yea
If there is, there's probably a way to list the user count too so ya

slender thistle
#

You'll need to make sure you cache every user

earnest phoenix
#

Cache, then list, then sort, something along those lines

#

I'll fiddle around later and see what I come up with

slender thistle
#

create an array
Iterate through every guild
iterate through every user
on each iteration if the user ID isn't already in the array, push the ID to it
after all the iterations are done, array.size if it's JS iirc

#

There might be a better way but this is the only one I've come up with k3llyShrug

earnest phoenix
#

I'll try that and post results when I'm home, thanksPFloatingHearts

slender thistle
#

👍

late hill
#

If you're sure all users are cached

#

You'd just use client.users.size?

slender thistle
#

somehow that flew past my head

late hill
lunar crystal
#

@vital lark It was a markdown misstake ^^'

late hill
#

^The issue you have is most likely that you're just creating an embed and not doing anything with it?

languid epoch
#

Hi

fickle anvil
#

hi. Using discord.js I am trying to get user id, name and tag. The ID is working perfectly but username and tag won't show up but always be 'unidentified'

console.error('Der Admin hat was geschrieben. Tag: '+ message.member.tag + " und ID: "+ message.member.id);

I am getting the id, but not the tag. Am I missing something ?

amber fractal
#

.tag is a User property

#

not a Member property

#

use author instead of member

fickle anvil
#

Awesome, works. But why is username and tag listed in the doc? <.<

mossy vine
#

@modern sable ^

fickle anvil
#

!ban @cursive stump x)

mossy vine
#

and an auctions tester too

cursive stump
#

:c

#

:C

#

Y

#

???

fickle anvil
#

Everyone using everyone should get instakickbankill and cut their internet connection off forever. Unless it is an important announcement :3

cursive stump
#

Y

modern sable
#

how about you eat a ban

earnest phoenix
#

bans are not edible

#

would not recommend

unique nimbus
#

Maybe with salt

vernal yoke
olive vapor
#

I want to know the number of servers my bot is on. Help me please. Discord.py

fickle anvil
#

on js it is client.guilds.size

amber fractal
#

@fickle anvil in the docs there is not tag property on members, just on users https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=tag as you can see it doesnt scroll to anything

fickle anvil
#

kay thx

earnest phoenix
#

so im currently using this and console.log(client.users) to grab/list all users in all the servers the bot is in, seems to work, now I just gotta do a size check and print usernames only, but i feel like I'm missing something
any idea?

client.on('ready', () => {
    setInterval (function (){
        var u, user;
        for(u in client.users){
           user = client.users[u];
           if(user instanceof Discord.User) console.log("["+u+"] "+user.username);
        }
    }, 10000);
});
amber fractal
#

Why would you have this on an interval

knotty steeple
#
if(user instanceof Discord.User) console.log("["+u+"] "+user.username);
amber fractal
#

Rip server as soon as it gets a large amount of users

knotty steeple
#

whats instanceof

#

i have never seen that

amber fractal
#

d.jsdoes this for checking your client as well

#

It can be very useful

knotty steeple
#

mmm cba to go read that

#

lmao

amber fractal
#

Then you'll never learn

knotty steeple
#

later™

earnest phoenix
#

its hopefully gonna be changed to a on guild join, rather than interval, so it updates that way, then I can call for it at any time

#

currently working on auto-updating a single message or channel name with the usercount

earnest phoenix
#

well I got the stuff I need, oof

#

took long enough

earnest phoenix
#

How do I make a bot

sudden geyser
last geyser
#

i need help with something developing a website for my bot, am i allowed to ask here?

#

its html and css related

#

nvm

balmy lantern
#

how do you get a name for your link

#

like pokecord

tacit stag
#

@balmy lantern the name for a hyperlink? (Google for www.google.com) it has to be in an embed and you use Name

#

@here in discord.js, how to search for a channel by name, and if it doesnt exist, create a channel.

#

for finding it, i tried javascript guild.channels.find(<myservername>, <channelname>).sendMessage("Hello World!")
but it resulted in an error. i tried looking up the syntax for this, and wasn't able to find the usage

#

UPDATE: I found a way to do it.

balmy lantern
#

Yo

#

What are markdowns on the top.gg website
bc i try you know the bold and that does noting

tacit stag
#

Underscores around the word italicize it

earnest phoenix
#

i feel like I'm being hella dumb, how do I get my bot to DM a certain userID with a message?
say if I did like

DM!send (message)
and had it set to only send to a specific userID, how would I get the command to read and copy-paste the (message) into the userID's DM's?

#

I've got everything down except for the "read my message and send it to the userID" part
I've got a lock on sending a set message to a userID, but not a user-inputted one

#

whats ur lib

#

.js

#

atm

#

ight imma head out

#

its like 4 am and im tired, its killing me xD

#

and .js what

#

d.js, eris?

#

discord.js i think

#

im just hella tired so brain not working

earnest phoenix
#

id if this will work, oop

grizzled jackal
#

That console log, oof

#

Please just stick to one approach 🤣

knotty steeple
#

ok so i want to be able to run 1 node.js script more than once with 1 command

#

how can i do so

#

with my downloader i can make it so that it downloads multiple images at once

valid frigate
#

you mean offload your request to different processes?

#

multithreading in node Thonk

#

well for starters you could look into child_process

stray wasp
#

discord js caches all avatarURL's and usernames? right?

earnest phoenix
#

@stray wasp no, only if the user has sent a message

stray wasp
#

thanks Plemso

rugged hatch
#

Hey my bot says seth take too long to respond after start up, how could I fix it?

sudden geyser
#

could you explain more

earnest phoenix
#

When I added shard, I encountered such a problem; client.channels.get gives error, how can I fix it?

earnest phoenix
#

Is there an event related to creating dispute in webhook in js?

earnest phoenix
#

wat

wheat jolt
#
<body style="background-color: #23272A">
        <nav class="navbar navbar-expand-sm bg-dark navbar-dark">
            <a class="navbar-brand">
              <img src="/images/icon.png" style="width:40px;">
            </a>
            
            <ul class="nav navbar-nav">
              <li class="nav-item">
                <a class="nav-link" href="#">Link 1</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="#">Link 2</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="#">Link 3</a>
              </li>
            </ul>

            <ul class="nav navbar-right">
                <li>
                    <img class="rounded-circle pull-right" src=<%- user.avatarURL %> width="50" height="50">
                </li>
            </ul>
        </nav>
    </body>

http://owo.sh/8ZNoAJV.png
Why the avatar isn't in the right of the navbar?

sick cloud
#

because bootstrap doesn't work like that

wheat jolt
#

what should I do so the avatar goes in the right? mmLol

sick cloud
#

read the docs or google it

wheat jolt
#

I'm "new" to bootstrap

sick cloud
#

there's something related to positioning to do it

#

i haven't used bootstrap in a while because there's better things

wheat jolt
#

Changed pull-right to float-right but it still doesn't work

sick cloud
#

there's something else

#

let me check

#

try ml-auto or mr-auto on the navbar-right ul

#

but changed navbar-right to navbar-nav

wheat jolt
#

same thing with this

#

nvm

cerulean salmon
#

how to dm mentioned member ?

#

👀

earnest phoenix
#
if (user){
user.send('example test')
} else {
message.reply('user ?')
}```
#

@cerulean salmon example

cerulean salmon
#

💗 thank u very much

earnest phoenix
#

np 3291_Cool_Dab

cerulean salmon
#

first()

#

what this function do ?

dapper dome
#

you are getting all mentioned members. and with first you'll get the first entry

cerulean salmon
#

👀 without that function i will ge an array of mentioned user ,right ?

dapper dome
#

otherwise you would get a list or an array (depends on language i guess)

#

yes

cerulean salmon
#

i was getting empty array

#

don't know why

dapper dome
#

eventhough you mentioned someone?

#

what language and api wrapper are you coding in

cerulean salmon
#

js

#

discord.js

dapper dome
#

mh okay i dont use that, so i don't know what the issue can be
but if you catch a message someone mentioned a user in, you shouldnt get an empty array 👀

humble anchor
#

Hello

earnest phoenix
humble anchor
#

How to make music cammand in Android

#

@earnest phoenix

earnest phoenix
#

write code

#

and magic happens

#

best try/catch method? bot seems to be going offline but not showing any errors in console or anywhere

#

to use... try catch

#

@humble anchor "How to make music command in Android" isnt a very good question. Try findind something in the internet and try it, if you run into errors feel free to ask

#
try {
client.login(discordApiKey);
}
catch(err) {
    msg.author.send ("ERROR CATCH TEST - This Works??")
};

is what im using lmao

#

but it doesnt work xD

#

because that's a promise

#
client.login(key).catch((err => {
console.log('Error')
}))
#

😮 🥄

#

ik

#

@earnest phoenix in your code there are multiple errors

#

The message isnt defined there

#

If you make a space between msg.author.send and the message it wont work

#

you have to find the member you want to send it to in your bots cache with client.users.find(m => m.id == 'some id')

#

and send the message to him

#

= finished code (sorry for 🥄)

#
client.login(discordApiKey).catch((err => {
    console.log('Error while login:\n' + err)
}))
#

like i said

#
try {
client.login(discordApiKey);
}
catch(err) {
    client.users.get("USERID").send("Error")
};

so something like this? idk

#

so

#

if you fail to login

#

= ur bot cant login to discord

#

how would you send a message over ur discord client to yourself

#

if your bot cant login

#

ahh okay, send to console.log instead xD
so I've gotta do this for every section that might error out right?

#

if the error blocks you from sending messages log it into console

#

console.log("Hi i am ur console")

#
try {
client.login(discordApiKey);
}
catch(err) {
    console.log("\x1b[31m" + err + "\x1b[0m")
};

so, something like this?

#

no try*

#
client.login(token).catch((err => {
//do something with err variable that contains the error
}))
#

u have to promise output i think

#

ill try that, how would I put this to grab any/all errors my app.js might put out, is there a global variant?

#

no

#

oof

#

gotta do this for each section of the code then I'm guessing

#

if there could be a error and you dont know how to prevent it then yes

#

so,say for instace I've got this

client.on("guildDelete", guild => {
client.users.get("USERID").send("Left a guild: " + guild.name)
})

how would I add the catch here?
would it just be as simple as

client.on("guildDelete", guild => {
client.users.get("227836492880281600").send("Left a guild: " + guild.name)
}).catch((err => {
console.log(err)
}))
#

oh ur bot got approvum gg

#

the catch comes after the send

#

so

#
client.on("guildDelete", guild => {
client.users.get("227836492880281600").send("Left a guild: " + guild.name).catch((err => {
console.log(err)
}))
})
#

im spoonfeeding aigan god dammned

#

sorry ❤ catch just confuses me xD
so for every line, I'd have to add the catch?

client.on("guildDelete", guild => {
client.users.get("USERID").send("Left a guild: " + guild.name).catch((err => {
console.log(err)
}))
    const guildNames = client.guilds.map(g => g.name).join("\n").catch((err => {
console.log(err)
}))
    console.log("\x1b[33m", guildNames, "\x1b[0m").catch((err => {
console.log(err)
}))
})

???

#

🤦🏿

#

no

#

wait

#

only in lines where you expect a error and want to give the user a output

#

you dont have to add a catch to everything

#

for example

#

idk what exactly is causing the error though oof, it just kills the bot at some point and idk when

#

thanks for the help though man, I really appreciate it ❤

#

wait

#

so wait

#

you want to output the guild names to the console and dm you when your bot gets removed from a guild

#

thats easy tho

#

hol on

digital tangle
#

I added a catch to everything and DMed unexpected errors to myself

earnest phoenix
#

absolutely

#

theres a lot more to it tbh, and im tempted to do that ^ alpha

got 212 lines of messy code that idk what could break in xD

#
client.on('guildCreate', guild => {
    dbl.postStats(client.guilds.size)
    console.log('Joined a new guild: ' + guild.name);
    const owner = client.users.find(usr => usr.id == 'urid');
    owner.send(`Joined ${guild.name} || ${guild.id}`)
});
client.on('guildDelete', guild => {
    dbl.postStats(client.guilds.size)
    console.log('Left a guild: ' + guild.name);
    const owner = client.users.find(usr => usr.id == 'urid');
    owner.send(`left ${guild.name} || ${guild.id}`)
});
#

i have those two

#

if you want to get a dm every time ur bot gets removed / added

#

you can go that path

harsh nova
#

wait why do you use string interpolation on owner.send but not on console.log?

#

*completely unrelated to how the code operates im just a doof

earnest phoenix
#

All my bot functions work, but one of them, idk which, is causing the bot to go offline and stop working, but the console is fine and keeps updating

humble anchor
#

How to make bot status remove command?? @earnest phoenix

late hill
#

So if someone spam invites/kicks your bot, you're gonna spam post stats to dbl pepesuspicion

earnest phoenix
#

dont

#

fucking

#

do that

#

@late hill i swear to god

late hill
#

Shouldn't you do something about that

earnest phoenix
#

no

#

ehhe

#

because if someone does

#

set it to dm you instead

#

hippedi hoppedi blacklist gets their property

knotty steeple
#

@earnest phoenix if you dont know where an error is coming from

#

be sure to 100% log every single thing

#

works for me mmLol

earnest phoenix
#

@knotty steeple yea ima stick a catch on every bit of code lmaooo til I figure out the issue that is

humble anchor
#

@earnest phoenix tell how to make bot status remove command??

earnest phoenix
#

google

humble anchor
#

Google is not telling

#

@earnest phoenix

knotty steeple
#

what does that even mean

late hill
#

Also, from what I've seen guildDelete can fire when a server goes unavailable

earnest phoenix
#

if u type b.removestatus for example it resets presence

knotty steeple
#

oh a command to remove

late hill
#

So literally just discord dying could get you ratelimitted from dbl

knotty steeple
#

playing status

slender thistle
#

@late hill DBL ratelimits are kinda fucky

late hill
#

But wouldn't it be nice to respect them anyway awoo

slender thistle
#

True

astral meteor
#

How do I get the discriminator from an ID?

#

I can only get the mention atm.

slender thistle
#

You can get the ID from mention

earnest phoenix
#

client.users.find(m => m.id == args[0]).discrim

quartz kindle
#

that only works if the user is cached

earnest phoenix
#

idk

#

use client.fetchUser

#

gets from cache if there is one, if there isn't one it does a REST request instead (which is why it's a promise)

slender thistle
#

sad that d.py doesn't do that by default

earnest phoenix
#

i mean it shouldn't

slender thistle
#

k3llyShrug guess it's just me being pissy about having less lines for that kind of stuff

earnest phoenix
#

d.js does it and does a lot of other things for the end user because a lot of d.js users are degenerates

slender thistle
#

Understandable

green kestrel
#

@late hill my fix for spamming DBL is that my updates are on an hourly schedule with the first update being an hour after the bot boots, reconnections don't affect that timer interval

#

That way even if it crashed it wouldn't submit again immediately

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

Do you mean a mention?

#

If so I think you need to do something like <@userid>

#

I'm not 100 percent sure

#

Because I haven't done that in a really long time

slender thistle
#

<@id> or <@!id>

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

We answered

grim aspen
#

bruh

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

snow urchin
#

{ Error: Connection lost: The server closed the connection.
    at Protocol.end (/home/callum/newCMBtest/node_modules/mysql/lib/protocol/tocol.js:112:13)
    at Socket.<anonymous> (/home/callum/newCMBtest/node_modules/mysql/lib/Contion.js:97:28)
    at Socket.<anonymous> (/home/callum/newCMBtest/node_modules/mysql/lib/Contion.js:525:10)
    at Socket.emit (events.js:194:15)
    at endReadableNT (_stream_readable.js:1103:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    --------------------
    at Protocol._enqueue (/home/callum/newCMBtest/node_modules/mysql/lib/protl/Protocol.js:144:48)
    at Protocol.handshake (/home/callum/newCMBtest/node_modules/mysql/lib/prool/Protocol.js:51:23)
    at Connection.connect (/home/callum/newCMBtest/node_modules/mysql/lib/Contion.js:119:18)
    at Timeout._onTimeout (/home/callum/newCMBtest/bot/database.js:18:7)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10) fatal: true, code: 'PROTOCOL_COCTION_LOST' }
module.exports = client => {

  var mysql = require('mysql');
var connection = mysql.createConnection({
  host: 'url hidden',
  port: '7503',
  user: 'root',
  password: 'pass hidden',
  database: 'catmaniabot'
});
let sql = connection;
global.sqlConnection = sql
setTimeout(function(){
  sql.connect(function(err) {
    if ( !err ) {
      console.log("Connected to MySQL");
    } else if ( err ) {
      console.log(err);
    }
  });
},10000)
}

Why is the sql not connecting?

pearl jasper
#

is it possible to make a channel that has time to it?

slender thistle
#

Yup, but coming up with the format is up to you

pearl jasper
#

i did try it but the time keeps bugging

#

i did interval

#

to make it update every 1 minute

slender thistle
#

In which way bugging?

pearl jasper
#

like the numbers are getting crazy changing every second

#

its working fine in the start but after idk how long but lets say 5 minutes the time will go crazy

slender thistle
#

"crazy" is vague to me

#

Some screenshots could help

earnest phoenix
#

client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});

#

Id of undefined

slender thistle
#

client.shards is not defined

earnest phoenix
#

2 shard

slender thistle
peak quail
modern elm
#

anyone know where i would start looking to learn abt sharding my bot?

mossy vine
#

@earnest phoenix id, not Id

earnest phoenix
#

🤦 You are right

opaque eagle
#

What language is your bot written in? @modern elm

modern elm
#

javascript

opaque eagle
#

discord.js, right?

modern elm
#

yeh

opaque eagle
modern elm
#

oh thanks :)

toxic oracle
#

@peak quail that's grafana

#

Oh wait nvm it might not be

#

It looks like a grafana graph though

ocean rampart
#

What does this mean?

quartz kindle
#

it means your quotes are wrong. you have to use the " character, not quotation marks

#

also, next time please make a print screen, that pic took ages to load

mortal mortar
#

dev

#

check my bot :(

untold galleon
#

@ocean rampart wath is your thème of visual studio code ?

mossy vine
#

@untold galleon seems to be default dark

untold galleon
#

a okay thks

mossy vine
#

i personally use https://draculatheme.com for everything

sudden geyser
#

dracula is hot

topaz fjord
#

Material Darker > ***

ocean rampart
#

What does The file name, directory name, or volume label syntax is incorrect. Mean?

valid frigate
#

it means your path is incorrect

#

or you're using malformed syntax

ocean rampart
#

What?

#

Sorry, I’m don’t really know a lot about coding.

valid frigate
#

ah ok so basically it means

#

say you have a path like C:\Users\you\project\config.json

#

that is a path

#

or linux is something like ~/project/config.json

#

so basically make sure your path looks something like the ones above without any characters that would cause that error

#

off of the top of my head, i think adding double slashes would cause that error

ocean rampart
#

Oh okay, thanks.

valid frigate
#

yw

cerulean salmon
#

🤦

#

bot sending the message continuously

#

how to stop it ?

amber fractal
#

you'll need to show more code

green kestrel
vernal yoke
#

that if else bracket is killing my eyes, but theme is dope

late hill
#

You're passing 'good' && lwcmd.search('night') to lwcmd.search()

#

Don't know what exactly you're trying to do, but probably not that

untold galleon
#

@green kestrel i can have your theme please ,

#

or it's visual studio code fot computer ?

#

can help me for develop one command for anti-raid please ?

green kestrel
#

It's a vim theme for *nix

#

Debians default dark scheme

mossy vine
#

isnt it the default vim theme?

green kestrel
#

Yes :)

mossy vine
#

vim gang

green kestrel
#

It's always been fine for me to read, so I didn't change it

scenic kelp
#

The only command I know in vim is :q!

green kestrel
#

Lol

#

:%s/search/replace/g

#

I'm no expert, I have a few commands I know to get by

scenic kelp
#

If I need to edit something on my VPS I just use nano or I use a SFTP extension in VSCode

mossy vine
#

sed also exists in discord

green kestrel
#

Nano is ok I guess

mossy vine
#

s/find in last message/replace

#

doesnt work on mobile so

green kestrel
#

Yeah I found that out by mistake @mossy vine

mossy vine
#

oh cool and some bot just dmd me on that

scenic kelp
#

s/?

mossy vine
#

yeah we found it accidentally like 2 years ago

scenic kelp
#

Yep 2

green kestrel
#

I do that as habit from IRC and was surprised when it edited my last message for me

scenic kelp
#

Ah well you really can't do anything about it

snow urchin
#

is there anyway I can catch all errors that happen when a command is executed with the command handler, just at the command handler, instead of putting a bunch of catches in the command code?

valid frigate
#

for the entire process

#
process
  .on('unhandledRejection', (reason, p) => {
    // handle
  })
  .on('uncaughtException', err => {
    // handle
  });
#

oh for the command handler

#

assuming require().run() just do require().run().catch(e => { //handle here})

#

wait

#

nvm im dumb

grizzled jackal
#

just a try / catch wherever you execute the command lol

late hill
#

If you're not awaiting promises it could still throw from there

#

Right?

valid frigate
#

if you're using djs then maybe

.on('message', m => {
    messageHandler.dosomething(m).catch(e => {
        // handle
        handleError(e);
    })
})
#

obv you wont have messagehandler like above id assume but it would look something like that

tall arrow
#

any good tutorial to writing to objects?

mossy vine
#

@tall arrow what do you mean?

tall arrow
#

let object = {}

#

i wanna write data to that object

#

if its called an object

mossy vine
#

object.property = 'something'

#

or let object = {property: 'something'}

tall arrow
#

and can i write something like
object.property = id[coins]

mossy vine
#

yes

untold galleon
#

help me for develop a command anti-raid on

const Discord = require('discord.js');

module.exports.run = (client, message, args) => {

};
module.export.help = {
    name: 'setAnti-raid'
};
``` and I do not know the code of the entire anti raid ... in my main file it's like that
```js
client.on('message'......
```here
tall arrow
#

damn,I need to try things before asking

#

thanks

mossy vine
#

@untold galleon noone will spoonfeed you

untold galleon
#

I know but I ask for help

earnest phoenix
#

@untold galleon it says module.export

#

When it should be module.exports

untold galleon
#

what ?

grizzled jackal
#

-> Sketch out your command
-> Think of the logical steps you'd have to create in order to get your desired result
-> If you don't know how to do a specific task, google it, if you still can't find what you're looking for you can ask here. Likewise if you need help with figuring out logical steps.

Just don't ask for something in it's entirety, aka how to do my whole command

quartz kindle
#

furthermore, anti-raid is a very complex thing, there are a lot of things to think about. its not something that everyone uses and copy-pastes from each other

lavish shuttle
#

I know but I ask for help
and I do not know the code of the entire anti raid

@untold galleon Saying that you don't know code doesn't mean you're asking for help. You're indeed asking us to spoonfeed you

stray wasp
#

Spoonfeeding is for children up to 7 - 8 months old

earnest phoenix
#

choking hazard

stray wasp
#

Due to you knowing English and a bit of code I believe you have the mental capacity of at least a 9 year old or older. So I'm sorry your too old for spoonfeeding.

earnest phoenix
#

you're

sudden geyser
#

Missing comma

valid frigate
#

that's an apostrophe bruh moment

stray wasp
#

Alright I'm go necklace

sage bobcat
#

One message removed from a suspended account.

quick rain
#

I get error in that line how to fix?

slender thistle
#

Try ().content

quick rain
#

Where I use ().content?

#

Can u show pls @slender thistle

tacit stag
#

How do I add custom emoji to a server using a discord js bot? If I have an image link, how can I add them as emoji (given the bot has perms)?

sudden geyser
#

Are you on stable or master

earnest phoenix
#

How to add a nitro emoji in bot

#

Or script

tacit stag
#

how can i tell @sudden geyser

#

does it change the way it is done?

sudden geyser
#

visit package.json and look for where discord.js is. If you're using master, check out the GuildEmojiRoleStore class. Else, just look at the Guild class for creating emojis.

cunning goblet
#

@earnest phoenix if you uh mean

#

so you can use a nitro emote in other servers

#

then create a server, add the emoji and now you can use it on any server (for your bot)

vocal phoenix
sick cloud
fallow spire
#

help

Error:
(node:15879) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message

Code: ```
const Canvas = require('canvas-constructor');
const Canvas1 = require('canvas');
const Discord = require ('discord.js')

exports.run = async (bot,message,args) => {

    var award1 = args.join(' ')
    if (!award1) return message.reply ('Not inputting a needed parameter and breaking the bot')
    var pic3 = await Canvas1.loadImage('https://api.alexflipnote.dev/achievement?text=' + award1);
    if (award1.toLowerCase().includes('gnomed')) var pic3 = await Canvas1.loadImage("https://i1.sndcdn.com/artworks-000179621054-n5eeg3-t500x500.jpg");
    var w = pic3.naturalWidth;
    var h = pic3.naturalHeight;
    const canvas2 = new Canvas.Canvas(w, h)
        .addImage(pic3, 0, 0)
        .toBuffer()
    const canvas3 = new Discord.MessageAttachment(canvas2, 'card.png')
    message.channel.send(canvas3);
}

module.exports.help = {
name: "achievement",
aliases: ["achie"]
}```

earnest phoenix
#

My bot goes offline randomly, Anyone have a fix for this?

fallow spire
#

Well whats the Error

#

@earnest phoenix Are you on glitch?

earnest phoenix
#

No

fallow spire
#

Ok

#

Have you any Errors in the Console

valid frigate
#

unhandled rejections don't cause your app to exit (yet)

#

but yeah id advise looking through your console

#

or something is emitting sigint/sigkill

earnest phoenix
#

events.js:194
throw err; // Unhandled 'error' event
^

Error [ERR_UNHANDLED_ERROR]: Unhandled error. (ErrorEvent {
target: WebSocket {
_events: [Object: null prototype] {
message: [Function],
open: [Function],
error: [Function],
close: [Function]
},

#

_eventsCount: 4,
_maxListeners: undefined,
readyState: 2,
protocol: '',
_binaryType: 'nodebuffer',
_finalize: [Function: bound finalize] { __ultron: 0 },
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: '',
_closeTimer: null,
_finalized: true,
_closeCode: 1006,
_extensions: {},
_isServer: false,
_receiver: Receiver {
_binaryType: 'nodebuffer',
_extensions: {},
_maxPayload: 0,
_bufferedBytes: 0,
_buffers: [],
_compressed: false,
_payloadLength: 36,
_fragmented: 0,
_masked: false,
_fin: true,
_mask: null,
_opcode: 1,
_totalPayloadLength: 0,
_messageLength: 0,
_fragments: [],
_cleanupCallback: null,
_hadError: false,
_dead: false,
_loop: false,
onmessage: [Function],
onclose: [Function],
onerror: [Function],
onping: [Function],
onpong: [Function],
_state: 0
},
_sender: Sender {
_extensions: {},
_socket: [TLSSocket],
_firstFragment: true,
_compress: false,
_bufferedBytes: 0,
_deflating: false,
_queue: []
},
_socket: TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'gateway.discord.gg',
alpnProtocol: false,

#

authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object: null prototype],
_eventsCount: 7,
connecting: false,
_hadError: false,
_parent: null,
_host: 'gateway.discord.gg',
_readableState: [ReadableState],
readable: false,
_maxListeners: undefined,
_writableState: [WritableState],
writable: false,
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: null,
timeout: 0,
[Symbol(res)]: [TLSWrap],
[Symb

valid frigate
#

judging by the word "websocket"

#

it probably has to do with your internet connection if djs didn't handle the error

sinful lotus
#

404 client.on('error') not found

earnest phoenix
#

Alright

valid frigate
#

wait i forgot clients emit that

#

lmao

#

basically that

earnest phoenix
#

So it’s my internet?

valid frigate
#

no

#

you just need to listen for an error event probably

earnest phoenix
#

K

valid frigate
#

didnt see the whole throw err; // Unhandled 'error' event bruh moment

quick rain
#

@vocal phoenix still not working

#

😞😞

marble juniper
#

very important question

#

why camera and not screenshot

quick rain
#

i take picture with my phone

#

caand do creen with the pc

#

but i dont resolve that problem

#

@marble juniper

marble juniper
#

why not

quick rain
marble juniper
#

have you tried

#

reading the error

quick rain
#

yes but still not fix it

#

@marble juniper

#

some idea for resolve?

marble juniper
#

I don't use phython so I Have no idea @quick rain

quick rain
#

okey thx

#

help 🙂

slender thistle
#

Using bot but putting client

digital tangle
#

@quick rain Indent that second if statement in on_message

indigo geyser
#

@quick rain you didn't add the process command

#

On the on on_message add await bot.process_commands(message)

#

At the top

earnest phoenix
#

its possible to make a code that when someone voted ur bot bot says in a channel who voted?

#

i dont know how to tell that.

astral meteor
#

How do I do an "is bot" field on my userinfo command?

earnest phoenix
#

by adding it

sinful lotus
#

even I dont python I feel like that agua is iindented wrong

marble juniper
#

@astral meteor make another field and then use message.author.bot and put it into that field if you want you can also replace the true or false with your own message

#

I think thats also in the docs idk if you use js but thats how I would do it

astral meteor
#

yeah ofc i use djs xd

marble juniper
#

cuz some use python

#

so I was not sure

astral meteor
#

ahh

marble juniper
#

but I hope that helped you

astral meteor
#

works. thank you :)

marble juniper
#

looks like this

astral meteor
#

Yep

quick rain
#

Still not work if I change to water

quartz kindle
#

pretty sure the last two lines should be one indentation back
also, you're using bot, not client, so client.for_message is wrong

warm marsh
#

When I use "this" within a class it returns the first thing I bound to it.

snow urchin
#

Will doing this work to catch all errors when a command is ran?

            try {
                cmd.run(client, message, args);
            } catch (e) {
                message.channel.send(`**Whoopsies, an error has occured while trying to use this command!**\n**Error:**\`\`\`${e}\`\`\``)
            }
amber fractal
#

No

#

Well

warm marsh
#

That will send a message if the command doesn't exist or doesn't have .run method

amber fractal
#

You'll need to handle errors within commands too

snow urchin
#

What do I need to do, to catch all errors instead of having a bunch of .catch inside the command

amber fractal
#

Uh

#

You dont

warm marsh
#

try catch

modest remnant
#

Any one have music bot spriti python programming language

warm marsh
#

Nvm, Found out why. My bad.

quartz kindle
#

@snow urchin that will work if everything in the run function is sync

#

if you have async code, then all promises must be awaited for it to work

#

including the run function itself, if its an async function

modest remnant
#

I make a music bot

#

And he did not connect in voice channel

#

What I do

#

Any one tell me

#

@quartz kindle

earnest phoenix
#

Did you read the error

#

FFMPEG wasn't found

modest remnant
#

FFMPEG WHAT IS THIS

#

🤔

#

@earnest phoenix

#

@everyone

#

Listen me

earnest phoenix
#

you're annoying

#

and you pinged nobody

glacial mango
#

Can I use something else than YouTube to play music?

earnest phoenix
#

youtube music 🙃

buoyant lake
#

guys, is there any way to embed into discord message?

earnest phoenix
#

you mean send an embed?

buoyant lake
#

yeah

#

like iframe

earnest phoenix
#

no

buoyant lake
#

looking a way to countdown timer that reset every week and embed it into a command in MEE6

earnest phoenix
#

you can't inject anything

#

make your own counter

buoyant lake
#

but embed it like a message 🤔

earnest phoenix
#

and then edit the message every minute

west raptor
#

@glacial mango lavalink supports other hosts such as SoundCloud and Bandcamp

grim aspen
#

are you talking like a cooldown?

buoyant lake
#

i heard it has "tick" resource problem

grim aspen
#

which library?

buoyant lake
#

yes, cooldown or countdown

#

to an event that reset every week

grim aspen
#

or language i mean

glacial mango
#

What's lavalink?

buoyant lake
#

haven't tried myself 🤣

grim aspen
#

@glacial mango

#

a rare tim is here

glacial mango
#

I dont understand anything of that

#

😶

quartz kindle
#

@buoyant lake you cannot have a live updating timer/countdown. you can update it every minute or so, or you can show how much time is left when a person uses the command, but you cant have live updating

buoyant lake
#

thank you for describing it in detail

quartz kindle
#

the absolute limit is update it every second, but that might get you banned from discord

#

the longer you wait between updates, the better

buoyant lake
#

problem is i've seen a server use it

#

a sec

#

6 days 8 hours left 🤔

quartz kindle
#

yes, but its not live updating

#

its the second option i said or you can show how much time is left when a person uses the command

buoyant lake
#

ok sorry, i misunderstood

opal summit
#

What is the ID and the token of a discord webhook ?

buoyant lake
#

so is this the solution, wizyx?

#

by using webhook? 🤔

#

@opal summit

#

i got no knowledge about this part of discord

opal summit
#

no it's another question

quartz kindle
#

@opal summit what are you trying to do?

buoyant lake
#

how do you propose i do this, Tim

#

by hosting my own bot?

quartz kindle
#

@buoyant lake what are you trying to do exactly?

slender thistle
#

Isn't the token of a webhook literally in the webhook URL

#

if we're talking Discord ones

buoyant lake
#

how do i test how bot behave like if i compile it in IDE?

#

like the screnshot that i posted above

#

countdown run in the background and then update it when user run the command

earnest phoenix
#

webhooks are alternatives to sending messages with bots, you can't edit messages or read messages with them from what i'm aware

quartz kindle
#

@buoyant lake are you coding your own bot? if so, what language and library are you using?

buoyant lake
#

i'm not sure, i havent' done programming for a while

#

any recommendation?

quartz kindle
#

do you have experience with any programming language?

buoyant lake
#

or that webhook alternative, is it possibile to use that method instead?

slender thistle
#

For a complete bot, nop

#

Just for sending messages, yup

buoyant lake
#

well i'm comp sci graduate 4 years ago, but i haven't touch programming since 2 years ago

#

🤦

#

just a degree i think now, since the skill is almost gone

#

useless

quartz kindle
#

but are you familiar with any language?

buoyant lake
#

c#, react* and the html,js,css

quartz kindle
#

then its always better to stick with what you're familiar with

#

javascript and c# both have libraries for discord bots

buoyant lake
#

but is it necessary to waste resource to develop bot for this purpose only? 🤔

#

if webhook method is enough to just send the timeleft message

quartz kindle
#

well, you can try

#

you need a webservice that offers countdowns

#

in webhook form

#

and if their webhooks are not compatible with discords, you need to use a middle-man like IFTTT

heavy marsh
#

how to have a premium bot linked with the normal bot?
Can i get some ideas

#

when i say linked i mean by having the same information as the main bot such as commands and db info - discord.js

fallow spire
#

help

Error:
(node:15879) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message

Code: ```
const Canvas = require('canvas-constructor');
const Canvas1 = require('canvas');
const Discord = require ('discord.js')

exports.run = async (bot,message,args) => {

    var award1 = args.join(' ')
    if (!award1) return message.reply ('Not inputting a needed parameter and breaking the bot')
    var pic3 = await Canvas1.loadImage('https://api.alexflipnote.dev/achievement?text=' + award1);
    if (award1.toLowerCase().includes('gnomed')) var pic3 = await Canvas1.loadImage("https://i1.sndcdn.com/artworks-000179621054-n5eeg3-t500x500.jpg");
    var w = pic3.naturalWidth;
    var h = pic3.naturalHeight;
    const canvas2 = new Canvas.Canvas(w, h)
        .addImage(pic3, 0, 0)
        .toBuffer()
    const canvas3 = new Discord.MessageAttachment(canvas2, 'card.png')
    message.channel.send(canvas3);
}

module.exports.help = {
name: "achievement",
aliases: ["achie"]
}```

earnest phoenix
#

the first parameter is reserved for the content

#

the second parameter takes in options/attachment

heavy marsh
#
message.channel.send({ files: [{ attachment: result, name: 'card.png' }] });

@fallow spire

earnest phoenix
#

😮 🥄

earnest phoenix
#

ask yourself first if you need a premium bot

#

possible to make a code like when someone voted ur bot it will show a message

#

??? In.(js)

heavy marsh
#

yep i do

earnest phoenix
#

why

heavy marsh
#

well it would be nice

earnest phoenix
#

@heavy marsh u know?

#

that's not a valid reason

#

you don't need to have a premium bot

heavy marsh
#

nope i down sorry

#

@earnest phoenix

#

but u can find it in the api sections

earnest phoenix
#

??

#

it's bad user experience and it's a pain to link two bots to work together in sync

#

U saying to me?

#

I can find that in dbl api?

heavy marsh
#

hold

earnest phoenix
#

okey

heavy marsh
#

IDK it looks interesting

fallow spire
#

@heavy marsh tyy

heavy marsh
#

np

earnest phoenix
#

okay so I finally managed to get the console to print the error that stops the bot from running

#

buuut

#

im stumped

#
events.js:189
    throw err; // Unhandled 'error' event
    ^

Error [ERR_UNHANDLED_ERROR]: Unhandled error. (ErrorEvent {
  target:
   WebSocket {
     _events:
      [Object: null prototype] {
        message: [Function],
        open: [Function],
        error: [Function],
        close: [Function] },
     _eventsCount: 4,
     _maxListeners: undefined,
     readyState: 2,
     protocol: '',
     _binaryType: 'nodebuffer',
     _closeFrameReceived: false,
     _closeFrameSent: false,
     _closeMessage: '',
     _closeTimer: null,
     _closeCode: 1006,
     _extensions: {},
     _receiver: null,
     _sender: null,
     _socket: null,
     _isServer: false,
     _redirects: 0,
     url: 'wss://gateway.discord.gg/?v=6&encoding=json',
     _req: null },
  type: 'error',
  message:
   'getaddrinfo ENOTFOUND gateway.discord.gg gateway.discord.gg:443',
  error:
   { Error: getaddrinfo ENOTFOUND gateway.discord.gg gateway.discord.gg:443
       at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
     errno: 'ENOTFOUND',
     code: 'ENOTFOUND',
     syscall: 'getaddrinfo',
     hostname: 'gateway.discord.gg',
     host: 'gateway.discord.gg',
     port: 443 } })
    at Client.emit (events.js:187:17)
    at WebSocketConnection.onError (F:\desktop\Dappers Bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:374:17)
    at WebSocket.onError (F:\desktop\Dappers Bot\node_modules\ws\lib\event-target.js:128:16)
    at WebSocket.emit (events.js:198:13)
    at ClientRequest.req.on (F:\desktop\Dappers Bot\node_modules\ws\lib\websocket.js:568:15)
    at ClientRequest.emit (events.js:198:13)
    at TLSSocket.socketErrorListener (_http_client.js:392:9)
    at TLSSocket.emit (events.js:198:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
#

ho boy, wall of text

smoky spire
#

Handle the error event

earnest phoenix
#

but where
nothing on line 189 except for commented out code ;-;

smoky spire
#

Handle it as you would any other client event

#

Doesn't matter where

sudden geyser
#

@smoky spire your internet died

#

listen to the error event also

smoky spire
#

I didn't post the error

earnest phoenix
#

oof, idk why internet died then
gonna have to figure out how to attempt to re-connect after internet loss

quartz kindle
#

@earnest phoenix listen and handle the error event

#
client.on("error", error => {
    // do something with error, like console log it or something
})```
earnest phoenix
#

Ahh oki, I'll try that

junior loom
#

someone with a working musicbot willing to give me the code? I lost my code because i had to reset my PC because of a VIRUS... and now i lost like tons of hours /lines of code... if you want proof dm me i can show you how the bot was..

#

ik its akward to ask....

#

hope i dont get banned for that.

unique nimbus
#

Why didn't you back up the code?

#

or put in on Github

#

in a private repo

earnest phoenix
#

^

junior loom
#

idk i was doing it without thinking..

cunning goblet
#

a working musicbot willing to give me the code?

#

no ones going to spoonfeed ya

quartz kindle
#

even if they did, the code would likely be drastically different from what you had before, and you wouldn't understand half of it

cunning goblet
#

^^

grizzled jackal
#

It sucks but it's best to start anew

#

and make sure to back it up this time

junior loom
#

k

#

ye

quartz kindle
#

ayyy, node 12 finally went LTS

#

and gyp finally supports python 3

cunning goblet
#

YES

dusky marsh
#

finally

tranquil drum
#

or not cause a wrong argument error if I do change it to Class<Enum> if I supply a enum class like SomeEnumType.class

untold galleon
#

@flat pelican can you change my nickname please?

flat pelican
#

for what?

#

what should be the new nick

untold galleon
#

Well technoboy it was before ...

#

just Loïc

flat pelican
#

Done

unique nimbus
#

A discord server can't be DDOS'd however it can be raided, there is bots like altdefender which stops spam and raids

slender thistle
#

Altdentifier

unique nimbus
#

I cant english

amber fractal
#

Imma make altdefender now

#

defends alts

#

thanks

unique nimbus
#

No Problem

summer torrent
#

ty

quartz kindle
#

a discord server cant, but discord itself can lul

earnest phoenix
#

xd

hushed berry
#

Discord servers absolutely can be DOS'd

#

It's just an incredibly nonstandard approach

blissful scaffold
#

Some bots can be DOS'd if you throw enough users/people at it

earnest phoenix
#

or just oof their host lol

blissful scaffold
#

but there is no way to know their ip/host as far as i know, all data goes through discord

earnest phoenix
#

akshcually

blissful scaffold
#

that's why i said as far as i know 😛

earnest phoenix
#

they used to expose the raw ip in a UDP voice connection

#

new exploits are still being found to get a user's ip address

#

Ill brb

#

it was loic aigan right?

#

(((((im joking)))))

#

so im planning to add a thing to my bot where it creates a channel, and updates the channel name periodically with a count.
I get how to make a channel and stuff, but if the channel name changes each time it gets updated, how do I refer to that specific channel each time it needs to update?

#

store the id

#

create channel in server
then find channel ID

#

store, and change via ID?

#

yes

#

the entire channel object is returned to you when you create it

#

so you can use the id property on it

#

ahh perfect, thanks

tight mountain
#

Im still having a problem when I try to do something like setInterval(function(){client.channels.get("630431103051890701").send("test")}, 10000). It says that send is not defined.

#

specifically setInterval(function(){client.channels.get("625117613151879172").send("test")}, 10000); ^ TypeError: Cannot read property 'send' of undefined

#

But, if I add client.channels.forEach((channel, id) => { console.log(`(${channel.type})${channel.name?channel.name:(channel.recipient?channel.recipient.tag:'')}:${channel.id}`) }); to the code, the channel is visible to the bot. I tried taking it out of the setInterval, didnt work, tried different channels/guilds, and that didnt work either

blissful scaffold
#

it says the channel is undefined

tight mountain
#

I know, but the channel is visible to the bot, and I can't figure out why it isnt defined

earnest phoenix
#

maybe try message.channel.send? I had an issue similar, might work idk

#
setInterval(function(){client.channels.get("625117613151879172")message.channel.send("test")},
10000);

no clue if ittl work but

tight mountain
#

it would probably give unexpected identifier because client.channels.get("625117613151879172") replaces message.channel

#

yep ```setInterval(function(){client.channels.get("625117613151879172")message.channel.
send("test")}, 10000);
^^^^^^^

SyntaxError: Unexpected identifier```

vocal phoenix
#

Wait, did you run client.channels.forEach((channel, id) => { console.log(`(${channel.type})${channel.name?channel.name:(channel.recipient?channel.recipient.tag:'')}:${channel.id}`) }); inside the lambda for setInterval? Or did you run it outside?

tight mountain
#

outside

vocal phoenix
#

Same results if inside?

tight mountain
#

Yes

quick rain
#

Can I do that my bot do an announcement for @ashen cloudyone every day at 19:00 for exempel

earnest phoenix
#

@tight mountain
maybe

setInterval(function(){
var Chan = client.channels.get("625117613151879172")
Chan.send("test")},
10000);

idek, i cant remember how I fixed mine ;-;

tight mountain
#

same error

earnest phoenix
#

hmm

#

does it have to be that specific id?

#

or would you be able to check for name instead

#
setInterval(function(){client.channels.get('625117613151879172')channel.send("test")},
10000);

no clue, but this might work, looking into stuff

#

whelp idk, no clue here sorry

#

hopefully someone else can give you a hand

#

I'm just trying to create a voice channel where @ everyone can view its existance, but not access/connect to it. not sure what I'm doing wrong here and i feel like its super simple, code nd error here
https://paste.mod.gg/afidutiben.coffeescript

vocal phoenix
#

const everyone = message.guild.roles.find("@" + "everyone");

#

Find requires a callback function.

sudden geyser
#

therefore pass a function

amber fractal
#

"@" + "everyone" wtf

#

The everyone role is also the the guild id

#

To which I would recommend using get over find as it's faster.

shy turret
#

TypeError: Discord.RichEmbed is not a constructor...

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

shy turret
#

this is legit what I do const embed = new Discord.RichEmbed()

#
      const embed = new Discord.RichEmbed()
        .setAuthor('Ping')
        .setColor("RANDOM")
        .setDescription("My websocket ping is " + Math.round(client.ping) + ".")
      message.channel.send({embed});

one of my cmds

#

doesn't work

#

after i updated to v12

#

v11 was perfect though

#

WAIT WHAT

#

it sent???

#

oh wai, i ran npm i discord.js --f

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

How does one remove the color bit from the embed messages entirely?

shy turret
#

how do you make message embeds?

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

I don’t and it comes up grey

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

No like remove it

sage bobcat
#

One message removed from a suspended account.

shy turret
#

i need to read docs again rip

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

How does Luca do it

#

And mythical

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

How are those made?

shy turret
earnest phoenix
#

Instead of RichEmbed, it’s MessageEmbed?

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

It will produce something like that?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

See how there’s no color bit

#

In that middle message

shy turret
#

you mean const embed = new Discord.MessageEmbed()

earnest phoenix
#

I’m trying to achieve that, Mythical bot has something like that but in embed

shy turret
#

yep just tested

#

const embed = new Discord.MessageEmbed() is for message embeds

#

yay

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

No color bit?

#

@shy turret

shy turret
#

?

earnest phoenix
#

Afk is why I’m asking this weird questions lmao

shy turret
#

I think rich embeds and message embeds are almost the same thing..

#

Is it possible to zip with nodejs?

earnest phoenix
shy turret
#

@earnest phoenix wait r u asking for color in ur embed or not?

earnest phoenix
#

@shy turret I’m asking to completely remove it

#

So it’s just the embed box

#

Looks better imo 🤣