#development

1 messages · Page 904 of 1

shell raptor
#

const Discord = require('discord.js');
const prefix = "*";

module.exports = async(client, message) => {

if(message.author.bot) return;
if(message.channel.type === "dm") return;

if(!message.content.startsWith(prefix)) return;

const args = message.content.slice(prefix.length).trim().split(/ +/g);
const commande = args.shift();

const cmd = client.commands.get(commande);

if(!cmd) return;

cmd.run(client, message, args);

};

split hazel
#

would low port speeds be one cause of your bot constantly reconnecting?
@grizzled raven shouldn't be, unless you have multiple shards/use a lot of network

#

not sure if you're referring to the standard gateway reconnects

shell raptor
#

@quartz kindle

quartz kindle
#

and it sends 5 messages?

shell raptor
#

yes

quartz kindle
#

show your event loader

shell raptor
#

fs.readdir("./Events/", (error, f) => {
if(error) console.log(error);
console.log(${f.length} events en chargement !);

f.forEach((f) => {
    const events = require(`./Events/${f}`);
    const event = f.split(".")[0];

    client.on(event, events.bind(null, client));
});

});

#

this ?

#

oh

#

its done

#

he send 1 msg now

quartz kindle
#

what was the problem ?

shell raptor
#

in the terminal i have 5 "node"

quartz kindle
#

lmao

shell raptor
#

but i delete

grizzled raven
#

well what would cause constant reconnecting/disconnection issues

shell raptor
#

an error ?

earnest phoenix
#

your lib not supporting opcode 9 or blocking gateway code

shell raptor
#

there is french here pls ?

earnest phoenix
#

this guild is english only

shell raptor
#

oh

#

im french me

#

but i have a question

hollow prawn
shell raptor
#

it's "you don't have permission" or "you doesn't have permission" ?

earnest phoenix
#

you don't

shell raptor
#

ok thx

earnest phoenix
#

i dont, you dont, he/she/it doesn't, we dont, you dont, they dont

shell raptor
#

oh

#

thx

#

i remember it

#

"I dont find the person" its correct ?

hollow prawn
#

also "I cant find the person"

shell raptor
#

oh thx

#

its better

sudden geyser
#

"I dont find the person" -> "I do not find the person" wrong.

#

I can't -> correct

shell raptor
#

thx

#

my english is poor

#

:/

sudden geyser
#

it's fine

shell raptor
#

its "has been kicked" or "was kicked" ?

digital ibex
#

hi

shell raptor
#

hi

digital ibex
#
 guild.updateOne({ $set: { 'tag.name': args[0] } });
