#development

1 messages ยท Page 337 of 1

trim steppe
#

for each bans each mentioned user

#

If you have a way to trigger the bot via a mention, you may want to add a filter for the bot itself

earnest phoenix
#

message.mentions.members.ban("Being a bad person")
message.mentions.members.forEach(member => member.ban());

trim steppe
#

if (message.guild) {
message.mentions.members.filter(member => member.id !== message.client.user.id).forEach(member => member.ban());
} else {
message.reply('You Bigot, you need to be in a guild');
}

#

Check if you're in a guild first

earnest phoenix
#

Ah

trim steppe
#

Or else your bot will crash

earnest phoenix
#

It would have been an uncaught promise

#

Oh

trim steppe
#

If it's not

#

No no no

#

You only need that one line

earnest phoenix
#

?

#

Okay wait

#

So the filter gets the user ID, am I correct?

trim steppe
#

This is the code that does the actual banning

message.mentions.members.forEach(member => member.ban());

However, it will not work outside a guild

earnest phoenix
#

And the bot will crash

#

Ah

#

Understood

trim steppe
#

The filter just ensures it doesn't try to ban itself

earnest phoenix
#

XD

#

That would be bad

trim steppe
#

It can't, but it's better to add it in, because errors will pop up when you try

earnest phoenix
#

Okay

#

And the ID obtaining acts as an ID ban

#

Interesting

trim steppe
#

What ID obtaining?

earnest phoenix
trim steppe
#

That doesn't do anything about banning

earnest phoenix
#

No ik

#

Doesnt it get the user ID?

#

Or am I very very wrong

trim steppe
#

Yes

earnest phoenix
#

๐Ÿคฆ

trim steppe
#

If it is not the client ID, it will be kept on the list of things to ban

earnest phoenix
#

Ahhhh!

#

Alright!

#

This makes sense!

#

Wait

#

Wouldnt you want the client ID on the list to ban?

#

Nvm

#

You mean the bot client ID

#

Derp

#

Well, wow thank you!

trim steppe
#

Sorry about last time

earnest phoenix
#

Lol its fine bro

trim steppe
#

I was really angry at how long it takes for others to understand code, but you've grown better since last time

earnest phoenix
#

Rip and aw thx lol

tawny lava
#

could someone tell me why this always returns undefined?

client.getUser = id => {
        client.rethink.db('best').table('users').get(id).run(client.connection, (err, result) => {
            if(err) return console.error('Error while fetching a user from the database\n' + err);
            return result;
        });
    };
#

both the table and the db exist

quiet bobcat
#

Remove return

#

yeah

#

How do I see how many guilds my bot is connected to?

round solstice
#

Whichib

#

*Which lib

#

@quiet bobcat

quiet bobcat
#

discord.js

round solstice
#

No clue

tawny lava
#

<Client>.guilds.size

quiet bobcat
#

How does it desplay?

#

In console?

tawny lava
#

that returns a number

#

you can console.log it if you want

quiet bobcat
#

So like bot.on('ready', () => { <Client>.guilds.size.console.log });?

#

Oh

#

Im really smart

#

as you can tell

#

So bot.on('ready', () => { bot.guilds.size.console.log });

#

I can try both

#

TypeError: Cannot read property 'log' of undefined???

#

Got it to work

round solstice
#

BREAKTHROUGH ๐Ÿ™‚ ```rb

server = IO.popen('server.exe', 'r+')

bot.command(:update) do |event|
server.puts('givemoney ' + $save[event.user.id.to_s].steamid? + ' ' + $save[event.user.id].money)
event.respond 'Balance updated!'
end```

quiet bobcat
#

?

#

What do you mean?

#

How did you make the code colored?

quiet bobcat
#

?

prime cliff
#

@quiet bobcat Its called markdown maybe you should google discord markdown

#

๐Ÿ˜‰

inner jewel
quiet bobcat
#

Ok

#

Thanks for helping me

uncut slate
#

@tawny lava do yourself a favor and use rethinkdbdash instead of rethinkdb

tawny lava
#

o

#

what exactly is the difference?

uncut slate
#

It's better in alot of aspects, less cluttered. You don't need to pass your connection with each call, you don't need to fuck with cursors

tawny lava
#

aight

#

I'll give it a try

uncut slate
#

defo should

#

I don't know anyone who uses non-dash in prod

cosmic plover
#

meanwhile the java driver hardly works and its last release was years ago

#

kill me ^^;

inner jewel
#

we should write a new one

#

:^)

thorny hinge
#
    sql.get(`SELECT * FROM cases WHERE guildId =${msg.guild.id}`).then(row => {
      if(!row) {
        return;
      } else {
var number = row.number;
      //values cant be returned here
    });
//values can be returned here
}```
Returning `number` says undefined so idk how to get that variable returned where values can be returned ![GWchadThinkeyes](https://cdn.discordapp.com/emojis/366999794117246976.webp?size=128 "GWchadThinkeyes")
vale orbit
#

What are you trying to do with that coding?

earnest phoenix
#

@thorny hinge That is because row.number does not exist

#

row.length will return the amount of rows

thorny hinge
#

@earnest phoenix it does exist Thonk

#

The row name is number lol

earnest phoenix
#

no

#

if you are using SELECT then the returned type is an array

#

not object

quiet bobcat
#

I can see the chat through my bot.... It's weird Thonk

earnest phoenix
#

you want to use var number = row[0].number

#

also, use if (row.length < 1) { instaed of if (!row) {

#

Hi

thorny hinge
#

That wasnt my problem, its just that I cant use the variable in the //values can be returned section GWmythicalFeelsSadMan

#

Because its outside of the sql thingie

earnest phoenix
#

OH

#

I see

#

um

#

You would want to use a promise

#

hold on

restive silo
#

Promisify all the things owoah

earnest phoenix
#

@thorny hinge

#
function getCase() {
    return new Promise((resolve, reject) => {
        sql.get(`SELECT * FROM cases WHERE guildId =${msg.guild.id}`).then(row => {
            if (row.length < 1) return reject(); 
            resolve(row[0].number);
        });
    });
}```
#

