#development

1 messages Β· Page 534 of 1

inner jewel
#

x === false can be simplified to !x

violet dagger
#

xD

earnest phoenix
#

@empty owl Promise.then does not take a method!!

#

It takes a callback function

blazing star
#

yep

#

u can bind a method iirc

earnest phoenix
#

I think you're talking about something else

blazing star
#

i think u can do like <Promise>.then(callback.call(this))

#

i’m not really sure as I never use any sort of binding for functions

earnest phoenix
#

Uhm

#

do you know what that does?

blazing star
#

I know what call/bind does

earnest phoenix
#

Then you should know that thats pointless

#

You don't need to provide a this argument if you use an arrow function

bright spear
#

never ask the same thing in 2 channels smh

blazing star
#

smh

earnest phoenix
#

smh

vernal rivet
#

what is the question?

earnest phoenix
#

+help

#

Damn it

vernal rivet
#

commands do not work here, the only places that commands will work is in the testing channel @empty compass

bright spear
#

Well if you run a help cmd in any channel you'll get a bunch of dms

vernal rivet
#

oh rip

#

not me

#

lol

slim heart
#

how could i tell if there is no message.content

#

like i tried if(message.content == "")

west raptor
#

so like

slim heart
#

or !message.content

west raptor
slim heart
#

but it wont work

#

no i

#

well

#

idk

#

idk if theres something there

#

but like if you sent an attachment

#

theres no message.content

west raptor
#

uh

last ferry
#

message.content == 0

#

if a message has an attachment itll be 1

#

iirc

west raptor
#

what about embed though

last ferry
#

uh

#

i think it still works for embeds

slim heart
#

no thats not it

#

+eval message.channel.fetchMessage('521522475222433821')
.then(res => {
if(message.content == 0) console.log('hi')
})

#

i did that

last ferry
#

message.content == 0

slim heart
#

and it didn't

#

yes

last ferry
#

Context.Message.Attachments.Count() == 1

#

would that work

slim heart
#

i can tell if it has an attachment

#

but i cant tell if it has no message.content

#

cuz u can send or not send a message with the attachment

#

yk what

last ferry
#

wait so "" didnt work?

blazing star
#

yes

last ferry
#

ok 1 sec

slim heart
#

im stupid

blazing star
#

it would not work

slim heart
#

i did message.content == 0

blazing star
#

lmao

slim heart
#

when i need to do res.content == 0

#

@last ferry you were right thank you

blazing star
#

y tho

last ferry
#

lol

blazing star
#

what do you need to check

last ferry
#

you could also try msg.Length == 0

#

cause htat might work too

blazing star
#

if the content is 0

#

which will always be false because content is a string

west raptor
#

.length

blazing star
#

and plus fetching messages returns a collection

#

oh fetchMessage nvm

last ferry
#

message.content.length == 0

blazing star
#

now that works

last ferry
#

yeah im used to C# lol

blazing star
#

wait, no

#

messages can’t be empty

#

so that’s useless

west raptor
#

they can

#

kinda

last ferry
#

with just an image or embed they can

west raptor
#

^

blazing star
#

yeah, with u200b

#

and those confusions

#

conditions

last ferry
#

if you leave the "comment" blank

#

the message is empty

blazing star
#

yep

#

it’s like sending no payload_json

bright spear
#

or you can just edit a message into nothing

blazing star
#

true

bright spear
#

oh wait they patched that

inner jewel
#

that's a bug tho

blazing star
#

yep

hoary stag
#

I don't understand what tthis wrote

spring ember
#

@hoary stag it failed to connect

hoary stag
#

okey

earnest phoenix
#

.

tribal thunder
#

Is there a way as a bot owner to unsubscribe from channels?

quartz kindle
#

you mean for the bot to ignore certain channels?

earnest phoenix
#

ok ik that's a known bug, but every time i refresh the discord applications page, my bot gets another token, w0tf should i do, cuz i can't connect my bot

west raptor
#

thats not a bug (afaik)

#

also wdym you cant connect to ur bot

earnest phoenix
#

bcs i refresh the page, bot gets another token, and i can't use it in my code

late hill
#

The old token still works

#

It only disables those tokens if you used the refresh token button

earnest phoenix
#

i can't get the old token fok me

late hill
#

regenerate*

#

You don't need the old token

#

Any token shown on there will work

#

Untill u hit regenerate

earnest phoenix
#

nope it doesn't

late hill
#

Then you're doing something wrong

earnest phoenix
#

hm

#

ye nvm

late hill
#

πŸ‘€

earnest phoenix
#

i was trying to get from .env

#

and it was undefined all the time DoubleFacepalm

late hill
hushed berry
#

πŸ˜‚

earnest phoenix
#

wot

#

did you even put it in env

#

ok wtf is this

#

it worked before and now it doesn't

#

when i set command that can be used by my id only it works for others 2 lol

late hill
#

Code πŸ‘€

tribal thunder
#

The way I understand it to work is that any channel can invite my bot to their channel right? Can I as the owner of the bot force it to leave those channels?

late hill
#

You mean guilds/servers

#

Yes you can

#

Depending on what library you use

tribal thunder
#

I'm using Discord.js

late hill
#

okay

#

Pretty sure .leave()

#

on the guild object

#

would work

tribal thunder
#

hmm ok, I'll check the API

late hill
#

client.guilds.get(id) to get the guild

tribal thunder
#

The bot console isn't aware of what servers it's connected to right?

#

I can only determine that through code?

uneven rover
#

make an eval command

late hill
#

Unless you did something special

#

No

uneven rover
#

List all servers with corresponding name and ID

client.guilds.map(g => 'Guild: ' + g.name + ' ID: ' +g.id).join('\n')```
Assuming that you have an eval command
```javascript
client.guilds.get('ID').leave();
quartz kindle
#

it is if you run it in a browser environment