``` why is this not updating in the db?
#

anyone have any ideas

quartz kindle
#

@shell raptor "has been" is mostly used for something that started and still continues now. "was" is more for something that happened at some point

#

a user was kicked a long time ago, a user has been banned since a long time ago

earnest phoenix
#

hello

#

How do u get the bot dev role?

#

like

#

any dev role

quartz kindle
earnest phoenix
#

ok

grizzled raven
#

your lib not supporting opcode 9 or blocking gateway code
how can i check

quartz kindle
#

are you making a lib?

shell raptor
#

ok thx @quartz kindle

hollow prawn
#

Tim, sorry to ask you this, I don't wanna be intrusive, but I'd run that code in on ready event so I wanna be sure I have the greenlight of someone skilled that I know its correct code that wouldn't cause api spam

grizzled raven
#

bruh i dont feel so good

#

😔

#

can my discord not be bad

quartz kindle
#

change your name to TheLegend27

#

boom, instant pro

grizzled raven
#

😔

#

i wish

#

i honestly just think im not capable of

#

maybe im doing the wrong thing

#

who knows

#

how many members can you fetch ar a time

quartz kindle
#

if you fetch all members, they will come in batches of 1000

#

if you fetch by ids or by name, max 100 per request

#

@hollow prawn show code

grizzled raven
#

okay

#

if you fetch by id, and you pass in one id of a user that isnt in the guild, will all members except that id be fetched, noone be fetched or members before that id be fetched?

quartz kindle
#

none will be fetched

grizzled raven
#

bruh okay

quartz kindle
#

i mean

#

if you pass a list of ids

#

the valid ids will still work i believe

quartz kindle
#

if you pass only one id, then if it doesnt work it doesnt return anything

hollow prawn
#

I had also tagged you in the message

quartz kindle
#

looks alright

cold geyser
#

could somebody tell me how i make an command with will send the text you enter into my dms?

hollow prawn
#

sweet, thanks

cold geyser
#

i have the code itself bit it dosent sends the embed to my dms

quartz kindle
#

show code

#

there is no message.dev

cold geyser
#

i just tested stuff

#

with that message.dev

quartz kindle
#

if dev is you id, you need to use it to obtain your User object, for example client.users.get(dev)

#

then you can send the embed to it

cold geyser
#

ok thx, ill try

#

thx, workes fine now

earnest phoenix
#

is it possible to @ a role or person without pinging them?

split hazel
#

No

#

also please try not to cold ping users

earnest phoenix
#

just wanted to write an example

quartz kindle
#

if youre using discord.js you can disable mentions

#

it will just send the mention as text instead of as mention

#

you can also achieve the same result by adding a zero-width space in between the @ and the text

earnest phoenix
#

ah neat, but the end result i'm looking for is for a bot to ping a role or group on their behalf

#

so i can write @ role in 4 days

#

so the bot can ping the role after 4 days

split hazel
#

Best you can do to mention something, and not ping, is to put it in an embed

hollow prawn
#

^^ that

quartz kindle
#

you want to give the bot a mention so the bot uses it later?

earnest phoenix
#

can users write embeds or am i thinking of something else

split hazel
#

But be aware, discord cache is not forgiving sometimes

earnest phoenix
#

yeah kinda

#

tim

split hazel
#

Normal users can't really do that unless you post a link or something

quartz kindle
#

the only reliable way to do that is to give it the role id

earnest phoenix
#

didn't know roles had ids

quartz kindle
#

for example /remindme 387593795828057203 4 days

#

or something like that

split hazel
#

everything has an id

quartz kindle
#

yes roles have ids

split hazel
#

so they could be uniquely identified despite having multiple similar names

earnest phoenix
#

another naive approach could be checking if an @ has a whitespace after it and remove it, so you can write /remindme @ person 4 days

#

is "everyone" a role with an id?

quartz kindle
#

the everyone role is the guild's id

earnest phoenix
#

my only worry is if the end user could figure that out by themselves

#

i know you can write documentation etc, but far from most reads it.

quartz kindle
#

i know that pain

#

my help command is 700 lines

#

lmao

#

and people still ask basic questions

earnest phoenix
#

can you modify someone's message between them sending it and it being posted?

quartz kindle
#

nope

earnest phoenix
#

so they can write /remindme @ everyone and the bot disabling it before everyone is pinged

quartz kindle
#

can that command be used on roles only or also people?

earnest phoenix
#

would prob be useful for moderation bots

#

on people too

quartz kindle
#

so the only way it would be reliable is by using ids

#

and even then you'd need to check for both roles and users

#

because you wouldnt know what type of id is it

earnest phoenix
#

there wouldn't be a overlap though, right

split hazel
#

and people still ask basic questions
@quartz kindle people don't like reading the help documents or whatever, they just want a quick and instant response kittyNotLikeThis

restive furnace
#

make interactive help menuokeh

earnest phoenix
#

oh right, deleting a single whitespace after every "@" and tell ppl to write @ person wouldn't work either because of nick names

restive furnace
#

nick names shouldnt affect to mentions

earnest phoenix
#

are you sure?

#

because when you @ nicknames they are transformed into @ username

grizzled raven
#

wait yeah i meant by ids

#

so it will only fetch the valid ids and return no error?

quartz kindle
#

@restive furnace i do have an interactive help menu lmao

#

but even that is "too complicated" for them

#

people these days apparently hate reading

#

they all want videos instead of text

#

@earnest phoenix that wouldnt work anyway because usernames sent by bots dont get converted to mentions automatically

#

you can make your bot post @myusername and it will not convert it to a mention

earnest phoenix
#

incorporate natural language understanding into the bot and make it listen for "how do i make x work on bot y"

regal tinsel
#

здесь есть русские???

#

или я один только

slender thistle
#

Ну я же тебе написал, можем в #memes-and-media спокойно поговорить...

viral spade
#

@quartz kindle holy man can you give me your advice pls once again.

I am hosting 16k servers for 18 Euro per month which is an ok price for me. it is a linux vps at vpsdime with 18gb memory. Currently both, cpu and memory are at their limits like this. i know i can further cut down the cost by doing stuff like add zlib or reduce the cached information.

But beside this i wanted to ask:

  1. Would you rather get a better vps now and try reach more servers per vps, or go directly into a new one and start the bot on different machines? I am considering a hetzner 40€/m, which should be more than double as good as my current vps (in terms or ram and cpu).

  2. When using second method and start using the bot on multiple machines, how can i best manage all this? i know there is kubernetes or docker swarm (the bot is running in a docker), but am not sure if its an overkill. How do most people manage multiple machines and ensure every shard is running on one vps only and always?

quartz kindle
#

i would go for reducing resource usage first

viral spade
#

i know, but besides this?

modest maple
#

18gb ram usage for 16k server oof

#

thats fucking way too much

#

we're using 5.2GB for 54k guilds

quartz kindle
#

running a bot on multiple machines requires careful orchestration, because you cannot connect more than one shard every 5 seconds globally, and rest rate limits are also global, so each shards would have no idea how much the other shards are using, then they are busy connecting or not

viral spade
#

well its statistics bot, lots of data, all in ram

quartz kindle
#

of course you can just catch the errors and retry

modest maple
#

why is it all in ram.....

viral spade
#

because ram is faster lel

modest maple
#

stop doing that lol

#

thats really really bad

viral spade
#

why?

quartz kindle
#

its not bad, just a waste of money, electricity and resources

modest maple
#

^

#

considering a simple DB would pose minimal latency and save litterally GB of ram

quartz kindle
#

you have a bot that collects a huge amount of statistics, right? so it is safe to assume that it collects way more than it needs to retrieve, correct?

viral spade
#

not really, because every write of stats causes multiple reads. Whenever 1 message is written, all that users stats are calculated to check if there was a levelup and other stuff.

modest maple
#

then use a db lol

viral spade
#

i am using a db, in memory

modest maple
#

no

#

dont do that

#

that is why ur shit is so high in load

viral spade
#

i have more troubles with cpu than with ram

#

and the cpu work comes from the in memory database

#

where is calculates a lot of stuff

modest maple
#

use a database then

#

put it this way

#

my server that is currently at 460 requests a second, and about 2000+ db querys a sec stays under 5ms response time easily

#

having shit in ram makes very little diffrence alot of the time

#

and looking at your bot and what it does, IDK wtf you're doing but that should not be so CPU and RAM intensive

#

somthing like SQL can do ALOT of stuff and alot of the work for you

restive furnace
#

postgres can hold smh 500k req per sec

viral spade
#

i am doing most of it in sql

quartz kindle
#

perhaps you'd need a complete redesign of its structure in order to optimize for your use case

viral spade
#

all stats calculation is in sql

modest maple
#

yh seems like you need to redesign that then

viral spade
#

but how

modest maple
#

cuz im sorry but 18GB and Really high fucking cpu usage at 16k guilds is just too far

viral spade
#

i feel like using the least possible information to do what i want

earnest phoenix
#

Added a command so u can add ur spotify playlist to the music queue on my bot

modest maple
#

why arent you doing that to begin with

astral yoke
#

ok

regal tinsel
#

+act

astral yoke
#

^

viral spade
#

i mean i am already

modest maple
#

somehow i doubt that

#

as i just cannot believe that tracking voice activity, message events and some other stuff is using that much

#

unless you have some god damn awful optimisation

viral spade
#

what exactly do you mean by optimization?

#

stuff like zlib and reducing cache size?

modest maple
#

doing shit efficiently, like not storing everything in ram

#

it doesnt help already that d.js is a cache shit show

viral spade
#

you know with one button i make everything go saved onto the drive. i havent tried it for months now because it was slow.

#

but i will try now

modest maple
#

what do you intend todo

viral spade
#

just try saving od the drive, instead of in memory, like you said

modest maple
#

stop right there

#

what do you intend to use to save stuff to drive

#

what do you intend todo exactly

viral spade
#

I change my mysql database engine from MEMORY to INNODB, it takes one replace command and a bot restart to change the way its saved

#

in my docker init script

modest maple
#

First: Yeet mysql its slow a shit
Second: If you're running the db itself in memory (Which btw is only normally supposed to be for testing), How are you saving / backing up the data

viral spade
#

data is backed up differentially to a remote database

#

basically everything is set up to be sharded on 2 different pcs

#

from this backup the information is also retrieved when first encountering a guild in a shard on demand

serene cliff
#

is there anyway to force discord to clear client cache with bot? intention is just showing bandwidth graphic. the image itself auto updates with the new graph but once client cache the images it stays there quite a while

nimble escarp
#

How are you sending the image? Is it an attachment or is it url to the image?

serene cliff
#

url

nimble escarp
#

Well I don't know how Discord caching works, but you could try bypassing the cache with GET params.
Basically the idea is that you'd replace the url with a different GET param whenever you want to refresh.
Normally in browsers it works because the browser thinks it's a new image since it's a new URL but the new URL points to the same path (just a different parameter).

quartz kindle
#

^

nimble escarp
#

Not really sure if it'll work with Discord but I'd try that idea first.

quartz kindle
#

static content is cached client side by their path name

#

if you change the path by changing the file name or appending some query param to it, it will invalidate/bypass the cache

heavy marsh
serene cliff
#

thanks.
that works

nimble escarp
#

@heavy marsh Invite owner (the person who created the invite) is not exposed by Discord API but you can check if the invite is temporary by accessing .expiresAt property of an Invite.

heavy marsh
#
embed.setThumbnail(invite.guild.iconURL);
#

Why doesnt this work?

nimble escarp
#

Try printing out .iconURL (in console) first and you'll see.

grizzled raven
#

does postgre take more or less the same queries as sql/ite?

nimble escarp
#

more or less pepeshrug
Not really 100% sure since I last used sqlite some time ago but as far as I remember it's pretty similar to psql (as well as mysql to an extent)

quartz kindle
#

they should be 99% interchangeable

earnest phoenix
#

is it possible to do something like
(string1+string2).length?

#

compared to string1.lenght+string2.length

#

(s1+s2).length works

heavy marsh
#

@nimble escarp does invalid date mean it doesn't expire

#

Also I did console.log for .iconURL
It comes as undefined

nimble escarp
#

then that's the problem

quartz kindle
#

@earnest phoenix string1.length + string2.length is more efficient tho xd

nimble escarp
#

As far as I know .guild is not guaranteed to exist on an Invite.

heavy marsh
#

But how?
Cause invite.guild.iconURL

nimble escarp
#

The only guaranteed properties are code, channel, and url. Other properties can be missing.
https://discord.js.org/#/docs/main/stable/class/Invite

heavy marsh
#

But I did invite.guild.id and it worked

nimble escarp
#

Oh, my bad.
.iconURL is a method
.icon is a property

heavy marsh
#

Ooh so it's invite.guild.iconURL()

fleet jay
#

.help

heavy marsh
fleet jay
nimble escarp
#

yeah, you can supply an object as options
{format: string, dynamic: bool, size: number }

heavy marsh
#

But I am using v11.4.8 and not v12

fleet jay
heavy marsh
#

Don't repost the same problem read the channel topic

dusty onyx
#

yo, what’s the code you’d use to find all members in every server your bot is in in python? i have it for guilds but can’t find it for members 👀💧

#

not specific, just the number

nimble escarp
#

Oh, again. My bad again @heavy marsh
.iconURL should still be a property then pepeThinkingHmmmm try getting .icon

heavy marsh
#

Will that not give just the string ThinkingGlobal

#

Ok nvm I will form my own url lol

nimble escarp
#

It will, but it's better than nothing if it's throwing undefined for iconURLpepeshrug

vestal star
#

Hey I can't set any div.content properties in my description any fixes?

heavy marsh
#

Ok I will test that then

#

Also does undefined date mean the link will not expire?

#

Invaild date*

feral heath
#

@vestal star what are you trying to do?

vestal star
#

Set background

nimble escarp
#

No idea @heavy marsh you need to test it out. Never used it.

heavy marsh
#

😄 ok thanks

feral heath
#

Can I see your css

tender cedar
#

Hi I have a question, Its about the website not really codding but idk where to post so tell me If I should go to another channel
am I allowed to include like a donation paypal link on the bot's page?

split hazel
#

Yes @tender cedar

tender cedar
#

thanks ^^

vestal star
#

My css is just .content { background: x; }

feral heath
#

well as long as x is a valid colour it should work

#

Have you tried a ctrl shift r

#

just incase its the cache messing it up

#

ohhh

#

You might want an !important on that

#
.content { background: x !important; } 
surreal notch
#

how to minus the balance from someone account if he have credits i m using discord.js v12 quick.db

#

for that

earnest phoenix
#

what does this mean ```js
let gmt = parseInt(message.content.slice((prefix+cmd2).length))
^^^