Then to use that, use this

#
getCase().then(caseNumber => {
    // use caseNumber
}).catch(() => {
    // could not get case
})```
thorny hinge
#

thanks

earnest phoenix
#

no problem

#

also, you may want to sanatize your database input

#

although it's not user input, it's still good practice

#

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

thorny hinge
#

Alright

earnest phoenix
#

๐Ÿ‘Œ

quiet bobcat
#

Im so happy I got approved! ๐Ÿ‘

#

oops

#

wrong chat haha

uncut slate
#

@earnest phoenix prepared statements

earnest phoenix
#

Yeah, whatever it's called

uncut slate
#

oh wait

#

not your code

#

@thorny hinge use prepared statements

thorny hinge
#

Huh

quiet bobcat
#
const https = require('https');

const postData = JSON.stringify({
    server_count: bot.guilds.size
});

const options = {
    hostname: 'https://discordbots.org',
    path: `/api/bots/${bot.User.id}/stats`,
    method: 'POST',
    headers: {
        'User-Agent': 'DiscordBot (https://moustacheminer.com/) Discord Guild Counter',
        'Content-Type': 'application/json',
        'Content-Length': postData.length,
        Authorization: 'X'
    }
};```
Whats wrong with it? I get the error TypeError: Cannot read property 'id' of undefined.
#

Im using discord.js

scenic crest
#

what line is causing the error

quiet bobcat
#
path: `/api/bots/${bot.User.id}/stats`,```
median lintel
#

capital U on user

quiet bobcat
#

I have that

olive vigil
#

Capitals on ID probably

quiet bobcat
#

I can try

#

This is the problem TypeError: Cannot read property 'ID' of undefined

median lintel
#

ya might wanna do User => user

quiet bobcat
#

again thats not the problem

#

It cant read id

#

has nothing to do with capital letters

scenic crest
#

is your d.js called bot or maybe client

quiet bobcat
#

It is called bot

#

And its set to bot

#

    path: `/api/bots/${bot.User.ID}/stats`,```
median lintel
#

it has everything to do with capital letters

quiet bobcat
#

Oh yeah?

#

What should be capital and what shouldnt?

#

non capital u still the error

#

capital u still the error

#

capital id with capital u error

#

capital id with small u error

#

I have tried everything

#

That has to do with capital

#

Im going to sleep

#

too tired for this shit

#

cya tomorrow

abstract mango
#
    path: `/api/bots/${bot.user.id}/stats`,
``` @quiet bobcat
solemn sparrow
#
 
const api = new dbl({
  token: "not-telling-you"
    id: "365689417052192799"
})

api.postStats("Your bot's server count, MUST be a number, not a string", (err, res) => {
    if(err) {
        console.error(err)
    } else {
        console.log(res)
    }
})
slow swan
#

"Your bot's server count, MUST be a number, not a string" isnt a valid guild count

thorny hinge
#

^^^

solemn sparrow
#

client.guilds.size?

slow swan
#

sure

thorny hinge
#

Yes

solemn sparrow
#

i guess i use that

#

xD

#

rip i didnt think about that

slow swan
#

make sure that actually exists

#

and you are running it when the bot is ready not when the client is constructed

solemn sparrow
#

i do

#

i already use it

#

so i should put it in my ready event?

slow swan
#

i did just say that

solemn sparrow
#

k

slow swan
#

but you should also do it when your guild count changes

solemn sparrow
#

k

#

ty i got it working

#

:/

rose tangle
#

hey infinity, fancy meeting you here

#

how's it going

#

still a scumbag?

steel shoal
#

heyy

#

how can i become a bot dev?

quasi marsh
#

Real answer, learn a coding language like Python or Javascript (or C# if you hate yourself) and learn the respective library

steel shoal
#

i did that already haha

#

nederlands haa

#

zie je pf

#

lmao

quasi marsh
#

Yea but this server is English so lets keep it that way ๐Ÿ˜‰

steel shoal
#

np

quasi marsh
#

Add your bot

#

And wait a few days

steel shoal
#

okey cool

#

thx

rose tangle
#

I hate myself

quasi marsh
#

(Just be sure that your bot doesn't annoy people when it is in this server, like mentioning a lot of people or welcome messages in #general or DM etc. etc.)

earnest phoenix
#

c# is a good lang imho

#

i learned to code in it

#

twas my first language

rose tangle
#

same

earnest phoenix
#

its a very powerful language

rose tangle
#

its great, I love it

earnest phoenix
#

๐Ÿ˜ƒ

quasi marsh
#

I was watching a YouTube tutorial and the difficulty curve really bored me

rose tangle
#

especially net core

earnest phoenix
#

I haven't done anything in c# in so long... i should really get back to it

quasi marsh
#

So I stopped until I had to modify Rhinoceros's music bot and got into Python

#

And I just fell in love

earnest phoenix
#

best way to learn c# imho

rose tangle
#

and proper async

#

I just learned it by making discord bots

earnest phoenix
#

I learned js by making discord bots

quasi marsh
#

swap js with python for me

earnest phoenix
#

and my more advanced c# that I know is from making a bot

#

I prefer js to python anyday, but I've grown up on C style syntax

quasi marsh
#

But everytime I develop new features or fix bugs I learn new stuff which I like

earnest phoenix
#

but I need to learn python because I'm doing machine learning now

quasi marsh
#

Python probably won't be that hard if you come from C#

earnest phoenix
#

I need to be typing less, I hurt my wrist

rose tangle
#

what pisses me off is that now I have to add error feedback to my bot before it gets accepted, and I specifially didn't want it to be spammy

#

tbh idk why I'm still trying kek

quasi marsh
#

Wait, Discord Best Bot practices recommend you handle errors silently

rose tangle
#

of course they do, because I followed them

#

but clearly the people reviewing bots here don't care

quasi marsh
#

wat

#

It's literally a point on the "Best ways to get certified on DBL"

rose tangle
#

clearly Arraying didn't get that memo

#

like if they spent more than 4 seconds mindlessly spamming commands and actually tried using it, who knows, it might actually work

#

but in two applications they failed both times to even get the bot to work

quasi marsh
#

They accepted mine and my setup is pretty complicated

rose tangle
#

even though each command is fully documented

#

maybe I'll add a "use this if you're a discord bots list reviewer" command that walks them through it

quasi marsh
#

Well I'm working on making setup easier for my bot since a lot of people have config issues

earnest phoenix
#

Hey, uh, guys?

slow swan
#

hello yes

earnest phoenix
#

I have a question

#

It seems my permission checking code has malfunctioned

#

So my ban and kick commands can be used by anyone

#

Which is very very bad

slow swan
#

ok

earnest phoenix
#

Im not sure whats wrong >.>

#

It comes up with no errors

#

It just doesnt work

slow swan
#

show code

earnest phoenix
#

Okay

#
Permissionhas(msg) {
        if(!msg.guild) return this.client.isOwner(msg.author);
        return msg.member.Permissionshas('ADMINISTRATOR');
    }```