#

for example, if you run your bot in nwjs or electron, you can access it through the developer tools console and interact with discord in real time

late hill
#

But who does that πŸ‘€

lofty hamlet
#

Hi !

#

Who can help me ?

#

I have a problem

#

My code

#

My error : `/home/Akimitsu_Dev/commandes.js:83
const { body: buffer } = await snekfetch.get(member.displayAvatarURL);
^^^^^

SyntaxError: await is only valid in async function
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3`

west raptor
#

```js
<code here>``` pls

lofty hamlet
#

No it's to long @west raptor

#

Look hastebin

west raptor
#

??

#

also make the function async

lofty hamlet
#

? Hu ?

#

it's just everything we expect πŸ€”

west raptor
#

what

lofty hamlet
#

I don't know why

#

it's just everything awaitπŸ€”

west raptor
#

whats your native language

lofty hamlet
#

French

west raptor
#

ok

lofty hamlet
#

all await doesn't work

#

i don't know why

west raptor
#

i assume you have

#
function (){
    // ...
    await thing();
    // ...
}```
#

or something

#

like that

#

am i correct?

lofty hamlet
#

mmmmhhh

#

you can edit my code ?

#

Plz ?

#

@west raptor

#

Hum no @west raptor look my code

west raptor
lofty hamlet
#

What @west raptor ?

west raptor
#

aaa

#

hold on

lofty hamlet
#

Ok ^^

west raptor
#

Google translate:

La fonction n'est pas asynchrone

lofty hamlet
#

So ?

west raptor
#

wait ne peut Γͺtre utilisΓ© que dans une fonction asynchrone

lofty hamlet
#

For test my canvas i set thi in command but this command work

#

            const applyText = (canvas, text) => {
                const ctx = canvas.getContext('2d');

                // Declare a base size of the font
                let fontSize = 42.5;

                do {

                    ctx.font = `bold ${fontSize -= 10}px sans-serif`;

                } while (ctx.measureText(text).width > canvas.width - 300);


                return ctx.font;
            };

            const canvas = Canvas.createCanvas(700, 250);
            const ctx = canvas.getContext('2d');

            const background = await Canvas.loadImage('./Welcome.png');
            ctx.drawImage(background, 0, 0, canvas.width, canvas.height);


            // Slightly smaller text placed above the member's display name
            ctx.font = 'italic 25px sans-serif';
            ctx.fillStyle = '#2A2A30';
            ctx.fillText('Bienvenue sur le Serveur', canvas.width / 2.7, canvas.height / 2.1);

            // Add an exclamation point here and below
            ctx.font = applyText(canvas, `${message.author.username}`);
            ctx.fillStyle = '#2A2A30';
            ctx.textAlign = 'center'
            ctx.fillText(`${message.author.username}`, canvas.width / 1.7, canvas.height / 1.5);

            ctx.beginPath();
            ctx.arc(125, 125, 100, 0, Math.PI * 2, true);
            ctx.closePath();
            ctx.clip();

            const { body: buffer } = await snekfetch.get(message.author.displayAvatarURL);
            const avatar = await Canvas.loadImage(buffer);
            ctx.drawImage(avatar, 25, 25, 200, 200);

            const attachment = new Discord.Attachment(canvas.toBuffer(), 'Welcome.png');

            message.channel.send(attachment);
            break;```
#

But in guildmemberadd my code doesn't work @west raptor

#

I don't know why

west raptor
#

Because the function is not async

lofty hamlet
#

So ?

#

How should I do it?

brittle nova
#

so you can't use await

west raptor
#

Make it async

pale parcel
#

hi

lofty hamlet
#

I do not know how to do

#

....

#

πŸ€”

pale parcel
#

rolles command?