SyntaxError: Lexical declaration cannot appear in a single-statement context

feral heath
#

Uhh my javascript is kinda rusty but I think you can only use let in some sort of block

nimble escarp
earnest phoenix
#

some sort of block?

feral heath
#

Yeah so within a function or method

#

or just a {]

#

{}

marble juniper
#
if (condition) let example = "test"

this above wouldn't work

let example;
if (condition) example = "test"

this would work

earnest phoenix
#

is parseInt a condition?

marble juniper
#

can u show the code where you define the variables

earnest phoenix
#

i understand that example, link bit i don't see understand why it wouldn't work in my case

marble juniper
#

*variable

earnest phoenix
#
    let gmt = parseInt(message.content.slice((prefix+cmd2).length))
    ^^^

SyntaxError: Lexical declaration cannot appear in a single-statement context
#

the def of prefix, cmd?

marble juniper
#

wait a min

nimble escarp
#

you can try using var

marble juniper
#

or that

#

try that

earnest phoenix
#

what

#

why would that make a difference

marble juniper
#

im kinda stupid today

#

just try it ok

earnest phoenix
#

why does it work?

nimble escarp
#

Since let and const can only be defined in blocks pepeshrug

earnest phoenix
#

with var and not let

#

but const doesnt have to be defined in a block?

#

const x = require("module"), isn't a block?

nimble escarp
#

Constants are block-scoped, much like variables defined using the let keyword. The value of a constant can't be changed through reassignment, and it can't be redeclared.

The let statement declares a block-scoped local variable, optionally initializing it to a value.

quartz kindle
#

what are you trying to do?

earnest phoenix
#

omg

#

it's because i forgot to add brackets in the above "else if"

nimble escarp
#

oh yeah, makes sense

quartz kindle
#

lul

nimble escarp
#

Because then there is no block for the variables.

digital ibex
#

hi, anyone know why i'm getting this error: MongoError: Cannot create field 'name' in element {tags: [ "create" ]}?

#

code: await guild.updateOne({ $addToSet: { 'tags.name': args[4] }})

regal jacinth
#

hey how do i make my bot so that it doesn't need the Manage_Messages permissions to edit the embed in my help cmd

digital ibex
#

u can't

regal jacinth
#

@ember atlas sooo someone said i can't

ember atlas
#

@digital ibex A bot does not need manage messages to edit it's own messages

digital ibex
#

your bot will always need perms and u can't change that

ember atlas
#

Just like regular discord users don't need manage messages to edit their own messages

#

What

digital ibex
#

oh, idk about perms to edit messages

ember atlas
#

Well then read the question and if you do not know the answer then don't answer

digital ibex
#

i was saying u can't do anything about it

#

chill

regal jacinth
#

;-;

ember atlas
#

Just show the code @regal jacinth

regal jacinth
quartz kindle
#

@stuck scaffold you tried to do something to a shard that died or didnt spawn yet

ember atlas
#

@digital ibex I am just telling you that you don't need manage messages to edit your own message

regal jacinth
#

here

ember atlas
#

For future inquiries and etc

digital ibex
#

ok

stuck scaffold
#

where I need to fix?

#

setTimeout ?

regal jacinth
#

so anyone can help me ?

quartz kindle
#

@stuck scaffold did you require("dblapi.js")?

#

ah nvm i see it now

#

i dont know, looks ok there

digital ibex
#

@regal jacinth show ur code

cold geyser
#

is there any way to list all the servers/server ids where my bot is on?

regal jacinth
digital ibex
#

ok

regal jacinth
#

it's in here

#

it's safe

digital ibex
#

<client>.guilds.map((e) => e.name + ' | ' + e.id) devsin_666

#

ok

cold geyser
#

ight thx

regal jacinth
#

;-;

digital ibex
#

i don't know py

#

sorry

earnest phoenix
#

what do you guys think about using reactions to let users know their command was understood and successfully executed?

regal jacinth
#

its okay

#

any body know about python ?

cold geyser
#

@digital ibex is there any possiblity to make an space between the server names?

regal jacinth
#

yes

digital ibex
#

yes...

regal jacinth
#

just add space between the |

#

' | "

cold geyser
#
Reby Testing | 704783186504450098```
#

i mean so therews an space between them

regal jacinth
#

can ui edit it to what u want

#

btw idk anything about js

#

XD

cold geyser
#

ight XD

#

Reby Testing | 704783186504450098```
#

so it whoul look like this

regal jacinth
#

oh

quartz kindle
#

what does it look like now?

regal jacinth
#

do u use \n in js ?

quartz kindle
#

oh you mean vertically