slow swan
#

are you sure it's running the code

earnest phoenix
#

It should be

#

๐Ÿค”

#

I can try a watchpoint

slow swan
earnest phoenix
#

๐Ÿค”

#

That might be the problem

#

Aw sheet they deprecated it

#

Why do they always make everything more complicated

#

Wait

#

I think i might be able to do somethign with .missing

#

*something

#

@earnest phoenix It's called .hasPermission

#

do you even camelCase

#

No

#

Its not

#

Yes

#

It got deprecated

#

It is

#

d.js?

#

And doesnt work anymore

#

Yes

#

it is definetly still a thing

#

I can confirm

#

working fine for me

#

latest version

#

um

#

wtf

#

why

#

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

#

Idfk

#

OH

#

Wow you need to use .has now

#

Instead of .hasPermissions

#

Thats so stupid

#
Permissionhas(msg) {
        if(!msg.guild) return this.client.isOwner(msg.author);
        return msg.member.has('ADMINISTRATOR');
#

Im pretty sure this would work

#

"Permissionshas" is the function

#

So thats alright

#

I changed the permissionshas to .has

#

Now it should, in theory, be working

#

Okay wait wait

#

Ah ha!

#

I think I know how to create a permissions check system

#

Permissions(msg) {
if message.member.has('ADMINISTRATOR') return this.client.isOwner(message.author)
}else{ this.client.reply('You are not an admin, silly!') }

#

Did I place my {} right?

umbral pelican
#

you were looking at Permissions.hasPermission, not GuildMember.hasPermission

earnest phoenix
#

Yes

#

Wait ma minute

#

*a

#

This code gives admin to the person who says it

#

It has to "else" statement

#

*no

#

How df

#

Okay I fixed it

#

But nwo my bot isnt saying im the owner

#

*now

#

I set my user ID

umbral pelican
#

member.has is not a thing GWlgbtqpFeelsthinkingman

earnest phoenix
#

^

umbral pelican
earnest phoenix
#

Omfg I am

#

Hold on

#
Permissionshas(msg) {
        if(!msg.guild) return this.client.isOwner(msg.author);
        return msg.member.hasPermissions('ADMINISTRATOR');
    }
#

there ya go!

#

๐Ÿ‘

#

Bruh

#

it's hasPermission

#

not Permissions

umbral pelican
#

Permissionshas ๐Ÿ™ˆ

earnest phoenix
#

Its still not saying im the bot owner

#

Thats the name of the function

#

Lmao

umbral pelican
#

your isOwner method is probably fucked then ๐Ÿคท

earnest phoenix
#

๐Ÿคฆ

#

Endmysuffering

#

Okay, so

#
const Commando = require('discord.js-commando');

const client = new Commando.Client({
    owner: '296837294655143937'
});
#

EW

#

commando

#

Yes

#

Know what stfu lol

#

Its useful

#

According to the documentation, it should be working

#
    Permissionshas(msg) {
        if(!msg.guild) return this.client.isOwner(msg.author);
        return msg.member.hasPermission('ADMINISTRATOR');
    }
#

This should work, yes?

#

idk try it

#

Nope

#

Non-admins can still use it

#

Im so confused

#

WAIT

#

Why oh why does this code MAKE THE PERSON AN ADMIN

#

๐Ÿคฆ

#

Wait wait wait

#

No thats .has

#

This only checks permissions

#

Aaaaa

#

How do I make it so if the value is true, it moves to the code

#

return?

#

Nobody is responding

#

๐Ÿ˜

#
return this.client.isOwner(msg.author);
#

Well

vale orbit
#

wat

#

Just make a function or a auth json

#

let owner = config.owner;

#

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

trim steppe
#

solution: don't use commando

earnest phoenix
#

If I dont use commando

#

Then all of my bot commands

#

That I have worked on

#

Are null and void

#

Because they use the register groups command

#

They also use its listing service

#

For the help comnmand

#

*command

#

So basically not using commando would be asking me to start over

#

Im attempting to download sqlite

#

Done

#

Aaaaaaaaaaaaaaaaaaaa

#

Now sqlite isnt working

trim steppe
#

Have you heard of our lord and saviour RethinkDB

earnest phoenix
#

No

#

.>

#

Im so frustrated

#

Idk wtf to do

#

Nothing is working

trim steppe
#

Redoing everything is natural

earnest phoenix
#

WHAT

#

;-;

#

Okay know what yeah

#

Im gonna re-do my entire coding base

#

Everything is messed up

#

Im keeping my old bot folder though

#

Just in case

#

Ah, a fresh start

#

Idk how I would even code without commando

#

I re-installed node

#

Re-installing discord.js

#

Done

#
var bot = new Discord.Client
#

Would this be good for the start?

trim steppe
#

var is es5

#

consider using const

#

Also you forgot () on the end

earnest phoenix
#

Lol aren't they the same?

#

Okay

trim steppe
#

var I believe isn't scoped to within a block

#

Or something strange

earnest phoenix
#

Oh

trim steppe
#

const and let are the future

earnest phoenix
#

Alright, I set up a basic starting mechanism from the docs

#
const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
  console.log('I am ready!');
});