west raptor
#
bot.on('guildMemberAdd', async member => {
    //...```
lofty hamlet
#

You can edit my code pllzzz @west raptor ?

#

No it's good

#

Thanks ! @west raptor

west raptor
#

np

loud salmon
#

@normal wyvern you would have to do some research'

normal wyvern
#

Ok

loud salmon
#

i would start there

#

and then try and emulate a system like it

normal wyvern
#

As of now i just do $guildactivate <guildId> <true/false>

loud salmon
#

mhm

#

anything wrong with that system?

normal wyvern
#

Yes

#

It's nose and ez for now

#

But then later I have to keep track literall of stuff intact don't even worry

#

I'll do it when the time comes if i need to.

#

You see those emojis

#

On mobile it looks like :emojiName:

loud salmon
#

it may be an issue with discord

normal wyvern
#

Yes

fluid cloud
#

It is

topaz fjord
#

It's a none issue

#

*known

normal wyvern
#

It's a discord issue i know

topaz fjord
#

English

#

Pls

sick cloud
#

use \❌ and \βœ…

topaz fjord
#

no

sick cloud
#

mobile will show unicode

normal wyvern
#

I send the emoji by just doing :emojiName:

fluid cloud
sick cloud
#

at the least

topaz fjord
#

Heck out of here tony

normal wyvern
#

Not by getting it or something

sick cloud
#

fine

normal wyvern
#

Which way to do?

#

How should i do it then?

sick cloud
#

unicode is better

#

you just put a \ infront of the emoji in discord

#

in mobile, they'll show unicode but on pc they'll show as actual emojis

normal wyvern
#

\\\🚩

sick cloud
#

\:x: ie

#

would make \❌

normal wyvern
#

:x:

#

:x:

#

Nope

#

:x: ie

sick cloud
#

maybe they broke it on mobile lol

normal wyvern
#

You try

sick cloud
#

works fine as i showed

#

\❌

mossy vine
#

:poop:

#

Doesnt work on mobile

sick cloud
#

rip

normal wyvern
fluid cloud
normal wyvern
#

Now i do βœ…

#

❌

fluid cloud
#

Works fine

normal wyvern
#

That's what they are

#

Why not when i put in in title?

late hill
#

Because that's the way discord mobile works

#

I wouldn't expect a change to that anytime soon

#

If you want your bot to work properly on mobile, don't use emojis in titles

#

Same goes for field names afaik

earnest phoenix
#

if (blackListInfo[msg.author.id]) return msg.channel.send(blacklistembed) I have this but it ignores it and let blacklisted users use commands

knotty steeple
#

thats not how you

#

use

#

json

#

and

#

use a database

earnest phoenix
#

idk

#

it wont even delete

knotty steeple
#

wat

earnest phoenix
#

idk how to make it work

late hill
#
[
    "blacklistedID1",
    "blacklistedID2",
    "blacklistedID3"
]```
#

..

#

oh

#

You're using the id in the fricking ..

#

If you want to hardcode your blacklist you can do it by putting the ids in an array like that^^

knotty steeple
#

why are you encouraging

#

use of json

late hill
knotty steeple
#

its gonna corrupt soon

late hill
#

Because they aren't going to try using a db

knotty steeple
#

so?

#

their fault

late hill
#

I'm giving them something to work with

#

And a hardcoded blacklist legit doesn't matter

#

If you're not an ape you're not going to blacklists thousands of users

knotty steeple
#

json is persistent data

late hill
#

It won't just magically break

#

It'll work for his use case

knotty steeple
#

a

ruby dust
#

in discord.py, does the AutoShardedClient object share the same user/guild cache?

earnest phoenix
#

TypeError: blackListInfo.includes is not a function

#

@late hill

late hill
#

How did you define blackListInfo

earnest phoenix
#

const blackListInfo = require("./JSON/blacklistinfo.json")

late hill
#

πŸ‘€

earnest phoenix
#

if (blackListInfo.includes(msg.author.id)) return msg.channel.send(blacklistembed)

#

thats what I have

#

Β―_(ツ)_/Β―

west raptor
#

a

earnest phoenix
#

b

west raptor
#

you should do

earnest phoenix
west raptor
#
{
    "users":["user1", "user2", "user3"]
}```
late hill
#

But it should work

#

With just an array

earnest phoenix
#

I don't know how to use JSON

west raptor
#

json is so easy

#

pls

earnest phoenix
#

not to me

#

oof

late hill
#
[
  "100",
  "200"
]```
earnest phoenix
#

idk how

late hill
#
const test = require('./test');

console.log(test.includes("100")); //true
console.log(test.includes("00")); //false
console.log(test.includes("200")); //true
console.log(test.includes("10000")); //false```
#

Works fine for me.

#

test being the json above

earnest phoenix
#

the problem is commands dont error when the user is blacklisted

#

it errors when they're not

late hill
#

what

#

lol

earnest phoenix
#

idk

#
        let args =  msg.content.split(" ").slice(2).join(' ')
        if(!args[0]) return msg.channel.send("Invalid ID.")
        let embed = new Discord.RichEmbed()
        embed.setTitle("Please wait...").setDescription("Please wait while I check a few things.").setColor("RED")
        let m = await msg.channel.send(embed)
        fs.writeFileSync(`./JSON/blacklistinfo.json`, JSON.stringify(args, true, 4))
        embed.setTitle("Done!").setDescription("Sucessfully blacklisted.").setColor("RED")
        m.edit(embed)
    },``` 
I need this to save the user ids like this:
```'ids' {
'234'
'32423'
'324'
}``` but idk how
#

currently it just over writes ids

late hill
#

Yeh

#

If you're using commands to edit it

#

You shouldn't be using a json file

earnest phoenix
#

idk how

#

idk anything about data bases

late hill
#

Well

#

You could learn about them

#

Or keep the blacklist hardcoded

earnest phoenix
#

Maybe but I dont think I would ever use them for anything useful

late hill
#

Or if you rly want to use json

#

Because writefile will overwrite

#

You can get the entire json

#

Add the new user

#

and then write that

earnest phoenix
#

the problem is I need ALOT of ids possible and I need to be able to add and delete them

#

that's why I want to use commands

late hill
#

Then you should rly consider a database

earnest phoenix
#

yeah

#

ik

late hill
#

mlab & mongoose is what I would recommend

#

If you look it up I'm sure you'll find something

sick cloud
#

whats a dict

earnest phoenix
#

I need them to save as a file

sick cloud
earnest phoenix
#

because they will be long term blacklists

late hill
#

Your database can store them forever

#

πŸ‘€

earnest phoenix
#

can mlab

#

store forever?

late hill
#

I've never had any downtime on mlab

#

Using their free plans

earnest phoenix
#

no

#

I need physical code

late hill
#

You can always create backups if you want to be sure

earnest phoenix
#

I can add

late hill
#

You can add/remove to it

#

..

#

It's a database

#

You read/write to it

#

You could also host the database on your own system if that makes you feel more secure..

#

@sick cloud a dictionary is an object

#

with key: value pairs

#

πŸ‘€

sick cloud
#

so a python object or smtn?

late hill
#

Yeh

#

It's called a dictionary in some languages

earnest phoenix
#

can bot read messages from specific channel without prefix

inner jewel
#

prefixes are unrelated to receiving messages

late hill
#

If you code that

#

πŸ˜‚

inner jewel
#

discord sends message events for all channels the bot has permission to read

#

whatever you do with those events is your code

earnest phoenix
#

how could i get just message

inner jewel
#

read the docs for your library

#

on how to add an event listener for received messages

earnest phoenix
#

i searched, its js

#

client.on("message", async message => {

late hill
#

Your language is js

#

Not your library

#

πŸ‘€

earnest phoenix
#

discordjs

#

lets say i want to read message

#

from some channel

#

and display it on site

#

for now i just need to get message content

late hill
#

message.content

#

?

earnest phoenix
#

i guess

late hill
earnest phoenix
#

ikr that, all i need is to get message content

#

but i always fail to find it

late hill
#

It's just message.content ? πŸ˜‚

earnest phoenix
#

hmmm

#

sec

brittle nova
#

docs are so hard to read, aren't they

earnest phoenix
#

im still confused

#

message.content

#

can you give me an example

keen drift
vernal rivet
#

?

manic badger
#

How would I make a voter-only command?

vernal rivet
#

Explain more please

manic badger
#

nvm

vernal rivet
#

If your asking how to make a command that ONLY voter can use, then you would search if the member has the role either by the I'd or name

#

If they don't then return a message saying that they don't have the right role.

manic badger
#

nvm

vernal rivet
#

Ok

earnest phoenix
#

let message123 = args.join(" ")

#

args is not defined

vernal rivet
#

Did you define args?

earnest phoenix
#

it was working minutes ago

#

idk wtf

vernal rivet
#

Code please?

earnest phoenix
#

sec

vernal rivet
#

Ok

late hill
#

If you copied the code to get args and stuff from somewhere without actually understanding how any of it works

#

You probably won't be able to do many changes to it thonkku

vernal rivet
#

Yes

earnest phoenix
#
client.on("message", async message => { 

    let testmessage = args.join();
    const testchannel = bot.channels.get("513436447425036320")
    client.channels.get(testchannel).send(testmessage)
#

you don't have args defined

vernal rivet
#

Args is not defined

night imp
#

@earnest phoenix just do message.content

vernal rivet
#

Yes

night imp
#

No need for .join

vernal rivet
#

Or message.content.startsWith();

earnest phoenix
#

How can I make my bot run forever I use node.js

vernal rivet
#

Vps

late hill
#

That code would send a message everytime it receives a message πŸ‘€

night imp
#

Also you already got test channel you don't need to find it again @earnest phoenix

#

@earnest phoenix if you have a VPS already then npm i forever

earnest phoenix
#

Ok

#

Should I run it on a PI?

#

pm2

night imp
#

@earnest phoenix VPS is better

vernal rivet
#

Is forever God, or is it just like pm2

night imp
#

Forever is better than pm2

earnest phoenix
#

pm2 is better lol

vernal rivet
#

Rip

earnest phoenix
#

gives you more control

#

looped till it restarts @vernal rivet

vernal rivet
#

I just use nodemon

night imp
#

For production?

inner jewel
#

i just use the built in services the OS has

#

:^)

vernal rivet
#

For both for now, til I get a vps, I am a guy who wants free things that don't need a credit card

night imp
#

Okie

#

Glitch is shit but free

vernal rivet
#

My bot is really stable for now, it hasn't died yet

night imp
#

If your going to code your bot I would at least pay 3/Mon for a vps but just me

late hill
#

I wouldn't if I can get it for free

vernal rivet
#

I suggest for beginners to use node or nodemon

earnest phoenix
#

might run it on a PI

vernal rivet
#

OwO

#

Why pi

earnest phoenix
#

UwU

#

I can have it plugged in

#

and Connect through putty

vernal rivet
#

;-;

night imp
#

@late hill that's like saying why buy a meal when you can eat crackers

late hill
#

No

#

Then you missunderstood

#

If I can get a free service to suit all my needs

#

I will not pay

vernal rivet
#

Yes

night imp
#

It is slower

#

And has a higher ping

vernal rivet
#

I demand there to be a free lifetime vps

late hill
#

That's very wrong

#

There's free hosts which are located in the uk

#

with a good ping

#

under 30ms

vernal rivet
#

Really?

night imp
#

Which run like shit yeah

late hill
#

Nah

vernal rivet
#

But do you need to have a credit card to get one?

late hill
#

No

inner jewel
#

ping is a shit measurement

vernal rivet
#

Ummmmmm

night imp
#

@late hill link me one so I can compare

vernal rivet
#

Yes

late hill
#

I can legit host my bot on a free platform

inner jewel
#

also just ping means nothing

late hill
#

Without any issues

#

Almost 5k servers now

inner jewel
#

ping is only meaningful if all measurements are to the same place

vernal rivet
#

And 30 Ms is pretty fast

inner jewel
#

yes but 30ms to what?

earnest phoenix
#

I'll use VNC

inner jewel
#

to the speedtest server?

#

that's meaningless

#

Β―_(ツ)_/Β―

late hill
#

xd

vernal rivet
#

Just in general, the US has many things that are around 100ms

late hill
#

If you do a command and get the feeling of an ~instant reply

#

Then it's allright

vernal rivet
#

Yes

late hill
#

For which you do not need to pay

#

It's 2018 )

vernal rivet
#

Yea

#

Can you link me one, I want to look at it

late hill
#

Just google it

#

People mostly just bash on these free services

vernal rivet
#

What's the website?

late hill
#

Cuz they are too stupid to set them up properly

vernal rivet
#

Lol

late hill
#

The most known ones would be glitch and heroku I guess? xd

earnest phoenix
#

im angry at node

vernal rivet
#

Heroku I have, but struggling with setting it up

earnest phoenix
#

JUST

#

EXAMPLE

late hill
#

I've never used glitch

earnest phoenix
#

how the fuck

#

could i get message, just code example

late hill
#

Heroku can do nice things once u set it up

#

You just have to get used to it

vernal rivet
#

I seen good reviews, but I don't understand the git and vps thing

manic badger
#

glitch for da win

vernal rivet
#

Glitch is for people who want to look stupid

sick cloud
#

real vps heard of one

#

i use a dedicated server

manic badger
#

@vernal rivet no uβ„’

late hill
#
client.on("message", async message => { 
const messageContent = message.content;
});```
vernal rivet
#

Nah

late hill
#

@earnest phoenix ?

manic badger
#

I'm cheap af

vernal rivet
#

Oof

sick cloud
#

@late hill what's that even for

#

just use message.content directly

late hill
#

He's asking how to get the messag content

#

And wants an example

#

I already told him it's just message.content

#

🀷

sick cloud
#

okay

vernal rivet
#

Message.content is a method you use to check if the message contents it, so it's very unnecessary to name it

inner jewel
#

it's a property

#

not a method

late hill
#

^^

vernal rivet
#

Sorry

sick cloud
#

lol

vernal rivet
#

I was right about the function of it at least

sick cloud
#

it returns parsed content

#

you can use cleanContent to get the content

#

that's raw

#

but clean

vernal rivet
#

Shhhh, no one needs to know that πŸ˜‰

sick cloud
#

what

vernal rivet
#

Nothing

#

What were we talking about again?

earnest phoenix
#

did (); cause problem?

vernal rivet
#

No it needs to have();

sick cloud
#

you don't need it on message content

late hill
#

.content shouldn't have ()

#

..

vernal rivet
#

Oh really?

sick cloud
#

it's a property smh

#

not a function

vernal rivet
#

I don't use the message.content property

sick cloud
#

do you own a bot

vernal rivet
#

Yes

sick cloud
#

does it have commands

vernal rivet
#

Yes

late hill
#

πŸ˜‚

sick cloud
#

then you use message content

#

smh

vernal rivet
#

I don't have the message.content.startsWith(); thing

sick cloud
#

oh so you have no prefix LUL

vernal rivet
#

I do

sick cloud
#

you use message content if you have commands in your bot

inner jewel
#

what if i use commando

sick cloud
#

your bot has to check it somewhere

earnest phoenix
#

i was ragging over ;

vernal rivet
#

if(cmd === `${prefix}<command name>`){

#

-_-

late hill
#

but what is cmd

sick cloud
#

lol

vernal rivet
#

It's a messageArray[0]

inner jewel
#

that's basically the same as startsWith

sick cloud
#

cmd is a formated message content

#

anyways

inner jewel
#

and just as bad

late hill
#

and messageArray is most likely message.content.split(' ')

vernal rivet
#

Lol

sick cloud
#

i use regex

vernal rivet
#

It's easier to make commands at least

sick cloud
#

what about making a good bot

#

have a file for each command

vernal rivet
#

I already did that

#

Command handler

sick cloud
#

then why do you have an if

#

that's dumb

late hill
#

if
elseif
elseif
elseif

clearly supperior command handler

inner jewel
#

require("./commands/" + name)(message)

sick cloud
#

.

#

wow

vernal rivet
#

It's only commands like ping, if it's too small, or has multiple commands but shares the same function I have them in the bot file

sick cloud
#

that's disgusting

late hill
#

πŸ˜‚

vernal rivet
#

It is, but it works

late hill
#

But it's ass to read

vernal rivet
#

Lol

#

Not really

late hill
#

Bet

vernal rivet
#

I comment each section for what each thing is

late hill
#

Good readable code barely needs comments

#

You split up your code into functions

vernal rivet
#

That's bad programming habits, lol

late hill
#

And use proper naming for those functions and the variables you use

#

No

inner jewel
#

good code should also have docs

vernal rivet
#

Yes

inner jewel
#

all good code has docs

late hill
#

It's the opposite of bad habbits

vernal rivet
#

I agree with the docs, but comments are only used to define something that the programmer knows that someone else won't understand it

late hill
#

Yes

#

It's your job to make them understand

#

Which you can in most cases do without comments

vernal rivet
#

I only use comments to do that, and make it easier for me to find stuff

inner jewel
#

comments are useful to explain why something is what it is

vernal rivet
#

This is where I say fight my apcs teacher, he will strongly disagree with you about comments, lol

manic badger
#

when you spend 1 hour looking for free VPS hosting, find nothing, continue looking...

late hill
vernal rivet
#

That's what I did, but for two whole days worth

late hill
#

I'm just saying

manic badger
#

wow

late hill
#

Why put a comment if you can replace it with a function

manic badger
#

lol

vernal rivet
#

Why not, why put a function if you don't need a function?

inner jewel
#

because they're different things?

vernal rivet
#

Lol

late hill
#

You don't need comments on every block of code

vernal rivet
#

I don't do that

late hill
vernal rivet
#

I only do it for big section, duh, I am not that dumb. If it's music section I put a comment saying music and that's it

late hill
#

Just a comment that says music?

#

That seems pretty useless to me.

vernal rivet
#

Of course it's going to have more than just music, I was just making it clear that I only make comments for a section or genre of things, if it's music I make a comment about the music function, settings have a settings comment talking about it's in here, etc. I don't do it by each command, that's stupid and unnecessary to do

late hill
#

xd

vernal rivet
#

A good code would have little comments, yes, but sometimes the programmer doesn't have good beginning comment, that they have to make more than one, but really you only need at least 10 comments for a code that is about 1,500 lines, lol

late hill
#

yes

vernal rivet
#

If it's short, then 1 should work for about a 100 - 300 line code

manic badger
#

lol

earnest phoenix
pastel mulch
#

Oops! Error: 401 Unauthorized
Why do I keep getting this in logs?
It doesn't affect the bot, it just says it

quartz kindle
#

are you posting your server count?

#

it might be coming from there

earnest phoenix
#

anyone have any knowledge of the shards and websocket? Please DM me

blazing star
#

I do

sick cloud
#

@earnest phoenix ask your question here

#

I have a bit of knowledge

earnest phoenix
#

@sick cloud ok my shards are failing to log in and this is a recent thing. After check discord.js it doesn't appear they have made any major changes to shards but now all of a sudden the only errors i get are because of shards

#

What could cause them to fail to log in

#

Error [SHARDING_READY_DIED]: Shard 1's process exited before its Client became ready.

sick cloud
#

Discord API is memeing a lot for big bots

earnest phoenix
#

what does that mean exactly?

sick cloud
#

it's have issues

#

and they won't fix it

molten edge
#

@earnest phoenix discordjs right?

#

i use

const Discord = require('discord.js');
const { TOKEN } = process.env;
const Manager = new Discord.ShardingManager('./Botty.js', { totalShards: 'auto', token: TOKEN });
Manager.spawn() ```
#

of course set token to wherever you token is located

earnest phoenix
#

@molten edge still getting this error

#

it has sent my bot on a restart loop

blazing star
#

oof

molten edge
#

Mikes problem is all fixed up, seems it was something else in his shard file that was causing the errors

earnest phoenix
#

Does anyone know how to make a custom emoji?

lusty dew
#

@earnest phoenix Paint 3D?

#

Or Photoshop

#

Or Adobe InDesign

#

But those two cost money

#

I just use my school's Adobe programs to do that shit

#

Lmao

lament meteor
#

u can use anything and upload it to discord

lusty dew
#

True

#

I was just listing the ones that work best

#

Lol

summer delta
#

Anyone know how to get your app to be authorized?
I'm having a hard time figuring it out, would much appreciated if someone could help.

sick cloud
#

oauth2

#

identify scope gets you the basic user data

summer delta
#

What is the Redirect url @sick cloud ?

sick cloud
#

read the docs and think about the name

#

"redirect" "url"

summer delta
#

I used the example function get_token() it works, but only for the bot owner's account and not others, do you perhaps know the solution for adding it for users that add my bot as well?

sick cloud
#

uhh

#

i don't use python

summer delta
#

Do you have a solution in the language you're using?

sick cloud
#

not really

sick cloud
#
    text
        .replace(':skin-tone-1:', '').replace('🏻', '')
        .replace(':skin-tone-2:', '').replace('🏼', '')
        .replace(':skin-tone-3:', '').replace('🏽', '')
        .replace(':skin-tone-4:', '').replace('🏾', '')
        .replace(':skin-tone-5:', '').replace('🏿', '');
``` why didnt this work
void mantle
#

doesn't it also need the ids?

sick cloud
#

those are skin tones

#

the emoji comes as moji: '😏🏻',

earnest phoenix
#

skin tones only go on human emojis and not the yellow ones

#

Only hand emojis and ones of people will take skin tone the rest wont

sick cloud
#

the api has the skin tones though

earnest phoenix
#

you are using an emoji that cannot use skin tones

#

πŸ‘πŸ½πŸ‘΄πŸΌπŸ™ŽπŸ½β€β™‚οΈ emojis like this take skintones

#

the regular emojis do not

sick cloud
#

i'm not

#

emojidex apparently adds skin tones

#

how do i remove them

earnest phoenix
#

how to calculate double integrals?

lament meteor
#

@sick cloud why not parse emotes?

#

using regex

soft plaza
#

who uses mysql and does djs client sharding?

molten edge
#

@soft plaza i think @earnest phoenix had mysql and shards going

soft plaza
#

ok im gonna dm him

#

thx

molten edge
#

Np

topaz moth
#

is there a way to fix the whole widget is cached thing

#

i cant seem to find a way to make the widget display the current amount of upvote instead of an old amount in a embed

wanton walrus
#

I feel like a total dumbass, but I rarely use exports like this and I cannot for the life of me figure this out -

const db = require('./mariadb.js')
const cps = function getCPS(userid) {
    db.query(`SELECT mystuffgoeshere FROM table WHERE userid = ${userid}`, function (error, table, fields) {
        db.query(`SELECT mystuffgoeshere FROM tableagain WHERE userid = ${userid}`, function (erroragain, tableagain, fieldsagain) {
           //some error stuff here normally
            var baseCPS1 = Math.floor(1.1); //this normally has calculations
            var baseCPS = Math.floor(1.1); //this normally has calculations as well
            return baseCPS;
        })
    })
}
module.exports = cps;

But when I call the function when requiring it like so

let thing = require('../utils/getCPS.js');
thing(<userid goes here>)

It returns undefined

bitter sundial
#

it should be a promise

#

the query is an aync operation

wanton walrus
#

oh fuck you're right

earnest phoenix
#

Well no

#

It's a callback

wanton walrus
#

well wait

#

^

#

it shouldnt need to be

bitter sundial
#

when you return in the callback it doesn't reach the outer function

earnest phoenix
#

The easiest solution would be attaching a callback

wanton walrus
#

I've fiddled for like a good hour and couldnt get something to work

bitter sundial
#

yeah callback is an alternative to promise but pls no πŸ˜›

wanton walrus
#

I tried wrapping it in a promise as well

earnest phoenix
#

Do you know how to create a callback?

#
function (userID, callback) {
 //Async code
callback(baseCPS)
}
#

Something like that

bitter sundial
#
const db = require('./mariadb.js')
const cps = function getCPS(userid) {
    return new Promise(function(resolve, reject) {
        db.query(`SELECT mystuffgoeshere FROM table WHERE userid = ${userid}`, function (error, table, fields) {
            db.query(`SELECT mystuffgoeshere FROM tableagain WHERE userid = ${userid}`, function (erroragain, tableagain, fieldsagain) {
               //some error stuff here normally
                var baseCPS1 = Math.floor(1.1); //this normally has calculations
                var baseCPS = Math.floor(1.1); //this normally has calculations as well
                resolve(baseCPS);
            })
        })
    })
}
module.exports = cps;
earnest phoenix
#

Then, in the other file,

thing("ID, baseCPS => { console.log(baseCPS)})```
wanton walrus
#

hm I see

#

I tried what Tonkku just posted but I did something differently lemme see what I did

#

oooh I see - alright

#

Thank you BlobHug

earnest phoenix
#

The call back is hella straightforward

wanton walrus
#

^

#

I don't like callbacks much so ima go with the promise

bitter sundial
#

we're trying to get rid of callbacks cuz they're hell

#

thats why promises and async/await exist

earnest phoenix
#

Promises can be hell too

#

And so can async await

wanton walrus
#

Most of my stuff is promise based

bitter sundial
#

async/await is the least hell

wanton walrus
#

^

earnest phoenix
#

Can't escape it with async ops in JS

bitter sundial
#

async/await is godlike πŸ‘ŒπŸ»

quartz kindle
#

after i learned how to properly await promises, i felt like jesus learning to walk on water

bitter sundial
#

hah

earnest phoenix
#

Well, a bunch of await statements in a try catch looks ugly too

#

My preference in that case would be to chain promises

quartz kindle
#

better await 5 times than 5 callbacks inside each other

earnest phoenix
#

True, but then I'd prefer a promise chain

#

For easy error handling

quartz kindle
#

Promise.all > all

earnest phoenix
#

That won't run things one after the other

inner jewel
earnest phoenix
#

So it won't apply in all cases tim

quartz kindle
#

it applies to parallel computing

bitter sundial
#

usually tho

wanton walrus
#

@inner jewel Thanks

bitter sundial
#

I await something, then await something else with the data from the first function

inner jewel
#

if the multiple awaits have no dependencies between them, just use destructuring + Promise.all

bitter sundial
#

I dont think I've ever been in a situation like that thumbnail

inner jewel
#
[a, b, c, d] = await Promise.all([getA(), getB(), getC(), getD()])
[e, f, g] = await Promise.all([getE(a), getF(b), getG(c)])```
violet dagger
#

Tim Tom

quartz kindle
#
promises = [];
for(i = 0; i < something.length; i++) {
promises.push(new Promise((resolve,reject) => {
    resolve("thing")
}))}
resolved = await Promise.all(promises)```
#

hue

earnest phoenix
#

The woes that we have in asynchronous JS: one solution creates another problem

quartz kindle
#

all solutions create more problems

inner jewel
#
await Promise.all(Array(something.length).fill().map(() => (async () => "thing")()))```
earnest phoenix
#

Mmm, I could beg to differ, but that's out of the scope of this channel

bitter sundial
#

y tho

quartz kindle
#

are you saying you have discovered the elixir of life? the one solution to all problems?

earnest phoenix
#

Yes, Tim

molten pewter
earnest phoenix
#

tΓΌrrkler ananΔ±zΔ± siker

#

adma olun

#

.Γ‡D

molten pewter
#

It also updates when you update your gist

sick cloud
#

@lament meteor wdym

earnest phoenix
#

I installed FFMPEG from the website into my node modules and it says FFMPEG not found

quartz kindle
#

did you install it with npm too?

#

you have to install both

earnest phoenix
#

whats the opus engine module called?

fresh kernel
#

For nodejs it’s node-opus
To install with npm npm i node-opus β€”save

quartz kindle
#

node-opus or opusscript

earnest phoenix
#

ty

sick cloud
#

β€”save no

#

@fresh kernel its --save

#

or -s

fresh kernel
#

I did put β€” but discord merged them together

#

and again

sick cloud
#

discord doesnt

#

--

#

your using the wrong key

fresh kernel
#

probably

#

Blame iOS then, idk

quartz kindle
#

ios does that

#

my bot has commands like .command --option1=ok --option2=bla and i had to add corrections for that

#

because so many people had their phones automatically convert -- to long dash lol

keen drift
#

yarn GWcmeisterPeepoLove

earnest phoenix
#

how can i get all members with same role

#

e.g. role asd, and i want to give them new role

sick cloud
#

what lib

earnest phoenix
#

discordjs

sick cloud
#

message.guild.members.filter(m => m.roles.has(role id))

#

that'll get all members with that role

earnest phoenix
#

can i get roles by name?

sick cloud
#

roles are sorted by ID so no

#

you need the id

earnest phoenix
#

i'll try

#

one more question

#

im searching but cant find a way to replace role color

quartz kindle
#

you can use role.find no?

#

instead of role.has

#

roles*

fierce owl
#

well I mean isn't there a way to mention a role and have the bot find the id?

vernal rivet
#

Yes

#

Search for the role name

bright spear
#

no need

vernal rivet
#

Roles are sorted by IDs. And names

bright spear
#

just remove <@& and >

vernal rivet
#

Yes

bright spear
#

and you'll get the id

vernal rivet
#

But that only works for single server bots

bright spear
#

wdym

vernal rivet
#

Each role has a different id

bright spear
#

yes

vernal rivet
#

You can search for the name

bright spear
#

whats wrong with that

vernal rivet
#

If the person wants to see the person's role is equal to let's say dj, if you do it be the I'd, then your only doing it for one server and not other servers

earnest phoenix
#

var role = message.guild.roles.find("name", "RoleName");

vernal rivet
#

That's decrepit

bright spear
#

yeah you cant use find like that anymore

#
message.guild.roles.find(r => r.name==='RoleName')```
vernal rivet
#

Yes

#

You should be telling him this, and not to search for the I'd, cause he is a bot developor, and his bot is approved, so it was made for anyone

bright spear
#

what does he even want to do

earnest phoenix
#

just how can i change color name

#

cant find it in docs

vernal rivet
#

It's best to do hex color

earnest phoenix
#

this but cant understand it

#

like

#

role.color("hex")

vernal rivet
#

No hex color is a system

earnest phoenix
#

its "hex" is just an example

#

of #FFFF

vernal rivet
#

#ffffff is equal to white

earnest phoenix
#

.

vernal rivet
#

Yes

#

I will have to find the right code of it

earnest phoenix
#

how about

#

role.setColor

vernal rivet
#

Let me check

stiff spire
#

Bet

brittle nova
#

$5?

sick cloud
#

how do i post my bots shard/server count? i literally have never had to do shards manually

stiff spire
#

Paypal or cash?

vernal rivet
#

Here, and your right

stiff spire
#

Bots are not allowed to:
β€’ Break the Discord Terms of Service
β€’ Have NSFW names/avatars/command responses (in non-NSFW channels)
β€’ Advertise anything NSFW in the short or long description
β€’ Be a clone or fork of another bot
β€’ Contain malicious scripts/code
β€’ Hide the report/delete/vote buttons
β€’ Vote in behalf of the user
β€’ Autoplay video or audio
β€’ Use CSS/JS or anything to hide DBL placed ads/banners

Bots in the queue will be declined if they:
β€’ Do not comply with the bot rules
β€’ Are offline
β€’ Fail to provide an easily accessible list of commands
β€’ Have no actual features
β€’ Allow NSFW content (including but not limited to the Urban Dictionary, links that source to pornographic material) outside of NSFW channels.

Bots will be kicked from the server if they:
β€’ Send join messages/mass messages/advertisements in direct messages

Bots will receive a mute if they:
β€’ Spam testing channels
β€’ Send level up messages (these should be disabled for this server)
β€’ Reply to other bots
β€’ Go rogue
β€’ Respond to non-prefixed commands
β€’ Send automatic messages without being triggered by a prefixed command

Any existing bot that breaks the rules will be deleted.

vernal rivet
#

Please do not flood this channel with unnecessary things

sick cloud
#

{ server_count: guildCount, shard_count: client.shard.count } so is something like this okay

stiff spire
#

Sorry

#

I like sushi

vernal rivet
#

Tbh I haven't worked with sharding before, you might need to look at the discord developer docs for that

earnest phoenix
#

role.setColor is not a function Thonk

lusty dew
#

Does anyone know a bot with a calculator cmd?

bright spear
#

Btw @sick cloud why can't u just use dblapi.js thonk

sick cloud
#

i dont need another dependency

#

a simple request will do fine

faint junco
#

can someone help me?

#

I have this code

#

return message.react.name("white_check_mark")

#

Is it going to do what it should and react to last message?

empty owl
#

ok

#

what

#

@faint junco u want it to react to the message sent by the bot

#

right?

faint junco
#

no

#

To the message originally sent

empty owl
#

did u send it?

faint junco
#

?

#

I tried and failed

empty owl
#

test it?

#

o

#

wait

#

i dont think there is a name thing

faint junco
#

oh ok

empty owl
#

wait

west raptor
#

@faint junco react is a function not a property

empty owl
#

\βœ…

faint junco
#

ik

west raptor
#

.

empty owl
#

message.react('βœ…')

faint junco
#

k lemme try that

empty owl
#

its \:white_check_mark:

#

the copy the emoji

faint junco
#

ik

empty owl
#

if (lastFlip !== null && cooldown - (Date.now() - lastFlip) > 0 ) { message.channel.send(Sorry, you have to wait ${timeObj.seconds}s ${timeObj.milliseconds}m!`)
} else {
if (currentMoney < 1) return message.channel.send('You do not have enough money! Price: 1 BB')

` this messed me tmy bot up

#
  if (lastFlip !== null && cooldown - (Date.now() - lastFlip) > 0 ) {
  message.channel.send(`Sorry, you have to wait **${timeObj.seconds}s ${timeObj.milliseconds}m!**`)
  } else {
  if (currentMoney < 1) return message.channel.send('You do not have enough money! Price: 1 BB')
  
#

it replies with Sorry, you have to wait 4s 809m!

#

But I want to get rid of the last digit

west raptor
#

ok first

#

it should be ms

empty owl
#

ok

#

wait

#

i got it

#

deciseconds

#

wait

west raptor
#

ok

empty owl
#

thats not it

shadow barn
#

i must be dumb but i can't see the issue

#

shouldn't it define /src/ on ./commands & ./events since it's in the same dir?

#

nvm i fixed it

scarlet bane
#

Aye so when can a message's author be null?

#

Cus i got weird stuff happening with messages having null as author

sick cloud
#

when a webhook sends it

scarlet bane
#

Nope, i was dumb and parsing message_update as if it was message_create

#

message_update is allowed to skip parameters that havent changed

#

: )

#

thanks anyways tho

languid dragon
void mantle
mossy vine
#

Did this kid actually tag mods because of his birthday lmao

cold loom
gleaming glen
#
  1. dont ping all mods
modern sable
bitter sundial
#

last warning

slim heart
#

9. What is this

sly girder
#

Yo, ppl. I am currently developing a framework for a better Discord Bot developing experience. Doest someone wants to get know about that framework more, and maybe try that out? πŸ˜ƒ

#

Used lang is JS with Typescript declarations

mossy vine
#

@sly girder sure, dm me

shadow barn
#

dm me too

#

@sly girder

vague chasm
#

Which packages do I need?

lament meteor
#

dblapi.js

vague chasm
#

k

quartz kindle
#

webhook is undefined

vague chasm
#

Oh

#

const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });

#

What will be password? @quartz kindle

quartz kindle
#

webhook authorization

#

in your bot's edit page

lusty dew
#

Hey Tim!

crimson mauve
#

.

#

Hi

vague chasm
#

In the authorization field will be the password?

quartz kindle
#

yes

vague chasm
#

Do I use that link?

#

I created a new webhook for a channel in my guild

late hill
#

You can't use a discord webhook

vague chasm
#

What do I do then?

late hill
#

You have to get your own webserver

#

That can handle the requests

quartz kindle
#

dblapi.js does that already no?

late hill
#

Oh

quartz kindle
#

it should receive requests on port 5000 in your ip address

late hill
#

Yes

quartz kindle
#

you just need to configure your firewall, depending on where you're hosted

late hill
#

Then put your ip as url

#

With port

#

I think