cold geyser
#
Reby Testing | 704783186504450098```

@quartz kindle

quartz kindle
#

then yes add an \n

cold geyser
#

oh lol

regal jacinth
#

lol

#

soooooo someone help ;-;

quartz kindle
#

i dont py

regal jacinth
#

i don't js

#

lol okay

#

soooooo someone ||who does py|| help ;-;

modest maple
#

what is ur issue...

#

we cant help if we dont know

fleet chasm
#

just ask

regal jacinth
#

hey how do i make my bot so that it doesn't need the Manage_Messages permissions to edit the embed in my help cmd

#

@modest maple sorry for the ping

#

the help cmd

#

it's safe

#

;-;

hollow prawn
#

it shouldn't need it to edit its own message

regal jacinth
#

well boss said i don't

#

it doesn't need it

hollow prawn
#

i did a typo lol, when you edit your own message here in discord in any server you dont need manage messages, that's for deleting other people's messages iirc, pinning as well and 1 more thing cant remember for sure

stuck scaffold
regal jacinth
#

well how do i fix that

hollow prawn
#

by simply editing your message after the bot gets the awaited reaction, oh manage messages is needed to clear a reaction from message as well I think, so just dont clear the reactions and after a change of page, await new reactions

regal jacinth
#

hmm so i remove the clear reaction and do what? ;-;

#

Iam new in python

#

kinda

hollow prawn
#

oh idk about python but discord js language, in any case, you comment out the code for clearing reaction and move on to the next step
so:
embed message sent > add reactions to it > await for reaction > got a reaction, changing page > removed (/ clear reaction /)> await reaction again > change page > await again and so on and so forth

carmine magnet
regal jacinth
#

@hollow prawn ty sm

sudden geyser
#

The guild owner may not be cached in large guilds.

carmine magnet
#

Oof ok

sudden geyser
#

You should fetch the owner if server.owner is not present.

#

Also make sure you charge your phone.

carmine magnet
#

Lol

earnest phoenix
#

how can i add custom css to my bot page on top.gg

fleet chasm
#

style tag

earnest phoenix
#

where

feral heath
#

anywhere

vestal star
#

Donkey, what did you write your bot on?

feral heath
#

.net c#

vestal star
#

Noice

#

I'm am currently making my bot in djs but may switch to Eris (still nodejs) should I switch to anathor language?

feral heath
#

Write with whatever you're most comfortable with

#

Or whatever you need to get the job done

vestal star
#

What should I write in tho?

feral heath
#

I use .net because I'm familiar with the database stuff

#

Whatever you want dude

#

Write it in assembly if you really want to

vestal star
#

Xd

#

I'll try lol

regal jacinth
#

@hollow prawn i still get the error with need perrmissions

#
  eh = await ctx.send(embed=embed1)
    await eh.add_reaction('\U00002B05')
    await eh.add_reaction('\U000027A1')

    embed2=discord.Embed(title='Roles', description=" | ".join([r.name for r in ctx.guild.roles]), colour=discord.Colour.blue())
    embed2.add_field(name='Total Roles Nmber', value=str(total_roles_counter) + ' roles')
    embed_dict = {1: embed1, 2: embed2}
    flag = True
    pn = 1

    def check(reaction, user):
        return user == ctx.author and (str(reaction) == "\U000027A1" or str(reaction) == "\U00002B05")

    while flag:
        try:
            reaction, user = await client.wait_for("reaction_add", check=check)
        except:
            raise error
        else:
            if str(reaction) == "\U000027A1":
                e = embed_dict.get(pn + 1)
                if e:

                    await eh.edit(embed=e)
                    await eh.add_reaction('\U00002B05')
                    await eh.add_reaction('\U000027A1')
                    pn += 1
            elif str(reaction) == "\U00002B05":
                e = embed_dict.get(pn - 1)
                if e:

                    await eh.edit(embed=e)
                    await eh.add_reaction('\U00002B05')
                    await eh.add_reaction('\U000027A1')
                    pn -= 1

            else:
                await eh.delete()
                flag = False
``` this is a part of the cmd where i can change pages by reacting to it , but when i test the reaction thing with 0 perms i get an error ```discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
earnest phoenix
#

nvm did

regal jacinth
#

?

hollow prawn
#

with 0 perms of course, you wanted to not use manage messages
however you still use the embed_links which is also for embed messages

#

@regal jacinth

regal jacinth
#

hmmmm

#

but here they test the bots with 0 perms

#

so

#

oh wait

#

i added the embed links perms

wet dove
#

they will give it the required perms

regal jacinth
#

still

#

the same error

#

well i got declined 3 times cuz of it

#

they told me to fix the Manage_Messages perrmissions that the bot doesn't need

hollow prawn
#

thats interesting, mine did need it on some commands, but it isnt 100% necessary to be functional

regal jacinth
#

yeah they said that the help cmd doesn't need it

hollow prawn
#

you could make the reaction delete optional and before it does a clear reactions to check if ith as the permission, if not to jump a step that'll make it optional but no necessary, embed links should be working properly for embedding a message

regal jacinth
hollow prawn
#

also apparently you don't need to add reactions again after you edit your message (havent tested it on a bot, but a message sent from me in my server for testing)
what I said on that was:
answer to help command > add reaction > await reaction > check if bot has permission manage_messages to clear reaction, if not skip to next step > change page > await reaction > check for permission > and so on and so forth

regal jacinth
#

oh

#

okay

neat ingot
#

so, i just rented a basic vps (hosted in usa) from contabo to test it out for hosting the bot things, put a basic bot on there to test it out, see what pings were like and such. seem pretty reasonable to me, and are a huge improvement over the digital ocean server my bots on atm (hosted in london)

#

and as far as i can tell, they genuinely have given me 4 core, 8gb ram, 200gb of ssd storage, and a 200mb per sec up and download speedds on the internet, for 5 euro a month 😮

pale vessel
#

#shamelessplug

neat ingot
#

how is that a plug? lol

pale vessel
#

joke

split hazel
#

contabo is known for squashing about 90k users into one server to get maximum money

neat ingot
#

yea i thought they would do something like that too

split hazel
#

they're a sketchy company anyway but they work so

neat ingot
#

but as far as my initial tests can tell, all the resources they claimed are available for my using

#

and the response time on the bot is pretty swift

#

im gonna leave that dummy bot there for a few days to see how stable it is

split hazel
#

some people complained about getting slower speeds later on

neat ingot
#

yea, i was thinking they might have a newbie bonus perk thing going on, so i dont immediately hate them 😄

modest maple
#

tbf Contabo is good

#

their VPS' are fine tbf

#

steal can be a lil high at times

regal jacinth
#

tbf?

#

to be fuck?

modest maple
#

but the price is amazing considering its £15 a month for USA VPS

#

to be fair

regal jacinth
#

oh

#

my mind

#

went so far

neat ingot
#

yea, i figured for the price they ask, its worth trying for a month or two

#

for the same resources from my current host i'd like $40 a month

#

vs 10 on contabo

modest maple
#

yh

#

like for the same price

#

you can get more specs overall

hazy jungle
#

How do you get your bot verified?

modest maple
#

even with steal

neat ingot
#

yea for sure, and if you expect some of the resources to be 'stolen' just get a little more power for an extra 5$ 😄

hazy jungle
#

How do you get your bot verified?
@hazy jungle

oblique kettle
#

While my music bot plays music, the sound sounds a bit scratchy and bad. How can I fix it?

oak cliff
#

-verifybot @hazy jungle

gilded plankBOT
#

@hazy jungle

Hi! It seems like you are looking for information on how to get your bot verified.

Once your bot reaches 75 servers or more, you are eligible for bot verification. On October 7, 2020, bots with 100 servers or more that are not verified will not be able to be invited to any more servers. You verify your bot on your bot's application page, under the "Bot" section in the sidebar.

If you need more information, check out this article written by Discord about The Future of Bots on Discord and you can ask questions in the Discord Developer Server.

We cannot provide support on how to get your bot verified.

west spoke
#

@oblique kettle what are the specs of your VPS

oblique kettle
#

@west spoke Do you have a site that you recommend

west spoke
#

check pins

delicate zephyr
#

-vps @oblique kettle

gilded plankBOT
#

@oblique kettle

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

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

west spoke
#

ty luke

#

ily

earnest phoenix
#

i was thinking I change this message.channel.send('there was an error trying to execute that command!'); to console.log('There was an error executing a command in a guild, please keep an eye on logs to fix this issue (most likely execution issue)'); Thoughts?

quartz kindle
#

depends

hazy jungle
#

2 questions how do I see how many servers my bot is on, and how do I put my bot on github without revealing the token

quartz kindle
#

if its an error the user doesnt need to know, the second
if its an error the user needs to know because the user did something wrong, the first

earnest phoenix
#

@hazy jungle use a DOTENV

#

or a .env file

quartz kindle
#

use a .gitignore file

hazy jungle
#

How do I do that

#

New to github

quartz kindle
#

do you use a git software like github desktop?

hazy jungle
#

Yes

quartz kindle
#

create a .gitignore file, and type the names of the files you want github to ignore

earnest phoenix
#

you should put your token on a separate file and then .gitignore it

hazy jungle
#

Thank you

quartz kindle
#

yes

earnest phoenix
#

unless you wanna hide your code aswell

hazy jungle
#

Wait what do you mean

#

Make a copy?

pale vessel
#

.nowignore mmLol

earnest phoenix
#

something like this

quartz kindle
#

if your token is in your main file, create a new file for it

#

like a config.json file or something similar

#

and then add it to .gitignore

hazy jungle
#

Oh I already have that

quartz kindle
#

all files and folders written in the gitignore file will not be published on github

earnest phoenix
#

const token = require("./config").token and your config file would be where your bot token is

quartz kindle
#

when you open your github desktop, it will show you exactly what will be published

#

so just confirm that you config file is not there, before pushing

earnest phoenix
#

if you don't gitignore your node modules, DO NOT PUSH THAT

valid gyro
#

@oblique kettle my bot runs on glitch.com, theres some extra coding u have to do to get it to work, but when you do it works great

hazy jungle
#

Node modules?

oblique kettle
#

@valid gyro what

earnest phoenix
#

if you're starting fresh, you'll need node modules later

valid gyro
#

for running a bot

oblique kettle
#

music bot @valid gyro

earnest phoenix
#

they're kinda like plugins

valid gyro
#

yeah im talking hosting

hazy jungle
#

like discord.js

valid gyro
#

werent u the guy who asked about that

quartz kindle
#

the node_modules folder doesnt need to go on github

earnest phoenix
#

not at all

quartz kindle
#

its a waste of space and bandwidth

hazy jungle
#

I put my file in the .gitignore and it did nothing(its still on private mode tho)

#

bottem line

quartz kindle
#

the gitignore file will not remove it if its already on github, it will just prevent it to be added to github

#

you should make a new repository

#

dont make the private one public

earnest phoenix
#

^

quartz kindle
#

else all change history will be available to the public, including deleted files

#

make a new repo, open it in github desktop, and push it from github desktop

earnest phoenix
#

help

quartz kindle
hazy jungle
#

Just realized I can’t make a new repository, because I have heruko what should I do

quartz kindle
#

why cant you?

#

heroku doesnt stop you from using github

hazy jungle
#

It’s linked to my repository and it took me like 6 hours to set up and I don’t want to do that again

quartz kindle
#

i mean, why exactly do you want to create a public repo for your bot?

hazy jungle
#

Try to get people to use my bot, it’s no verified so most people ask to look at the github

quartz kindle
#

does heroku have a way to add/load files from outside of github?

hazy jungle
#

No clue

quartz kindle
#

because if you publish your bot on github, and use that on heroku, it will not have a token

hazy jungle
#

Might just have to make 75 servers to get my bot verified 😂

quartz kindle
#

you can simply have 2 repos, a public one for the public parts of your bot, and a private one to use with heroku

hazy jungle
#

True

#

I will do that

quartz kindle
#

you dont even need to make all of your code open source

#

my only bot github only has docs lol

#

my other bots dont even have githubs

hazy jungle
#

what sucks i will always have to use github because i have two houses

clear wraith
#

What did i do wrong here... It says this for my c!ticket command.

#

Let me know if you need the code

quartz kindle
#

.exists doesnt exist lol

earnest phoenix
#

lol

clear wraith
#

SO... That doesn't need to be in there?

quartz kindle
#

i dont know what you want to do

clear wraith
#

Ill get the code

earnest phoenix
#

if message.guild.channels not None maybe?

#

don't know what you're trying to do

#

kinda weird though

clear wraith
#

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

const fs = require('fs');
const util = require('util')

var current_date=new Date();

module.exports = {
name: "ticket",
category: "moderation",
description: "Opens A Ticket",
run: async (client, message, args) => {
const reason = message.content.split(" ").slice(1).join(" ");
var tAuthor = message.author.tag
if (message.guild.channels.exists("name", "ticket-" + message.author.tag)) return message.reply(You already have an application open.);
message.guild.createChannel(ticket-${message.author.tag}, "text").then(c => {
let role = message.guild.roles.find("name", ticket);
let role2 = message.guild.roles.find("name", "@everyone");
c.overwritePermissions(role, {
SEND_MESSAGES: true,
READ_MESSAGES: true
});
c.overwritePermissions(role2, {
SEND_MESSAGES: false,
READ_MESSAGES: false
});
c.overwritePermissions(message.author, {
SEND_MESSAGES: true,
READ_MESSAGES: true
});
c.setParent(566427452528787456)
message.reply(:white_check_mark: Your application has been created, #${c.name}.);
c.send(Thank you for opening a ticket! How can we help?);
//client.channels.get(config.logs).send(:white_check_mark: !!!Ticket Created ${message.author} at **${current_date}**);
}).catch(console.error);

}

};

#

Line 15

quartz kindle
#

so you want to check if a channel with a specific name exists

clear wraith
#

yes

quartz kindle
#

if you're using v11

clear wraith
#

Im using v12

quartz kindle
#

then you have more problems

clear wraith
#

lol

#

rip

quartz kindle
#

channels.cache.find()
roles.cache.find()

#

guild.channels.create()

#

overwritePermissions is also different

clear wraith
#

Ok

grizzled raven
#
console.log(require("../classes"), require("./"), require("./Toggle.js"), require("./index.js"))
// returns: {} {} [Function: Toggler] {}
``` why?
#