client.on('message', message => {
  if (message.content === 'ping') {
    message.reply('pong');
  }
});
#

I added the login part, I just didnt want you seeing the token

#

Lmao

#

Gosh Idk how I would even code commands without commando

frigid vault
#

๐Ÿ‘€

earnest phoenix
#

I learned how to use just commando, not the root d.js

frigid vault
#

ah

earnest phoenix
#

?

frigid vault
#

nothing

earnest phoenix
#

Okay

frigid vault
#

At first I was just thinking you were looking at Commando's code for reference

#

Then I realized that wasn't the case

earnest phoenix
#

Nope

#

Yep

#

Im gonna copy some of my old code

#

From my bot

#

Done

#

Wait

#

How do you even make commands in d.js

#

๐Ÿค”

#

oh god

#

Yup

#

Thx

#

no problem

earnest phoenix
#

leave it

#

You should also change it to any other Directory if you're using another directory that isn't the DocumentRoot

#

aka any subdirectory

#

change after the slash for the dir?

#

@earnest phoenix ^

#

$config["host"] = "http://" . $_SERVER['HTTP_HOST'] . "/enter directory here" . "/even deeper dir here" . "/";

#

ok

earnest phoenix
#

@earnest phoenix what are you supposed to do to make it not return the contents of the php file again?

earnest phoenix
#

wat

quiet bobcat
#

Can somone help me? I'm trying to make it so it shows how many servers the bot is in but I get this error ``` path: /api/bots/${bot.user.id}/stats,
^

TypeError: Cannot read property 'id' of null```

This is the entire code ```Javascript
const https = require('https');

const postData = JSON.stringify({
server_count: bot.guilds.size
});

const options = {
hostname: 'https://discordbots.org',
path: /api/bots/${bot.user.id}/stats,
method: 'POST',
headers: {
'User-Agent': 'DiscordBot (https://moustacheminer.com/) Discord Guild Counter',
'Content-Type': 'application/json',
'Content-Length': postData.length,
Authorization: 'X'
}
};

earnest phoenix
#

@quiet bobcat That is because there is no user property within bot

#

so you're trying to get id property of undefined

#

which u cant do

quiet bobcat
#

Thaths why I get that error then

earnest phoenix
#

Yes

quiet bobcat
#

It fixed it

#

But now I get this error { Error: getaddrinfo ENOTFOUND https://discordbots.org https://discordbots.org:443 at errnoException (dns.js:53:10) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:95:26) code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'https://discordbots.org', host: 'https://discordbots.org', port: 443 }

earnest phoenix
#

That is not your fault

#

that is DBL

#

blame Tonkku

prime cliff
#

Lol

quiet bobcat
#

lol

earnest phoenix
#

It's all Tonkku's fault

quiet bobcat
#

Alright

tawny lava
#

tonkku!!!!!!!!!!!!!!!1

earnest phoenix
#

@bitter sundial reeeeeeeeeee

quiet bobcat
#

I just want it to desplay how many servers my bot is in ๐Ÿ˜ฆ

bitter sundial
#

ENOTFOUND is not us lol

earnest phoenix
#

um

#

actually ya

quiet bobcat
#

What is it then?

earnest phoenix
#

your host

#

denying connection

#

blocking it

bitter sundial
#

are you getting just the frontpage?

quiet bobcat
#

Im trying to fix so my bot uses your api to desplay guilds and such

bitter sundial
#

what path

quiet bobcat
#

To what?

bitter sundial
#

path to api

earnest phoenix
#

๐Ÿ‘€

quiet bobcat
#

path: `/api/bots/${bot.id}/stats`,

exotic nexus
#

pls

#

DNS servers dont block lookups

#

It's him

#

prob on shitty dns servers or something

earnest phoenix
#

lul

quiet bobcat
#

sure why not

bitter sundial
#

is anyone else having a problem with the api

quiet bobcat
#

Only me I think

earnest phoenix
#

Yes

#

I have

#

same issue

quiet bobcat
#

Really?

earnest phoenix
#

only happens a couple times though

#

yes

#

about once per day

quiet bobcat
#

ok

earnest phoenix
#

but it's random

#

@bitter sundial

honest oyster
#

@everyone Who is willing to teach me how to code bots? Dm me if yes.

#

@everyone GTG to sleep.

wispy jolt
#

did he just

tawny lava
#

lul

honest oyster
#

!help

wispy jolt
#

this is sad

honest oyster
#

/help

#

help

#

;help

#

:help

tawny lava
#

bruh

weak parrot
#

Wtf

earnest phoenix
#

lmfao

#

this is sad

#

he tried

#

or she

#

cant assume

#

:P

weak parrot
#

Yeah

exotic nexus
#

We've long past the point of being able to distinguish a real user and a troll

quiet bobcat
#

haha

weak parrot
#

Idk why people think that others want to help then learn how to code without anything in return

#

I mean fix one command? Sure.

#

But learn how to code it self wtf

exotic nexus
#

Even if you wrote a guide to programming through discord bots they still would just copy and learn nothing

weak parrot
#

Yeah most likely

quiet bobcat
#

What should I change it to?

exotic nexus
quiet bobcat
#

?

agile cove
#

how to add bot

#

im new

languid dragon
#

Hi, welcome to DBL

agile cove
#

Hi

languid dragon
#

You can login with Discord it's a simple click of a button

#

From there you'll get redirected back to the main page of DBL

agile cove
#

why ur name green

languid dragon
#

From there, there will be a button "Add Bot"

#

I'm a certified bot developer :]

agile cove
#

ouhhh

#

btw thanks

languid dragon
#

No problem :]

quiet bobcat
#

Why is my bot not detecting FFMPEG??

#

It was a couple of minutes ago

languid dragon
#

Are you running it off your local machine?
And when it was working, was that machine a VPS?

quiet bobcat
#

Local and no vpn

languid dragon
#

D.js?

quiet bobcat
#

ye

languid dragon
#

Well from my experience with D.js.
I couldn't get Voice to work with windows at all

#

It worked for me on a linux but that's it

quiet bobcat
#

I got it to work

languid dragon
#

Do what you did before ๐Ÿ‘€

quiet bobcat
#

Might be because I did npm update

#

Any way to downgrade?

languid dragon
#

Hmm

#

Have you tried hard updating all your packages?

quiet bobcat
#

No?

#

How do I do that?

languid dragon
#

I know that Node and other packages sometimes don't fully update using just NPM

#

You might need to uh, google that one, sorry.

quiet bobcat
#

It's ok thanks for the help

languid dragon
#

No worries

bitter sundial
#

@quiet bobcat /api/bots/stats only works when POSTing

quiet bobcat
#

Ok, but it cant post because the bot cant connect

#

Uhm.... Uhmmm..... uhhmmm.. node index 'node' is not recognized as an internal or external command, operable program or batch file.

#

what

#

the

#

hell

exotic nexus
#

maybe you should add node then

quiet bobcat
#

I have node.js

exotic nexus
#

obviously not

#

since it's not in the path

#

unless you didn't add it

uncut slate
#

^ looks like you didn't add it to path

#

certain versions are also listed under nodejs you can give that a try if you want

quiet bobcat
#

I'll download the new nodejs

#

First ffmpeg wasnt working and now node doesn't work... Good day for me ๐Ÿ‘

#

Yay, everything works ๐Ÿ˜ƒ

uncut slate
#

PEBCAK

quiet bobcat
#

How do I make a command log errors?

uncut slate
#
try {
  // Running your command
} catch (e) {
  console.log(`o shit ${e.message}`);
}
quiet bobcat
#

lol

#

o shit

exotic nexus
#

You've got to stop asking for everything and learn yourself

steel shoal
#

hello

scenic crest
#

hello

honest bane
#

Does anyone know how to make a bot online if so message me plz

quiet bobcat
#

How do I edit a message my bot sends through my bot?

prime cliff
#

You could have easily found that out by reading docs

quiet bobcat
#

ok

#

I accidentally read the outdated docs ๐Ÿคฆ

prime cliff
#

You are using js right?

quiet bobcat
#

Yeah

prime cliff
quiet bobcat
#

Im already on there

prime cliff
#

So did you find it Thonk

frail lion
#

find what

lethal sun
#

message.edit doesent work for me

quiet bobcat
#

not for me either

lethal sun
#

it sends me an error saying that the bot cannot edit another uusers message

quiet bobcat
#

I get nothing :/

lethal sun
#

hm

quiet bobcat
#

It only posts the original

#

Doesnt edit it :/

lethal sun
#

thonk

quiet bobcat
earnest phoenix
#

time to get to work

#

@serene moon

prime cliff
#

Moose does work Thonk

earnest phoenix
#

im checking if my bot is online or not thank you very much

#

just needed to view profile

quiet bobcat
#

I keep getting this error: TypeError: message.edit is not a function

#

This is the code for it: javascript message.channel.send(":rage:").then(message => setTimeout(() => {message.edit(":angry:")}, 1000)).then(message => setTimeout(() => {message.edit(":slight_frown:")}, 1000)).then(message => setTimeout(() => {message.edit(":neutral_face:")}, 1000)).then(message => setTimeout(() => {message.edit(":smiley:")}, 1000))

umbral pelican
#

eww

#

.then me harder

earnest phoenix
#

lmao

#

@quiet bobcat you need to change message => to something other than message, like msg =>

#

and then all the message.edit to msg.edit

tawny lava
#

Needs more .thens

quiet bobcat
#

Are you sure @tawny lava

tawny lava
#

yes you need more

#

you don't have enough

quiet bobcat
#

Ok

#

@earnest phoenix now I got this error TypeError: msg.edit is not a function

young cradle
#

sigh do you know how .then() works?