ignore all the stupidity imcool

#

this makes no sense

viral spade
#

So Tim i changed the database from memory to Innodb and ofc the memory usage is lower now, but interestingly also the cpu usage seems to do better.
Still horrible stats for a bot (16K servers, on a 18€/month vps)? Like this it looks like it could handle double the servers. Where would you optimize next?

#

a lot of my cpu usage comes from calculations in sql, performed by the db. Do you think zlib can anyways give me a good cpu speedup?

grizzled raven
#

oh wait i think ik why

quartz kindle
#

since discord.js removed pako, zlib-sync wont necessarily reduce your cpu usage, it does however massively reduce bandwidth usage

#

you can try it nonetheless, and also the other optional libs, such as bufferutil, and utf-8-validate

viral spade
#

so when i add them to my package.json and do an npm install, it should work out of the box? discord.js will recognize its installed?

quartz kindle
#

yes

#

other than that, i'd look at your sql queries

#

are you using transactions?

viral spade
#

no

quartz kindle
#

i'd look into them

viral spade
#

i have used them

#

but not for this project. i did not feel i need them semantically

#

but i can save cpu with them?

quartz kindle
#

yes, most likely, specially if you can group together several queries into a single transaction

#

another thing i would do, make an in-memory cache for the hottest data you process, and dump it into sql in batches

#

for example collect updates for about 5 seconds, then write them all in one query, rinse and repeat

viral spade
#

that sounds good.

you know i think the most expensive thing is the calculation of the users experience, wherever a message is written. It will calculate the xp before and after. This means retrieving possibly hundrets of rows from channels, sum them up, multiply each type of stat with the respective xp value, determine the xp needed for the next level, based on the set up level speed. I do this every message/minute for each user, which understandably is a lot to calculate every second. But grouping it would reduce it drastically no question. However, the way it is now, a user gets thier level message/role/whatever the exact moment that he writes the message that lets him level up.

quartz kindle
#

keep a copy of the most important stats in memory all time

#

for example, the amout of xp the user needs to levelup,

#

that way you can always check against that before checking the database

#

the hottest data should always be in a memory cache

#

everything that is accessed very frequently

#

and you dont need all of it, only the parts of it that you need to compare to often

viral spade
#

well the level speed is in my guild variable thats retrieved when first determining if the message has the bots prefix or not