quiet bobcat
#

Not really

young cradle
#

Well, look for it, because attaching a .then() to another .then()

quiet bobcat
#

Idk how my bot even got approved

young cradle
#

It is not what you are looking for

quiet bobcat
#

Ok

young cradle
#

Neither do i, neither do i

quiet bobcat
young cradle
#

Anyhow, look for it and you will understand what you need to do to accomplish what you need

quiet bobcat
#

Alright

crystal void
#

could someone help translating ms (miliseconds) into a Day - Hour - Minute

#

discord.js btw....

lethal sun
#

thonk

#

ms package

crystal void
#

?

#

@lethal sun ?

#

oh... nvm

#

I see

quiet bobcat
#

@crystal void 1s = 1000ms 1m = 60 000 ms 1h= 3 600 000 ms 1d = 86 400 000 ms

crystal void
#

ik... but it's like 3545898ms

#

...

quiet bobcat
#

You have the exact values there ^^

crystal void
#

-.-

quiet bobcat
#

Whats wrong?

#

I dont get it?

crystal void
#

how would I recalculate 8555616419661ms into Days - Hours - Minutes????

quiet bobcat
#

I can fix it

crystal void
#

hiw?

#

how*

quiet bobcat
#

99 023,34 days

#

waw

crystal void
#

but how would my bot do that (in js)?

quiet bobcat
#

Not sure tbh

#

Only been coding for like 5 days

crystal void
#

lol

quiet bobcat
#

lol

#

Can you help me out real quick?

gaunt dune
#

suuure

#

for what?

quiet bobcat
#
    bot.setNickname({nick: msg.content.replace('Testing',)});
                           ^

ReferenceError: msg is not defined```
#

and if I use message I get message is not defined

#

But it works everywhere else

gaunt dune
#

so you can change the nick like that?

crystal void
#

can we get the whole code for bot.setNickname?

#

probably

quiet bobcat
#

Idk

#

cant test it out

#

I have a bunch of other startup commands

gaunt dune
#

try eval-ing it

crystal void
#

wait.... does this make sence to you @gaunt dune? js nick: msg.content.replace

gaunt dune
#

yes

#

it returns the string but with shit replaced

quiet bobcat
#
bot.on('ready', () => {
bot.setNickname({nick: message.content.replace('Testing',)});
};```
gaunt dune
#

try