#

so i have it anyways

quartz kindle
#

yes

viral spade
#

also, putting all my data in a memory cache means 16gb instead of 8gb for the bot in total

quartz kindle
#

when companies get to the point of moving thousands of queries per second, the only way forward is caching and eventual consistency

#

you dont need all of it, just some selected parts

#

you can find a way of optimizing that as well

viral spade
#

so what parts would that be?

quartz kindle
#

i wouldnt know without seeing your code

viral spade
#

basically what causes most cpu is think is this. On message:

quartz kindle
#

another possibility is what kind of data you're using, for example if you're storing lots of strings and serialized json objects

viral spade
#

all ints

#

int and datetime

quartz kindle
#

is each of those lines a db query?

viral spade
#

get scores and add scores yes

#

every freaking message this gets fired 2x

#

also all the time for adding voice scores

quartz kindle
#

why do you need voicerank when adding text score?

viral spade
#

i need to get the totalscore to determine if the user leveled up

#

totalscore is only a derived value

quartz kindle
#

so they level up by combined score of everything?

viral spade
#

yes

quartz kindle
#

so why not store the combined score as an independent value?

viral spade
#

because when a serveradmin changes xppervalue or levelfactor (level speed) then the independent value is false, the derived is always true. So i would have to rotate over all users and calculate all totalscores for everyone anew , when the admin changes settings.

quartz kindle
#

changing the admin settings changes the score retroactively?

viral spade
#

yes

#

everything is derived

#

so that causes a lot of cpu

quartz kindle
#

i would still keep it as an independent value

viral spade
#

i thought of it when i first made it but decided against it

#

maybe i will change it

quartz kindle
#

the admin changing the score factors is a rare event, its well worth the extra work to update everything in exchange for lessening the load on almost everything else
other than that nothing is stopping you from keeping both, an individual score and a combined score. when activity happens, calculate how much its worth, add to the combined score and add to the individual score. if the admins change it, recalculate all individual scores and replace the combined score with the new value, and continue from there

#

that along with transactions to write multiple things at once, and keeping a copy of the combined score in the User/Member object for fast lookup

viral spade
#

yes i was also thinking about that, but unsure if it would actually be worth the hassle. You think it would save a lot cpu? So to replace the big getGuildMemberTotalScore query with a simple getter of that precalculated value?

quartz kindle
#

yes

#

thats the way almost everything works

#

for example discord.js keeping a cached copy of something so it can fast-compare it when it receives an update (kind of a bad example because discord.js actually has no choice lol)

viral spade
#

very good to know. thank you so much. to sum up i will

  1. Install node packages.
  2. Try to make transactions.
  3. Try to cache important info in memory.
  4. Make totalScore independent precalculated value.

did i miss anything? Also i wanted to ask, you said some serious orchestration has to be done for starting a bot on multiple machines, what did you speak of, kubernetes?

quartz kindle
#

a central process is needed to coordinate everything

#

each process will need to connect to the central process over network, and obtain an authorization to connect to the gateway, because otherwise multiple shards can try to connect at the same time and be rejected by discord

#

the same thing for REST rate limits, one shard can use rate limits from another shard if there is any kind of cross-guild/cross-channel requests

#

and they wont be aware of each others' rate limits

earnest phoenix
heavy anchor
#

Good luck

quartz kindle
#

of course you can just ignore all that and do things manually, and catch a few rate limit errors here and there

#

first thing would be if you have 10 shards in one machine, you need to wait 1 minute before you can turn it on in the other machine, to let all the shards finish connecting

viral spade
#

sure but i mean all i have to do is ensure every machine gets the same totalShards value and the right shardsList. thats it, no?

quartz kindle
#

yes

clear wraith
#

**I have an error saying something about how the file is not a database: **
(node:562) UnhandledPromiseRejectionWarning: SqliteError: file is not a database

#
const db = require('quick.db')
const Discord = require('discord.js')

module.exports.run = async(client, message, args) => {
  let maximumamount = "100" //Here is the maximum ammount of money we will get for doing work
  let money = db.fetch(`money_${message.author.id}`) //This will check if the user has money or not
  let random = Math.floor(Math.random()*maximumamount) //This will give us a random amount of money within 100
  if(!money) { //if we didn't start yet, this would create an account for you or the user
    db.set("money_" + message.author.id, random)
    message.channel.send(`You worked and recieved $${random} from the BOSS`) //This will be sent the channel where the user worked
  } else { //If we have already worked then it will add money to our account 
    db.add("money_" + message.author.id, random)
    message.channel.send(`You worked and recieved $${random} from the BOSS`)
  }
  
}

module.exports.help = {
    name: "work",
    aliases: ["c!work"]
}
#

**I thought... const db = require('quick.db')
made the file a database??

#

So what am I missing...

quartz kindle
#

it will make a new file if you delete it

clear wraith
#

what do i need to do to make this a database?

#

or is it already a db

quartz kindle
#

do you have an existing file?

clear wraith
#

for the work command?

quartz kindle
#

quick.db creates a json.sqlite file

#

if you have a json.sqlite file already, before installing quick.db, you will need to delete it as its most likely not compatible

clear wraith
#

So i need to delete it?

#

This was in the json.sqlite file:

��:YtablejsonjsonCREATE TABLE json (ID TEXT, json TEXT)

��
n ����a;
�
R
�
u
&���_< =money_461914901624127489131.0!=money_534589798267224065-322.0!=money_566759316380450837-144.0)?'weekly_3709201411119513601584827875186(='daily_3709201411119513601584827870441*A'monthly_3709201411119513601584827862499!=money_3709201411119513603937.0*A'monthly_6460249327355822351584827832577!
=money_6460249327355822354390.0)?'weekly_6460249327355822351584827826992(='daily_6460249327355822351584827821508O�money_461914901624127489{}*A'monthly_4372750883503472741584759913774!=money_4372750883503472745153.0$Cmoney_@hidden magnet5000.0$
Cmoney_@neon gate5000.0O!money_46191490162412748994.0 =money_591494845856481299260.0(='daily_6073115811261972501584758394619*A'monthly_6073115811261972501584756816173)?'weekly_4372750883503472741584756514925��daily_646024932735582235{})?'weekly_6073115811261972501584756488630 weekly_370920141111951360{}"=money_60731158112619725021844.0     =money_601779047160217600267.0
#

idk if i need it or not

earnest phoenix
#

????

viral spade
#

Another question tim. So almost everyday already someone joins my support server and writes an overwhelming good feedback, comparing with other leveling bots like meee6. i wonder does this mean anything, does this happen to any crap bot, are these people "putting me in a bubble"?

clear wraith
#

They do that crap a lot @viral spade, I always have people joining my support server, and give negative feedback since its a new bot unlike the popular bots.

viral spade
#

i mean i only get overwhelmingly good feedback

#

like they trying to troll me..

clear wraith
#

Oh... Well thats better than what I get, lol

earnest phoenix
#

why does voicechannel and voice.channel come back undefined? here's code:

    const voiceChannel = message.member.voice.channel;
    if (!voiceChannel) return message.reply("You are not in a voice channel, please join one first!")
      (message.member !== undefined)
summer torrent
#

console.log(message.member.voice)

clear wraith
#

^

earnest phoenix
#
    at Object.execute (C:\Users\jjpla\OneDrive\Documents\GitHub\disc-bot-rep\commands\play.js:12:41)
    at Client.<anonymous> (C:\Users\jjpla\OneDrive\Documents\GitHub\disc-bot-rep\bot.js:47:21)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:9372) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:9372) [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.```
summer torrent
#

can you log message ?

earnest phoenix
#

yes

#

gives back the same thing

digital ibex
#

hi, how can i create reaction collector with eris?

clear wraith
#

wait im getting this error:
(node:8497) UnhandledPromiseRejectionWarning: TypeError: message.mentions.first is not a function

#

Why?

#

Im pretty sure i did everything right but i get this error

earnest phoenix
#

I think you should use a variable

#

and set it to

#

so like

clear wraith
#

let user = message.mentions.first() || message.author
It says this is the error

#

what am i missing?

earnest phoenix
#

var member = message.mentions.members.first()

#

try that

digital ibex
#

u r doing let user = member || user Thonk

#

will that work

earnest phoenix
#

member and user have to be defined

digital ibex
#

what

earnest phoenix
#

if you do that member and user have to be defined

clear wraith
#

ok, lemme try

digital ibex
#

no thats not what i meant

obtuse wind
#

is there a way to blacklist your public bot on certain servers

digital ibex
#

yes

#

u'll need a db

earnest phoenix
#

database : D

digital ibex
#

member and user are total different things

obtuse wind
#

IK but like, if my bot is added to a server its not supposed to be (with server ID) it just leaves

digital ibex
#

and u r doing let user = member or user

obtuse wind
#

ill figure something out

digital ibex
#

yes

#

u can

clear wraith
#

It still didn't work

fleet chasm
#

what is problem

earnest phoenix
#

officially lost is right

digital ibex
#

as i said, prolly won't work

#

just do

#

1 of 2 things: ```js
let member = message.mentions.members.first() || message.member;
let user = message.mentions.users.first() || message.author;

earnest phoenix
#

your statement basically says let user represent message.member.first or message author

#

why do you need an OR

hazy jungle
#

how do i see how many servers my bot is in?

fleet chasm
#

what language are you in

digital ibex
#

<client>.guilds.map((e) => e.name) assuming ur using js

#

and py iirc:

earnest phoenix
#

until I implement that, I use the bot's invite link

digital ibex
#

ok, i forgot py

small prairie
#

fs dead or what?

earnest phoenix
small prairie
#

i cant write anything + no error

digital ibex
#

wdym

earnest phoenix
small prairie
#

FS isnt working

#

nodejs filesystem module

digital ibex
#

yes

small prairie
#

just not working

digital ibex
#

but whats not working

small prairie
#

no error nothing

earnest phoenix
#

@small prairie wym fs isn't working

digital ibex
#

works perfectly fine for me

clear wraith
small prairie
#

not writing

#

/creating file

clear wraith
#

why does it show 2 bals

digital ibex
#

prolly u need an else statement

#

eris makes u use them a lot

small prairie
#

Yea

#

!eval fs.writeFile("./giveaway.json",JSON.stringify("{}"),err=>{ if(err)console.log(err) })

#

this command should make a file right?

digital ibex
#

p sure that should just like add something to it, not 2 sure tho

#

wait

#

yeah,

small prairie
#

yea it doesnt work

hazy jungle
#

is this a good amount for my time? also how do you get more ppl to use it?

digital ibex
#

u don't

#

u hope

small prairie
#

@hazy jungle not the correct channel

#

Oof

hazy jungle
#

what channel

digital ibex
#

idk

small prairie
#

Any help for me or am i "Officially Lost"

earnest phoenix
#

@hazy jungle yea

digital ibex
#

ok

#

also

#

u need to await it @small prairie pepowot

small prairie
#

await with .then?

digital ibex
#

await .catch

#

try this

small prairie
#

await fs.writeFile('./giveaway.json', JSON.stringify(ga)).catch(e=>console.log(e))?

#

or FileSync

digital ibex
#
fs.writeFile('newfile.txt', 'Learn Node FS module', function (e) {
if(e) { throw new Error(e) }
})
#

thats from the docs doe

small prairie
#

@digital ibex It creates to the main home directory but not to the current directory

digital ibex
#

then tell it to

small prairie
#

lel

digital ibex
#

dir/file

#

fs.writeFile('dir/file'...

#

p sure that'd work

small prairie
#

Thanks found that bug

#

'./' doesnt seem to work anymore

wicked pivot
#

hello i want to order information roles but i think i dont take it wrong

 let roleid = message.guild.roles.map(r => r.id).filter(r => r === args[0])
    let rolename = message.guild.roles.map(r => r.name).filter(r => r.includes(args[0]))
    if(roleid.size > 0){
message.reply("by id")
}else if(rolename.size > 0){
message.reply("by name")
}else{
message.reply("not found")
}```
sudden geyser
#

does it always say not found? Are you sure it does exist? Why are you re-mapping it just to check the property once, when you could instead just use .filter() once (e.g., roles.filter((role) => role.name === something))? What is args[0]?

wicked pivot
#

the id or name of a role

#
message.guild.roles.filter(r => r.id === args[0])```like this it works thank you
queen needle
#

My music command doesn't work?

sudden geyser
#

There are many better ways of doing it Tony, but okay.

#

What about it doesn't work.

queen needle
#

Like if I do ^play1 <youtubelink> it doesn't play anytthing

earnest phoenix
#

And errors in your console?

queen needle
#

abort(TypeError: Cannot destructure property channel of 'undefined' or 'null'.). Build with -s ASSERTIONS=1 for more info.10:03 PM

wicked pivot
#
let roleid = message.guild.roles.filter(r => r.id === args[0])
    let rolename = message.guild.roles.filter(r => r.name.toLowerCase() === args[0].toLowerCase())
   if(roleid.size > 0)var role = message.guild.roles.get(args[0])
   else if(rolename.size > 0) var role = message.guild.roles.filter(r => r.name.toLowerCase() === args[0].toLowerCase())
   else return message.channel.send("> Not found")```
queen needle
#

Idk if that's from this code or not gut I haven't seen that before

#

Is there a problem?

wicked pivot
#

when I do a search with the name of the role it's "useless"

queen needle
#

!inforole fondateur

#

Like it doesn't work

wicked pivot
#

well if it works but all the information is "undefined"

clear wraith
#

I have another problem

#

lemme get the screenshot'

#

ill get the code

prime cliff
#

@clear wraith you need to do <@id>

clear wraith
#

Ill show you the code?

#

@prime cliff On the 6th line... do I need to change that in order for it to mention the user?

queen needle
#

Show cpde

clear wraith
#

module.exports.run = async(client, message, args) => {
  let user = message.mentions.users.first() || message.author //This will show us how much money a user has when we mention them
  let money = await db.fetch(`money_${user.id}`) //This will fetch the amount of money we have in our account
  message.channel.send(`${user.id} has a balance of $${money}`)
}

module.exports.help = {
  name: "balance",
  aliases: ["bal"]
}```
queen needle
#

Get rid of. Id

#

Like user.ud

sudden geyser
#

you can also just use .toString() to get the mention

prime cliff
#

I just told you to do <@id>

queen needle
#

Yeah

clear wraith
#

ok

prime cliff
clear wraith
#

Ok

#

I got it

#

Ok, I have another problem...

#

I had one of my beta testers try the bal command, and came up with this...

#

How can I make it say Blah blah has a balance of $0??

#

instead of null

earnest phoenix
#

just... check if it's null?

#

though your data shouldn't be null in the first place

clear wraith
#

Thats what im tryna figure out

#

Idk why its saying null

earnest phoenix
#

Hi, how can I do to my bot skip a song? xD

#

Im sad

pliant cove
#

ok

earnest phoenix
#

4th time my bot got rejected

oak cliff
#

this is development, please move to off topic

pliant cove
#

then make a better one

earnest phoenix
#

ok

lofty grove
#

Hello,I have a problem can you help? it turns constantly.
logs* I'm talking about logs

queen needle
#

What

lofty grove
#

this place turns around and does not stop.

earnest phoenix
#

my guy didnt setup a webserver

lofty grove
earnest phoenix
#

glitch doesnt respond to http requests for you

#

you have to setup a express webserver in your glitch project somewhere to respond to a ping

#

for example with “hi” when someone makes a request to /

lofty grove
#

how can i do it?

earnest phoenix
#

express

#

new glitch express projects are setup to do exactly that

clear wraith
#

Yeah, use express

lofty grove
#

do you know how to do this?

clear wraith
#

yes

lofty grove
#

Can you help?

clear wraith
#

I use glitch to code my bot

earnest phoenix
#

let app = require("express")();
app.listen(8080)
app.get("/",(req,res)=>{res.send("hi")})

#

ik spoonfeeding

#

dont bully me

clear wraith
#

lol

#

there you go @lofty grove ^^^

earnest phoenix
#

put that anywhere in your code and u good

lofty grove
clear wraith
#

yes

earnest phoenix
#

ya need to install express first ynkow

lofty grove
#

edit I want to throw a link can you help?

sudden geyser
#

why so many dependencies

earnest phoenix
#

because big bot

lofty grove
#

constantin thank you friend who solved my problem.

earnest phoenix
#

with big bot comes big node_modules

#

also @lofty grove no problem, once again

lofty grove
queen needle
#

Did it work?

lofty grove
#

yes it worked

clear wraith
#

awesome

queen needle
#

Does anyone know anyone I could encrypt a message in md5 and send it like

#

^hash fish

#

And it sends back a md5 has version of the word fish

earnest phoenix
#

md5 isn't encryption

#

and your question doesn't make sense

#

if you can? how to? what's the question

queen needle
#

How to

#

But puts it in md6

#

Md5

earnest phoenix
#

in which language

queen needle
#

Js

#

Discord. Js

earnest phoenix
#

you could've done that yourself

queen needle
#

Or could im

#

But this thank you sorry

queen needle
#

With that I can't decrypt it do you know anything I could use for that

pale vessel
#

you can't decrypt md5

queen needle
#

OK thank you

pale vessel
#

well, like easily

earnest phoenix
#

again

#

md5 isn't encryption

#

it is hashing

queen needle
#

So I'm trying to convert to binary but it just sends back what I sent

#
 const binary= require("string-to-binary")
    if(message.content.startsWith(prefix + "binary")){
let hexing = args.join(" ")
    				if(!hexing) return message.reply("please include something to hash")
    				
    				

let bobby = (hexing)
    				message.channel.send(bobby)
    				}```
#

Nvm fixed it

earnest phoenix
#

Lol

pale vessel
#

you didn't even use the module

queen needle
#

Wdym?

#

Also this is the code that worked


    if(message.content.startsWith(prefix + "binary")){
let hexing = args.join(" ")
let binary = require("string-to-binary")(hexing)
    				if(!hexing) return message.reply("please include something to hash")
    				
    				


    				message.channel.send(binary)
    				}```
pale vessel
#

your previous code was dogshit

queen needle
#

Yeah

#

There was a in between version that was worse

#

I tried to use hexing before it was defined

sullen cypress
#

does any1 know if there's a way to use npm packages in html or if there's a way to loop through a folder in vanilla js

queen needle
#

Why?

#

Like what are you trying to do that requires that

sullen cypress
#

an api

#

and im listing all the pages

drowsy grail
#

definitely can't use npm without node.js

#

https://stackoverflow.com/a/14446538 @sullen cypress this might be what you're looking for

#

this is assuming you know the file names ahead of time

sullen cypress
#

ty

drowsy grail
#

no prob

sullen cypress
#

does that get content of a file or the file name?

drowsy grail
#

file contents

sullen cypress
#

mm

#

im trying to get the file name, but thanks for your help

surreal notch
#

db.add(`cdata_${user.id}`, args[1])

#

how to remove money from someones acc.

restive furnace
#

db.delete?

#

look the docs...

surreal notch
#

Umm....share me that please

restive furnace
#

i assume you using quick.db, so go google and search quick.db documentation

solid pike
#

do you know a module for calculate ?

earnest phoenix
#

hey

gilded plankBOT
#

Please don't just say "Hello" in chat without continuing the conversation. It's as if you called someone on the phone and said "Hi!" and then put them on hold. Additionally, asking your question before getting a reply allows asynchronous communication.

surreal notch
#

please anyone give me documentation of economy command of discord.js

earnest phoenix
#

no

earnest phoenix
#

Hi everyone, so im creating a bot called Octane in discord.js, i wanted to know how to create a function where when a user types an invalid command, the bot responses with something like "This is an invalid command, run prefix help"

#

don't

#

it's a bad practice

#

if the user attempts to execute a command that doesn't exist just don't do anything and internally return out of the function

#

uhm

#

ok

surreal notch
#

how to define answer?

#
  // If the message is "ping"
  if (message.content === "p!redeem XYZ") {
    // Send "" to the same channel
    message.channel.send("2");
 let cdata = db.get(`cdata_${message.author.id}`)
  
  if(cdata === null) db.set(`cdata_${message.author.id}`, 0)
if(answer === 2) {
    return message.channel.send("You won nothing better luck next time")
  }
db.add(`cdata_${message.author.id}`, answer)

       
    } else if(message.content === `${prefix}bal`) {
      
   
      
      
      let cdata = db.get(`cdata_${message.author.id}`)
      
    if(cdata === null) cdata = 0;
      
      message.channel.send(`**You have ${cdata} coins**`)
       talkedRecentl.add(message.author.id);
        setTimeout(() => {
          // Removes the user from the set after 6 hours
          talkedRecently.delete(message.author.id);
        },     21600000);
      
    }
    }
)