bot.on('ready', () => {
    //bot.setNickname({nick: message.content.replace('Testing',)});
};
autumn nova
#

python

import json
import requests

url = 'https://discordbots.org/api/bots/' + str(bot.user.id) + '/stats'
payload = {'server_count': len(bot.guilds)}
headers = {'Authorization': 'secret' }
requests.post(url, data=json.dumps(payload), headers=headers)```
This correct?
crystal void
#

why don't you just do bot.setNickname('Tesing');?

#

@autumn nova sry... we are js... ask someone else

quiet bobcat
#

idk

gaunt dune
#

bot.setNickname({nick: "testing"})

#

try that

crystal void
#

yeah even that would work...

quiet bobcat
#
    bot.setNickname({nick: "testing"})
        ^

TypeError: bot.setNickname is not a function```
gaunt dune
#

yup

#

scroll down to "answers"

crystal void
#

.-.

gaunt dune
#

maybe you could find the answer there

crystal void
#

yup, lol

quiet bobcat
#

I dont get it

#

Why isn't message defined

crystal void
#

๐Ÿคฆ

gaunt dune
#

cause you're usseing it in bot.ready and not bot.message

#

where it gives you the message's contents

#

but

#

there's no message where you're using it

quiet bobcat
#

Ok so bot.on.message?

crystal void
#

๐Ÿคฆ

gaunt dune
#

๐Ÿคฆ

crystal void
#

ikr

quiet bobcat
#

๐Ÿ˜ฆ

gaunt dune
crystal void
#
bot.on('message', message => {
    your thing here
});```
gaunt dune
#

add this in a command where message is

#

what @crystal void said

crystal void
#

yup ๐Ÿ˜›

quiet bobcat
#

Still message isnt defined

crystal void
#

OMFG

#

lemme rafraze this...

#

hold on a sec

quiet bobcat
#

Make it failproof please

#

Im really bad at coding

#

Youre kidding me

#

I fixed it

#

...

crystal void
#
bot.on('message', message => {
    if (message.content === 'jo.nick') {
        your thing here
    }
});```
quiet bobcat
#

I forgot to remove the change nick from startup commands ๐Ÿคฆ

crystal void
#

there you go

#

finally

#

or if you want it to happen on a command do te thing that I've just sent

quiet bobcat
#

Sorry for taking your time with my stupid questions

crystal void
#

it's k

#

we are here to help ๐Ÿ˜‰

quiet bobcat
#

But thanks alot for the troubleshoot!

#

๐Ÿ˜‰

crystal void
#

np ๐Ÿ˜Š

#

anything else?

quiet bobcat
#

And btw I dont think the code you sent would have worked. I use case "command": to make my commands not if()

#

No thats all ๐Ÿ˜ƒ

crystal void
#

-.-

quiet bobcat
#

Dont ask why

crystal void
#

u use ur own command handler?

quiet bobcat
#

I guess

#

Is that dumb?

crystal void
#

no

#

but it can disable other users helping you...

#

I mean.. they don't have your code

quiet bobcat
#

Yeah

#

I'll have to change it sooner or later

gaunt dune
#

put your bot on github or something

crystal void
#

no need if you enjoy it + understand it

#

@gaunt dune Agreed

quiet bobcat
#

Either way I have to go now! Cya and thanks for all the help!

crystal void
#

k ๐Ÿ˜›

earnest phoenix
#

Opinions; which is easier to code discord.js or discord.py

#

Easier to code/understand*

crystal void
#

js

#

at least for me... I hate py

#

it's complicated

#

it's just an opinion btw!

earnest phoenix
#

I'm assuming thats why there is alot of discord.js bots

crystal void
#

my opinion

wispy jolt
#

i'm the opposite lol

gaunt dune
#

so you're a FILTHY COMMI?

wispy jolt
#

no

gaunt dune
#

so you're NOT the opposite :o

crystal void
#

@gritty dirge Is going to be down for next 15-30 minutes due to maintnance! Adding a function to play music!

wispy jolt
#

joy

gaunt dune
#

my bot is down an hour every other hour

#

and I have MANUALLY restart it

#

(โ•ฏยฐโ–กยฐ๏ผ‰โ•ฏ๏ธต โ”ปโ”โ”ป

#

is this your bot?

stone kiln
#

Drugs are bad m'kay

loud verge
#

Nah

lethal sun
#

How to edit bot messages after the bot send one? message.edit doesent work for me...

gaunt dune
#

channel for chatting about bot development

loud verge
#

wrong channel whoops my bad

gaunt dune
#

it's called async and it's a nightmare :)

lethal sun
#

How to edit messages sent by a bot?

Code:

        case "test":
        message.channel.send("mk ok bud");
        message.channel.edit("k")
            break;```
#

message.edit won't work.

gaunt dune
crystal void
#

@lethal sun is that Aeirety's thing?

prime cliff
#

@lethal sun are you using C# .net?

gaunt dune
#

also message is refering to the user's message

#

so message.edit would edit their message

lethal sun
#

discord.js...

restive totem
#

so its impossible

#

u cant edit soemone else message

#

except in a communist system

lethal sun
#

and @crystal void yes case is easier for me

#

and the code isnt a big of a mess when u use case

#

for commands

crystal void
#

neither is mine ๐Ÿ˜›

#

and I don't use case

lethal sun
#

ok

crystal void
#

whatever... no judging

lethal sun
#

yeah ๐Ÿ˜‚

#

@gaunt dune thonk then how do you make the bot to edit it's own message?

gaunt dune
#

@lethal sun

var m = message.cha...
m.edit("edited");
#

try that

#

if that doesn't work, you will have to have async enabled

#

1 sec copy&pasting my bot's code

lethal sun
#

doesent work

#

alright

gaunt dune
#

bot.on('message', async message => {
    // Code
#

have that at the beggining to enable async

#

then

#
async var m = message.cha...
m.edit("edited");
#

try that boios

crystal void
#

@gritty dirge is going to be down for 15-30 more minutes due to maintnance! Adding a function to play music!

lethal sun
#

owo

#

`
async var m = message.channel
^^^

SyntaxError: Unexpected token var`

#

@gaunt dune

gaunt dune
lethal sun
#

thonk

gaunt dune
#

const m = await message.cha...

#

that is the thing

lethal sun
#

nope

#

doesent work

gaunt dune
#

what eror?

#

@lethal sun

lethal sun
#

not an error

#

it doesent edit the message

gaunt dune
#

sure you have m.edit(...);?

lethal sun
#

yes

gaunt dune
#

are you using ```js
bot.on('message', async message => {
// Code

#

?

lethal sun
#

yes

gaunt dune
#

that's not very nice

lethal sun
#

smh

#

dang

#

^

gaunt dune
#
const m = await message.channel.send("m ok bud");
#

that was not my simplified ping command

#

xD

lethal sun
#

lol

gaunt dune
#

also #VSCodeRepresent

#

I don't know why it took me so long to write that...

lethal sun
#

ikr

gaunt dune
#
message.react('๐Ÿค”');

this is one of my most used lines of code in my bot

#

lo

lethal sun
#

lol

crystal void
#

@gritty dirge is back!

#

and the music is not working atm :/

lethal sun
#

i never actually knew how to make bot to react with a server emoji

gaunt dune
#

your bot can type server emojies tho

#

"type"

#

AND MY BOT CRASHED AGAIN

#

WHUP DE DOO

#

okey it's back

indigo field
rose tangle
#

crashes are nice

#

so far no crashes on my bot, but I'm pretty sure I've jinxed myself now

earnest phoenix
#

Ikr

#

@lethal sun That is not right

#

it should be "const m = message.channel.send("mk ok bud")"

#

actually, put the word await before message and make sure the function is async

crystal void
#
(node:18268) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property '364451125438709811' of undefined
(node:18268) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
chilly fiber
#

How do I get a timed message, like a daily reminder? I already have the time by var d = new Date();

uncut slate
#

use a setInterval or a database

ornate shadow
#

haaaaaaaalp I'm so messed up... so desperate

#
for (let i = 0; i < rows.length; i++) {
    let string1 = `${rows[i].rank}. `;
    let string2 = `Level: ${rows[i].level} (${rows[i].xp}/${rows[i].xp_required} XP)`;

    bot.fetchUser(rows[i].user_id).then((user) => {
        string1.concat(`${user.username} (`);
    });

    bot.fetchUser(rows[i].user_id).then((user) => {
        string1.concat(`${user.tag})`);
    });

    embed.addField(string1, string2);
}
#

I have no idea how to use promises

#

basically what I'm trying to do is

for (let i = 0; i < rows.length; i++) embed.addField(`${rows[i].rank}. ${bot.users.get(rows[i].user_id).username} (${bot.users.get(rows[i].user_id).tag})`, `Level: ${rows[i].level} (${rows[i].xp}/${rows[i].xp_required} XP)`);

but using that will make my bot crash if it meets an user ID that is not in that server...

earnest phoenix
#

Bro

#

You could use an interval

ornate shadow
#

tried to change from bot.users.get(rows[i].user_id).username to the client#fetchuser thing

#

interval?

earnest phoenix
#

Okay

#

Yes

#

Ill show you

#

For example

jagged plume
#

How does an interval help

earnest phoenix
#

My status reset for my bot is set to an interval

jagged plume
earnest phoenix
#

It allows for a daily interval

#

Bruh

ornate shadow
#

that's irellevant to my needs though

earnest phoenix
#

Oh

jagged plume
#

exactly how would an interval solve this

earnest phoenix
#

You have the daily reminding mechanism?

ornate shadow
#

are you trolling? ๐Ÿ˜

earnest phoenix
#

No

#

Omg, okay so is your code messed up, or your time interval

#

I can only help with the time interval

jagged plume
#

a time interval for what

ornate shadow
#

I don't need help with that, thank you

earnest phoenix
#

Okay

#

Bai then lol

#

Cant help

ornate shadow
#

I have trouble with this because I don't have experience with promises in js and I'm trying to make use of them to add stuff to a RichEmbed

earnest phoenix
#

Oh

#

Wait hold on bruh

#

Ill give you a link

#

Learrrrnnnn

ornate shadow
#

I already had that page open for the past one or two hours

earnest phoenix
#

Oh

#

๐Ÿ˜

#

Well good luck then mah dude

ornate shadow
#

abd I have opened it several times in the past few days

#

even a week

earnest phoenix
#

So you srsly need help

#

Ill alert deh coders

#

Wait

ornate shadow
#

rofl

earnest phoenix
#

Ill alert the best coder I know

#

@trim steppe EY

ornate shadow
#

xD

earnest phoenix
#

@trim steppe BOI

trim steppe
#

:/

#

can you not

earnest phoenix
#

Oh sorreh

#

Wait are you busy

#

Or do you have free time

trim steppe
#

I'm busy atm

#

call back later

earnest phoenix
#

Oh

#

Okie

#

Its me, Set8 btw

trim steppe
#

:/

earnest phoenix
#

Wait

trim steppe
#

ok

earnest phoenix
#

Whos a good programmer you know

trim steppe
#

what now

#

err

earnest phoenix
#

Thats not busy

trim steppe
#

err

ornate shadow
#

throw err;

trim steppe
#

well most people i know are in the other bot list

#

because i used to spend the most time there

#

just ask now

#

i guess

#

i can take it

earnest phoenix
#

Okay

#

@ornate shadow Ask away mah dude

trim steppe
#

:/

ornate shadow
#

basically I suck at promises and I need them to add stuff to a RichEmbed

#

tried to change from bot.users.get(rows[i].user_id).username to the client#fetchuser thing

trim steppe
#

๐Ÿค”

ornate shadow
#

but I have no idea how to return the username through that... it's using promises

trim steppe
#
client.fetchUser('6969696969').then((user) => {
    console.log(user.username);
});
ornate shadow
#

hmm ok I guess that should work

#

but

#

how do I add that to a string in a addField in a rich embed?

earnest phoenix
#

Im learning javascript!

#

On codeacadimy

ornate shadow
#

I mean

trim steppe
#

user.username is a string

#
client.fetchUser('376147022660632587').then((user) => {
    console.log(user.username + ' is really dumb.');
});
#

unless you want to use templates

ornate shadow
#
for (let i = 0; i < rows.length; i++) {
    let string1 = `${rows[i].rank}. `;
    let string2 = `Level: ${rows[i].level} (${rows[i].xp}/${rows[i].xp_required} XP)`;

    bot.fetchUser(rows[i].user_id).then((user) => {
        string1.concat(`${user.username} (`);
    });

    bot.fetchUser(rows[i].user_id).then((user) => {
        string1.concat(`${user.tag})`);
    });

    embed.addField(string1, string2);
}

I have tried this and it doesn't work. what am I doing wrong?

trim steppe
#
client.fetchUser('376147022660632587').then((user) => {
    console.log(`${user.username} is really dumb.`);
});
#

string.concat?

ornate shadow
#

yeah

#

to add to the string1

trim steppe
#

string.concat returns a string

ornate shadow
#

oh shit

#

so

#

string1 = string1.concat

#

..

trim steppe
#

yea

ornate shadow
#

.:face

trim steppe
#

I always use +=

ornate shadow
#

๐Ÿคฆ

trim steppe
#

so i was surprised

ornate shadow
#

OMG

#

if this works

#

I love you

trim steppe
jagged plume
#

also why fetchuser twice

trim steppe
#

oh yea

#

i didn't notice

#

why

#

wait

#

that won't work

ornate shadow
#

why? :-<

trim steppe
#

because fetchuser is async?

ornate shadow
#

oh

trim steppe
#

maybe

#

im not sure

ornate shadow
#

well it's worth a shot

jagged plume
#

all of the addfield and sending functions need to be put in the callback for the promise or it'll be run before the promise is resolved

ornate shadow
#

no :-<

#

it doesn't work

earnest phoenix
#

Who mentioned me

#

Oh hai

ornate shadow
#

I mean not even an username or w/e

earnest phoenix
#

Bro

#

To do a mention with a user ID

#

Its <@user id here>

ornate shadow
#

meh

earnest phoenix
#

@earnest phoenix

trim steppe
#

that id is yours

#

lol

ornate shadow
#

I'll just smack my head for a few weeks

#

until I make it work

earnest phoenix
#

Or something that suits your needs