;```
I am making a command whenever some uses that cmd then in his account 5k coins will be added
#

But it is saying "answer is not defined"

#

Please guide me what to do and Is I am making coreect codes

#

I am using discord.js v12

earnest phoenix
#

stop stealing and copypasting code

surreal notch
#

and using quick.db

#

@earnest phoenix I made them for your kind info.

earnest phoenix
#

if you had written the code you would know how to resolve your problem

surreal notch
#

But I am new taking help of friend he is off so I asked here

#

Now please anyone guide me where I am doing mistake

#

Ok i found it

earnest phoenix
#

Quick question, how do i remove the 'undefined' thing in a MessageEmbed?

surreal notch
#

@earnest phoenix That's easy

earnest phoenix
#

uhm, i kinda still need help tho

#

im new to discord.js

surreal notch
#

var embed = new Discord.MessageEmbed()

#

are you getting error in this?

earnest phoenix
#

uhm

surreal notch
#

In which word you are getting

earnest phoenix
#

so, when run the command in Discord, after the .addField a 'undefined' comes up

west spoke
#

embed is undefined

earnest phoenix
#

oh

#
 var embed = new MessageEmbed()
            .setColor("RANDOM")
            .setTitle(`some title`)
            .setDescription(`some text`)
            .addField(`https://alink.com`)
            .addField(`https://herecomesalink.com`)

        message.channel.send(embed);
#

this is the code

west spoke
earnest phoenix
#

me knowing i kinda messed up

west spoke
#

"kinda" is an understatement

earnest phoenix
#

huh

west spoke
#
var embed = new MessageEmbed() {
            .setColor("RANDOM")
            .setTitle(`some title`)
            .setDescription(`some text`)
            .addField(`https://alink.com`)
            .addField(`https://herecomesalink.com`)
 }
        message.channel.send(embed);```
earnest phoenix
#

oh, im dumb

west spoke
#

if i'm not correct, it's because i use the C family, not JS.

earnest phoenix
#

C is awesome tho, i know C# and a bit C++

west spoke
#

eh

#

i couldn't find a very good lang for discord in c# easily, so i just stick with python

#

but c# with opengl is fun

earnest phoenix
#

very

west spoke
#

i managed to create a opengl 3d python game for no reason

earnest phoenix
#

cool