#development

1 messages · Page 707 of 1

quartz kindle
#

if type is supplied (ie: {type:"text"}), djs gets the type id from the ChannelTypes constants

#

if type is not supplied, it falls back to "text", but the discord api expects a channel type ID, not the string "text"

#

GUILD_TEXT's id is 0

earnest phoenix
#

Oh okay...

quartz kindle
#

its already fixed in 11.5-dev

west spoke
#

ok, i know how to do this in async, but how would i use a custom prefix (eg calling the server before it's sent)

#


import nekobot as nb
import nbapi



bot = commands.Bot(command_prefix=prefix)```
#

how would i change the prefix before the bot variable

#

Would i need to go through every server it's in?

astral meteor
#

How does one go about creating an eval command and what does it do?

mossy vine
#

it.. evaluates code

astral meteor
#

Oh cause I've seen people use it to do stuff?

mossy vine
#

yes

west spoke
#

eval()

astral meteor
#

And only bot owners can do it because you can get the bot's token

mossy vine
#

yes

#

thats how it works

#

dont trust anyone with eval

astral meteor
#

mhm

#

and how do i create a setprefix command

#

so it changes the prefix per server

west spoke
#

store prefix in database

#

shivaco

#

ima finally go away from json

#

reccomend me a db in dm pls

#

since you convinced me to use rewrite

astral meteor
#

wait cyber

#

arent you a mod in discordboats

mossy vine
#

yes, but how is that relevant

#

also what lazy said

astral meteor
#

idk i saw your username

west spoke
#

¯_(ツ)_/¯

astral meteor
#

How do I get the uptime of my bot? For stats command.

west spoke
#

you can store in file

#

and measure the difference

cursive dagger
#

@west spoke use a function to check the prefix and just pass it

west spoke
#

uh

#

could you help me with that

#

honestly i think #= is fairly uncommon

#

¯_(ツ)_/¯

#

so ill just keep it for now

#

until I properly learn rewrite

floral crater
cursive dagger
sick cloud
#

what's the permission name for changing nicknames

#

just CHANGE_NICKNAME right

earnest phoenix
#

Nickname for others or just the bot

#

Because for members I think it is MANAGE_NICKNAMES

west spoke
#

I don't exactly wanna mess with cogs

sick cloud
#

@earnest phoenix just the bot itself

earnest phoenix
#

Ah yeah CHANGE_NICKNAME should work then

sick cloud
#

👌

indigo geyser
#

@west spoke i use json for change prefix

#
def get_prefix(bot, message):
  with open ('<ur json>', 'r') as f:
    prefixes = json.load(f)
    
  return prefixes[str(message.guild.id)]


bot = commands.Bot(command_prefix = get_prefix)
west spoke
#

...

#

ok

indigo geyser
#

no?

valid frigate
#

why would you use json

#

it's subject to corruption

knotty steeple
#

sqlite is good for small bots

valid frigate
#

in order to scale though youll need an actual db eventually

#

like mongo, postgres, mysql, etc

knotty steeple
#

i dont like postgres

valid frigate
#

me neither but

#

it's a db so gotta list it

knotty steeple
#

also mariadb > mysql

valid frigate
knotty steeple
#

mariadb is better mysql

quartz kindle
#

Sqlite can handle anything that you can run on a single machine

#

The only point at which you need to move to mysql/postgre/mongo is when your bot needs multiple machines

sick cloud
#
        this.options.shards.filter(item => !isNaN(item) && item >= 0 && item < Infinity)
                            ^

TypeError: this.options.shards.filter is not a function```
![thinkLul](https://cdn.discordapp.com/emojis/264756680942813184.webp?size=128 "thinkLul") can anyone explain this
quartz kindle
#

Shards expects an array

sick cloud
#

so how do i tell it that i want it to decide then

#

thought auto would work

quartz kindle
#

You dont use shards

#

The shards option is to define the shard ids that this client should run

sick cloud
#

so that's not how you do internal sharding ok

quartz kindle
#

It is, but if you know which ids you want

sick cloud
#

what do i use if i don't then

quartz kindle
#

I dont remember, im on the phone, but there are other sharding options, check the client docs

sick cloud
#

mkay

quartz kindle
#

shardCount i think

sick cloud
#

only takes a number apparently

quartz kindle
#

Use util.fetchRecommendedShards

#

And give it that number

sick cloud
#

how do you get util

quartz kindle
#

Discord.util or {util} = require(discord)

outer niche
#

what do i do

sudden geyser
#

you do python v3

outer niche
#

yes

sudden geyser
#

Oh, you're missing a ) in the above fn

earnest phoenix
#

await ctx.send(embed=embed) *

west spoke
#

@outer niche on await ctx.send(embed=embed you forgot a )

#

Also change your idle's theme sheesh

#

use the dark theme at least

#

your eyes will thank you

earnest phoenix
#

Lol

#

Dark theme > all

outer niche
#

I mean it was perfectly fine before

earnest phoenix
#

Impossible

outer niche
#

And it's not doing it to that specific command anymore I moved it all around and it's doing it to another command now

earnest phoenix
#

^^

west spoke
#

@outer niche you forgot to add a ).

That is gonna happen in python (and any language)

outer niche
#

Completely different command now

west spoke
#

Show above it

outer niche
#

It was not having this problem before

west spoke
#

show above where the red is

outer niche
#

what

earnest phoenix
outer niche
#

yes what abot it

west spoke
#

Send a image of it

#

Eg if the highlited area was a error

#

We would need to see the above part

#

(Yes that's async, I'm redoing my bot now)

outer niche
west spoke
earnest phoenix
#

Show the code above your ASYNC

outer niche
west spoke
earnest phoenix
#

AGAIN ABOVE

outer niche
#

Are you talking about a whole another command

earnest phoenix
#

DUDE

#

Are

#

'-'

#

You

loud salmon
#

hey

#

calm down

#

and stop @earnest phoenix

#

rn

#

thanks

earnest phoenix
#

;-;

loud salmon
#

we dont need that here

earnest phoenix
#

above your current function you're showing us

outer niche
earnest phoenix
#

Omfg

loud salmon
#

@earnest phoenix pls, if you dont have anything helpful to say then please dont send it

loud salmon
#

yea i know

#

:<

earnest phoenix
#

Monka_Hmm okay

loud salmon
#

still there can be nicer ways to say it

#

:p

earnest phoenix
#

Yes

outer niche
#

Fixed

earnest phoenix
#

Sweet Ethereal_thumbsup

zealous veldt
#

@slim heart This channel isn't for that kind of message, last warning

slim heart
#

i was clicked into the wrong chat leave me alone

ember atlas
hushed berry
#

You check if the reported person doesnt have MANAGE_GUILD

#

@ember atlas

ember atlas
#

Oh

#

Well

#

I want to check if the reported person has manage guild so it errors

#

damnit

#

assuming i dont need a !

#

TypeError: Cannot read property 'first' of undefined

#

we love that

hushed berry
#

oh lol

ember atlas
#

it just worked

#

I seemed to have fixed that issue, but TypeError: reportChannel.send is not a function the same thing works for something else so like rooTHINK

hushed berry
#

@ember atlas are you sure reportChannel isnt the report channel's id

ember atlas
#

oh uh ya

#

i store it as id

hushed berry
#

today kids, we learn about the benefits of properly naming your variables

ember atlas
#

oh

#

wym

hushed berry
#

dont you need to resolve it into a channel before you can send a message to it

ember atlas
#

i didnt even think of that lol

#

i kinda forgot i store that as id

hushed berry
#

again

#

the benefits of properly naming your variables

ember atlas
#

ok so i need to resolve it as a channel name rather than an id to send it?

hushed berry
#

w-what

#

id assume you need to resolve it to the channel object

#

you cant send a message to a string in this case

ember atlas
#

hm

hushed berry
#

im not fluent with whatever discord lib youre using but id assume its something similar to that

ember atlas
#

ya im usin discord.js

amber fractal
#

get channel -> use methods

ember atlas
#

?

#

How would I send it then im hella confused

sudden geyser
#

do what the others said: Resolve a channel with the fetched ID, then send it from there

ember atlas
#

Ya i did that

#

this command is stupidly broken

#

it works fine but it cancels the report when i told it not to

copper cradle
#

@ember atlas do u even know how basic js works?

#

You need to get the object

#

<Client>.channels.get('id');

ember atlas
#

i bet you $100 bucks that has nothing to do with my issue above

earnest phoenix
#

i bet you $100 bucks that you wont try it

west spoke
ember atlas
#

i fixed it anyways

earnest phoenix
#

was wondering if anyone could help me out with this

languid dragon
#

nope sorry i don't know what your issue is because i didn't bother reading it at all

earnest phoenix
#

😦 ok

languid dragon
#

(fyi, you're trying to get variables from an "id")

earnest phoenix
#

oh shit

#

uh pretend you never saw that @languid dragon

copper cradle
#

boss

#

it had to do

sick cloud
copper cradle
#

w r o n g c h a n n e l

unreal hollow
sick cloud
#

@copper cradle technically no this channel is for talking about bot dev

#

@unreal hollow get a real host or try heroku support or something

earnest phoenix
#

I've created a "userinfo" command with my bot, but it didn't work with certains users. Why?

#

user isn't in cache

#

the code

late hill
#

user.lastMessage.member.nickname

#

when you have a member up above

earnest phoenix
#

the null isn't the problem

late hill
#

yeh but it still doesn't make sense

earnest phoenix
#

I've try with regular random members too, sometimes an error occured

#

"null" is beacause I don't have nickname on the server

#

(this user HAVE a nickname)

slender thistle
#

Looks like lastMessage is null? thonkku

late hill
#

Actually it's exactly that

#

that is the problem

#

lol

earnest phoenix
#

message.channel.send(Name: ${user.username}, ID: ${user.id}, Username: ${user.nickname});

#

this work

#

thx

twilit rapids
#

if user is the User Object then nickname is nothing

earnest phoenix
#

but the nickname shoxs up

#

wtf

#

(bot crashes)

#

(bot works again)

earnest phoenix
twilit rapids
#

...don't send it? Or change message.reply() to message.channel.send()

earnest phoenix
#

(basic stuff, I know)

#

thx

#

^^

stray garnet
#

message.reply() mentions the User.
message.channel.send() dosn't

wide ruin
#

How do you get text to appear as a link?

#

Like let's say I wanted Discord to have a link to discordapp.com on it, how would I do it?

quartz kindle
stray garnet
#

^

#

How would i get the Role of the Message Author?

sudden geyser
#

users don't have roles; guild members do (d.js). What lib are you using

slender thistle
#

A message author can have up to 250 roles, which role would you be talking about?

stray garnet
#

The Highest @slender thistle

#

@sudden geyser Discord.js

sudden geyser
#

master or stable

stray garnet
#

stable

slender thistle
#

GuildMember.highestRole

sudden geyser
#

check out the guildmember class docs for something that looks like it.

slender thistle
stray garnet
#

so it would be message.author.highestRole?

sudden geyser
#

users don't have roles, only guild members

stray garnet
#

F

#

Ok

#

Ty i got it

astral meteor
#

How do I add custom emojis to my bot's responses and in embeds? All the emojis are in its support server.

stray garnet
#

well get the id of them

astral meteor
#

Just put the ID in the message?

earnest phoenix
#

WHY MY BOT IS SO GLITCHY

astral meteor
#

.

earnest phoenix
#

now he can't ban users...

stray garnet
#

Put an :- before the Emoji to get the Id.

:-![thonkku](https://cdn.discordapp.com/emojis/356833797804916737.webp?size=128 "thonkku")

#

remove the :-

astral meteor
#

\ works too.

stray garnet
#

and ur good

astral meteor
stray garnet
#

that would

sudden geyser
#

@earnest phoenix we wouldn't know.

astral meteor
#

So I put ![xD](https://cdn.discordapp.com/emojis/530319509580677130.webp?size=128 "xD") in the response, for example.

stray garnet
#

Yes

astral meteor
#

And it would send:
xD Testy test

normal crater
#

my bot was declined beacause the invite isnt correct, but the invite link is correct help

earnest phoenix
#

can someone help me?

sudden geyser
#

contact the mod who denied your bot

astral meteor
#

Alrighty thank you quality

stray garnet
#

@astral meteor Yep

slender thistle
#

@normal crater Discuss that with the moderator who declined your bot, preferably in DMs

stray garnet
#

Np

earnest phoenix
#

the bot HAS the permissions to ban, but it failed

normal crater
#

@slender thistle @sudden geyser okay, thankyou

slender thistle
sudden geyser
#

@earnest phoenix bannable's spelled incorrectly

earnest phoenix
#

o

astral meteor
#

line 28, you misspelled banable, should be bannable.

earnest phoenix
#

(1 error, and the bot crashes)

astral meteor
#

yeah

earnest phoenix
#

thx

astral meteor
#

np

normal crater
#

but luca declined my bot lol

sudden geyser
#

Search for your bot with the search bar in #mod-logs (bot id) and you'll find the mod

#

A question I have: How long are user IDs usually?

earnest phoenix
astral meteor
#

18 @sudden geyser

slender thistle
#

iirc 17 characters minimum

little garnet
#

One message removed from a suspended account.

slender thistle
#

Port 5000 is already in use

flat pelican
#

he is asking what he can do

mossy vine
#

use a different port?

earnest phoenix
astral meteor
#

How do I see the names of servers & their member count my bot is in using my eval command?

sudden geyser
#

what lib

astral meteor
#

djs

sudden geyser
#

Iterate through the <Client>.guilds collection mapping by its name & membercount. ex: (guild) => guild.name (other stuff...)

astral meteor
#

How do I get uptime of my bot for stats cmd?

ebon crypt
#

Hello.

#

How i can paste guild id's in the website?

slender thistle
#

id1, id2, id3

ebon crypt
#

Thanks

earnest phoenix
#

Does loading commands with a handler increase memory usage that much, I thought the increase was due to a command, but after playing around with that I don't think it's directly caused by a certain command, leaving it seemingly be the command and event handler. Would something like that really increase memory usage by 30mb (discordjs)?

#

Or would it be something I glossed over when checking each of the commands

quartz kindle
#

30mb cant be caused by command handlers

lunar crystal
#

What does mean this erro unexpected token { ?

quartz kindle
#

unless you're doing something seriously wrong

#

it means that you have something wrong in your code

lunar crystal
#

Ok I check this

earnest phoenix
#

I mean the command handler is pretty basic ```js
client.commands = new Discord.Collection();

fs.readdir("./commands/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
if (!file.endsWith(".js")) return;
let props = require(./commands/${file});
let commandName = file.split(".")[0];
client.commands.set(commandName, props);
});
});

fs.readdir("./events/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
if (!file.endsWith(".js")) return;
const event = require(./events/${file});
let eventName = file.split(".")[0];
client.on(eventName, event.bind(null, client));
});
});```

#

unless it really is somewhere else in the code, which I suppose it could be

quartz kindle
#

how do you know those 30mb are caused by the handler and not by the cache?

earnest phoenix
#

I mean I suppose I really don't it was just an assumption based on the occurrence of how it started

#

I'm not knowledgeable on memory related things very much at all, if it were to be the cache, is there much that can be done, or is it just the way it is

quartz kindle
#

there is a lot that can be done, but not obviously so, and not easily either

#

the easiest thing you can do is disable message caching if you dont need it

#

by setting maxMessageCache to 0

#

other than that, you can either sweep the other caches regularly (users,members,channels.roles,emojis,voice states,presences)

#

or intercept their events to prevent caching in the first place using the raw event

#

you can also get some mileage by disabling event processing for events you dont need in the client options

earnest phoenix
amber fractal
#

yes

#

I cant post an invite though because I'm a white name

#

r3sSKJJ this is the code tho

knotty steeple
#

@quartz kindle i disabled message cache and my bot wouldnt respond to anything

astral meteor
#

When my bot joins a new server, how do I post that into a logging channel in its support server with said server's information?

mossy vine
#

fetch the channel and send the message

sudden geyser
#

listen to the guild join event and use logic from there

astral meteor
#

Yeah, but how do I get the info of the server my bot joined?

mossy vine
#

the guild object is passed in the guildCreate event, assuming youre using d.js

astral meteor
#

yes djs

broken shale
#

does a .catch or .then come first in js

#

forgot

knotty steeple
#
some.thing().then(do => do.that()).catch(err => console.error(err))```
#

something like this works

#

probably

amber fractal
#

I dont think it even matters the order

broken shale
#

¯_(ツ)_/¯

sudden geyser
#

.then if you want to handle the received stuff. .catch if you don't plan on doing anything with it. The order does matter. .catch(...).then(...) handles the .then for the rejected promise

broken shale
#

I was doing msg.author.send('some error occurs here').then(m => m.delete({timeout: 5000})).catch()

knotty steeple
#

that works

broken shale
#

Was just unsure

quartz kindle
#

@knotty steeple that makes no sense lul, disabling message cache doesnt interfere with that

knotty steeple
#

megathonk

earnest phoenix
#

He's right tho

#

I disabled it too and it wouldn't respond

sudden geyser
#

did you try setting it to 1

quartz kindle
#

yeah try setting it to 1 then

lunar crystal
#

Waht does unexpectited identifier mean ?

mossy vine
#

syntax error

lunar crystal
#

Oki thank u

earnest phoenix
#

that's not valid typescript/javascript

#

please learn the language before trying to code a bot in it

lunar crystal
#

Ok

#

But I don't know where to start ?

earnest phoenix
#

documentation/online courses

#

i personally suggest codecademy

mossy vine
#

let me tell you where you dont start: making a discord bot

#

sololearn is also good for learning syntax

lunar crystal
#

oki

#

But you think that I have to learn node.js or js directly ?

mossy vine
#

they are the same

#

sort of

#

very minor differences

#

no syntax difference tho

lunar crystal
#

OK

#

I can learn node.js directly I gess ?

knotty steeple
#

@mossy vine js and node.js isnt the same rEEE

mossy vine
#

node.js is a javascript runtime outside of a browser environment

knotty steeple
#

yes

#

its a runtime™

lunar crystal
#

Yep I know that

knotty steeple
#

just learn js and you basically can do node.js

#

might get taught on using js in the browser tho

earnest phoenix
astral meteor
#

If i wanted my prefix to be a word like "test" would I put the prefix in my file as "test " with a space after the word? So a command would be test <commandname>.

knotty steeple
#

ok

earnest phoenix
#

For users this is https://discordapp.com/api/v6/users/:ID/profile
What is it for guilds?

cedar brook
#

.

earnest phoenix
#

I have found ^^

hushed berry
#

Thonkang bots cant use that endpoint

cedar brook
#

should i download Noda.js ?

earnest phoenix
#

@hushed berry really?

grim aspen
#

You can if you want @cedar brook

cedar brook
#

@grim aspen How to make a commands to the bot? (Sorry for a lot of questions but I am new here)

earnest phoenix
#

bots can't access user profiles

grim aspen
jade thistle
#

^

earnest phoenix
#

No problem I can put my user token on the header

#

:)

#

which is against the tos

#

:/

hushed berry
#

lmao

earnest phoenix
#

it can result in account termination

jade thistle
#

bruh

cedar brook
#

@earnest phoenix What thing I need to use to make a commands for the bot?

grim aspen
broken shale
#

Is there a way of knowing if you got the 1 hour ban for the API because it seems like my shards can't connect to them for the past 2 hours or so. No 400s hit

earnest phoenix
jade thistle
cedar brook
#

kk

earnest phoenix
#

With my account i have this

#

being logged in inside of the browser doesn't carry it to the api requests

#

you need to supply a token

#

in the auth header

#

Bruh

#

Wait

cedar brook
#

really i need to script the bot?

earnest phoenix
#

Yes

cedar brook
#

Ugh..

#

It is hard?

jade thistle
#

no

earnest phoenix
#

depends what is hard for you

#

you need to know a programming language

#

Bruh

#

Am I not allowed to use this on a bot command?

#

no

#

:/

#

you're not allowed to use a user token outside of the official discord client

#

Okay

cedar brook
#

can someone dm me the link that i can scripting the bot there?

earnest phoenix
#

do your research

#

you have google

cedar brook
#

yes

jade thistle
#

use google

cedar brook
#

but.... i mean what program i need to download to script a bot

jade thistle
#

do you use windows?

earnest phoenix
#

it's not as simple as you think it is

jade thistle
#

^

mossy vine
#

@earnest phoenix honestly thats a great vid

cedar brook
#

i use windows @jade thistle

earnest phoenix
#

yeah, polymatter makes really good videos, enjoying his content a lot

cedar brook
#

.

earnest phoenix
quartz kindle
#

lucas did you read the links people gave you? like faq

cedar brook
#

i am noob, i am new in making bots, i need good teacher

jade thistle
#

@cedar brook windows has a program called "Notepad.exe" and you can write yor code here

#

but it isnt the best for doing it

quartz kindle
#

i can be your teacher for $20/hour

cedar brook
#

@quartz kindle WHAT?

mossy vine
#

tim are you serious rn

earnest phoenix
#

"for freep ls"

jade thistle
#

tim

mossy vine
#

do you do tutoring for 20 bucks an hour

cedar brook
#

may i have a teacher for free?

quartz kindle
#

for him, yes

jade thistle
#

bruh

mossy vine
#

oh, i thought you do that for anyone lol

quartz kindle
#

i wouldnt mind tbh

jade thistle
#

what programming language do you wanna start with?

cedar brook
#

guys! i really need a teacher for free. that who will teach me how to make commands etc.

quartz kindle
#

you think 20 is too much?

cedar brook
#

...

earnest phoenix
#

self-teach yourself if you can't afford a tutor or online services like codecademy

harsh nova
#

20 per hour is dirt cheap

earnest phoenix
#

most developers here are selftaught

mossy vine
#

honestly, i dont know what the average prices are but 20 seems fair, considering how good you are at teaching and explaining concepts

harsh nova
#

jesus

cedar brook
#

nvmmm

earnest phoenix
#

hell, i'm a selftaught fullstack jr

harsh nova
#

40 per hour is more fair

cedar brook
#

WHAT

#

NO

quartz kindle
#

do people actually pay 40 per hr?

harsh nova
#

time is money my dude

jade thistle
#

@cedar brook go on youtube and search for "the coding train"

harsh nova
#

I dont know

cedar brook
#

okay

harsh nova
#

I guess it depends on quality

jade thistle
#

they have tutorials

mossy vine
#

oh god here we go recommending shitty outdated guides

earnest phoenix
#

yeah tim, people have one on one call sessions and they're willing to pay a lot

jade thistle
#

how tf do guides become outdated?

mossy vine
#

wdym how

#

api changes

#

the discord api changes, the library changes

earnest phoenix
#

it's because software development brings a huge amount of profit, so obviously teaching sessions are pricier

mossy vine
#

shit changes

#

-> shit becomes outdated

jade thistle
#

oh ok i though you were talking about the programming languages, not the apis

harsh nova
#

es6 vs old non chad js is a good example

mossy vine
#

programming languages can become outdated as well

jade thistle
#

ok

#

i need to do some research now

#

goodbye for now i guess

knotty steeple
#

can you get message timestamps with eris and how

#

because idk

cedar brook
#

i am downloading noda. js it is good?

mossy vine
#

Message#timestamp

harsh nova
#

node is pretty good

knotty steeple
#

thats what

cedar brook
#

oh

knotty steeple
#

i did

#

what

quartz kindle
cedar brook
#

let me see

mossy vine
earnest phoenix
#

even if there wasnt a prop you could obtain the timestamp from the id

#

discord follows twitter's snowflake system

#

shift 22 bytes to the right and add discord's epoch

knotty steeple
#

i fucking hate nvim and unicode

#

aaaa

mossy vine
#

yeah nvim doesnt like unicode

cedar brook
#

is noda.js installing is taking long time?

knotty steeple
#

node

#

its

#

node

#

node.js

cedar brook
#

kk

#

it is taking much time to install?

mossy vine
#

maybe

cedar brook
#

exactly?

earnest phoenix
#

it's an environment not a program

mossy vine
#

you install it as if it was a program so

knotty steeple
#

node:1307) UnhandledPromiseRejectionWarning: Error: Invalid file object

#

h u h

#

will post code wait

#
msg.channel.createMessage("📶 Pongerino",{embed: {
        color: 0x7289DA,
        description: `💗  Latency (WS): **\`${boatboye.shards.get(0).latency}ms\`**
                      📬  Message response: **\`${msg.timestamp}\`**`
    }})
``` does this not work
jade thistle
#

what are you trying? we need context too.

knotty steeple
#

im trying to send a message?

earnest phoenix
#

the second param takes a file

knotty steeple
#

yes

earnest phoenix
#

the first one is an object iirc

mossy vine
#

yeah first param is either string (message content) or the entire object u want to send

#

because e r i s

knotty steeple
#

so how do i do message and embed

earnest phoenix
#
{
content: "",
embed: myembed
}
mossy vine
#

{
content: aaaaa
embed: {
color: 0xaaaaa
}
}

knotty steeple
#

thanks eris

ember atlas
#
const db = require('quick.db'); 

module.exports = { 
    name: 'reportchannel', 
    description: 'Sets the report channel.', 
    category: 'config', 
    usage: '<channel name | id>', 
    run: async (client, message, args) => { 

        if (!message.member.hasPermission("MANAGE_GUILD")) return;
        if (!message.member.hasPermission("ADMINISTRATOR")) return;

        let reportchannel = message.mentions.channels.first() || message.guild.channels.get(args[0]) || message.guild.channels.find(c => c.name.toLowerCase() == args.join(' ').toLocaleLowerCase());
        
            if (args[0].toLowerCase() === "disable") {
                await db.delete(`reportChannel_${message.guild.id}`)
                await message.channel.send('Deleted the report channel in my database. Use the command `!reportchannel [channel name | id]` to set a new one.')
            }

        if (!reportchannel) { 
            return message.channel.send('![No](https://cdn.discordapp.com/emojis/625122928849059860.webp?size=128 "No") Please supply a valid channel.')
        }
        db.set(`reportChannel_${message.guild.id}`, reportchannel.id)
                message.channel.send(`![check](https://cdn.discordapp.com/emojis/625049060839129142.webp?size=128 "check") Set the report channel to <#${reportchannel.id}>`)



    }
    
}

This command works with the disable thing, but how can I make it to it doesnt send supply a valid channel?

#

um

#

@loud salmon ^

loud salmon
#

-b @cedar brook 10 years old

gilded plankBOT
#

dblMod Banned 🎃LucasPro2534🎃| Halloween!#2875 (@cedar brook)

earnest phoenix
#

dang

jade thistle
#

bruh

#

where did you get his age from

spark kelp
#

does not matter read his messages

jade thistle
#

okk

vale cedar
#

Hello everyone, I created my webhook for a channel and when I put the link in my bot's info and test it, nothing gets sent to the channel. What could I be doing wrong?

ember atlas
#

Show code?

#

And lib/lang

vale cedar
ember atlas
#

code?

vale cedar
#

The way I did it was create a webhook on the Discord channel and copied that link into the bot's info in the top.gg website

#

do I have to code something in order for it to work?

#

Is this correct?

dblpy = dbl.DBLClient(bot, token)

@dblpy.event
async def on_dbl_test(data):
    print(data)```
ember atlas
#

oh im not a py dude

winged rapids
#

Is anybody here really good with bots

amber fractal
#

if you are looking to get someone to make a bot to you message Oliy to get access #434058442764714002

quartz kindle
#

many people here are good with bots

knotty steeple
#

so how would i go by uploading an image

#

on my pc

#

with my bot

earnest phoenix
#

i n

#

w h i c h

#

l i b r a r y

knotty steeple
#

i n

#

e r i s

amber fractal
earnest phoenix
#

Okay sorry

valid frigate
#

does anyone know if it's better practice to include tags for each metric on prometheus?

#

for each process i have it is a label on each metric

earnest phoenix
#
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./bot.js', { token: 'your-token-goes-here' });

manager.spawn();
manager.on('launch', shard => console.log(`Launched shard ${shard.id}`));```

I can use the shards but for orders?
#

Example music.js or moderations.js

earnest phoenix
#

:/

quartz kindle
#

what do you mean?

earnest phoenix
#

For example, if I want some commands to be available but not others if I update them, can I use shards for that?

quartz kindle
#

that has nothing to do with shards

earnest phoenix
#

Example in music.js there are music commands and in moderation.js there are moderation commands

#

Oh :/

quartz kindle
#

sharding is a system to split servers into different processes

#

a single process/login can only get 2500 servers

earnest phoenix
#

But because of the ports used I can't make shards

#

🤔

quartz kindle
#

if you have 4000 guilds, you need two shards. each shard is a process managing 2000 guilds

earnest phoenix
#

Mmmh okay

#
    if (command === 'stats') {
-        return message.channel.send(`Server count: ${client.guilds.size}`);
+        return client.shard.fetchClientValues('guilds.size')
+            .then(results => {
+                return message.channel.send(`Server count: ${results.reduce((prev, guildCount) => prev + guildCount, 0)}`);
+            })
+            .catch(console.error);
    }```
#

I have read this but

#

It makes it very difficult to order

quartz kindle
#

yes this is to get information from shards

#

how many guilds does your bot have?

earnest phoenix
#

I don't have 2k guilds lol juste it's interresting

#

But you have to redo each order for the shards, right?

quartz kindle
#

what do you mean?

earnest phoenix
#

Exemple:

#

2 shards:
1 = 2k guilds
2 = 2k guilds

#

The controls will not work on both shards

quartz kindle
#

you will have 2 processes

#

each process will be a copy of your bot

#

with the same commands

earnest phoenix
#

But if in one process i use a port i can't launch a second process...

quartz kindle
#

why do you need a port? do you have a webserver?

earnest phoenix
#

Yes i test to make a dashboard

quartz kindle
#

you can put the webserver in the main process, the process where you use the sharding manager

earnest phoenix
#

Okay

#

So I have to copy my main file several times?

quartz kindle
#

no, the sharding manager does it

knotty steeple
#

how do you

#

upload

#

a file

earnest phoenix
#

'-'

knotty steeple
#

with eris

quartz kindle
#

you have 2 files, the manager, and the bot

#

you run the manager, and the manager runs the bots for you

earnest phoenix
#

What should this manager file look like?

quartz kindle
#

the code you posted before

#

with the shardingManager

earnest phoenix
#

Yes

#

He is in this github

quartz kindle
#

yes, thats how the manager file looks like

earnest phoenix
#

Oh okay

#

This is really hard to setup shards

#

So if I use the manager file I don't need to modify the coding of my commands?

#

This is my last question.

quartz kindle
#

you only need to modify if you have code that is not compatible with sharding

earnest phoenix
#

Ah, there's a compatibility story....

quartz kindle
#

for example, if you have a database like levelDB which only accepts a connection from one process at a time

earnest phoenix
#

I use sqlite

quartz kindle
#

sqlite should be fine

earnest phoenix
#

Okay

quartz kindle
#

also, if you have commands that show the server count

#

the command will only show the servers for the shard

#

not all servers

earnest phoenix
#

Oh okay

#

This is good

#

Thank you for all

earnest phoenix
#

Hi

#

hello

#

I need help in troubleshooting my bot

#

Explain

#

@charred orbit

#

which lib?

#

wait

#

He won't reply in some servers but replies in here and the main server

#

sk.dblinfo @charred orbit

#

bruh

#

hol on

#

I can't help you for other librarie..

#

I can only help you on discord.js librarie

#

Sorry

#

Good night

#

Idk what library it is

#

That's what I have it as other

#

the library used to code your bot

#

Im not the one coding it

#

My friend is

#

@earnest phoenix the bot owner is shibe bot loader

#

uh

#

not you

#

lmao

#

it's not your bot

#

We're both

#

are u alt

#

Nu

#

but you arent listed as bot owner

grim aspen
#

@sturdy basin

#

do you know this person?

earnest phoenix
#

I can prove it

#

so he's muted

#

Mute evasion?

#

LOL

#

I have access to all of the bot

#

No, im not an alt

#

his youtube channel is jessie

grim aspen
#

so are you mute evading?

earnest phoenix
#

but why arent you listed as bot owner then

#

HMMMM

#

who else is named jessie here

#

@drowsy sentinel

#

HMMM

grim aspen
earnest phoenix
#

I'll show proof

earnest phoenix
opaque eagle
#

The instructions are in the error

#

have you tried reading it?

earnest phoenix
#

I don't know what it means

#

Option object

opaque eagle
#

Did you check what the docs say for Guild#createChannel?

earnest phoenix
#

oh

jaunty stump
#

I feel like I am going to go crazy trying to figure out what is wrong with my code x3

undefined:1

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at Object.<anonymous> (C:\Users\Ori\Desktop\E-Bot\E-Bot\bot\index.js:7:15)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

here is my error and my code is to long to copy and paste here or screenshot.
I don't know where in my code this is happening. somewhere in 814 lines this is hammening and I don't know where

help?

opaque eagle
#

That JSON file isn't formatted properly

earnest phoenix
#

@jaunty stump show your json please

jaunty stump
#

I have 3

a package.json
a config.json
and a database.json
I'll show all three

opaque eagle
#

Well just show the one that caused the error

sudden geyser
#

hold up json db

opaque eagle
#

It could just be connection information... never make assumptions @sudden geyser

sudden geyser
#

not making assumptions. just makes me think

jaunty stump
#

I fixed it

#

the database.json file was empty for some reason despite me not editing it after I created it

earnest phoenix
#

@jaunty stump show the json file please

opaque eagle
#

They said they fixed it

earnest phoenix
#

Oh okay

#

Sorry

#

;)

jaunty stump
#

also thanks Promise for telling me it was an issue with my .json files and not my main code. I was going crazy trying to find it.

earnest phoenix
#

Yes i know

jaunty stump
#

ok

#

if I have more troubles then I'll be back
ty

earnest phoenix
#

np

jaunty stump
#

well, my leveling system/database is working.

now I am having issues with this.

(node:6004) UnhandledPromiseRejectionWarning: ReferenceError: prefix is not defined
    at Client.client.on (C:\Users\Ori\Desktop\E-Bot\E-Bot\bot\index.js:14:5)
    at Client.emit (events.js:194:15)
    at MessageCreateHandler.handle (C:\Users\Ori\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (C:\Users\Ori\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:105:65)
    at WebSocketConnection.onPacket (C:\Users\Ori\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
    at WebSocketConnection.onMessage (C:\Users\Ori\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
    at WebSocket.onMessage (C:\Users\Ori\node_modules\ws\lib\event-target.js:120:16)
    at WebSocket.emit (events.js:189:13)
    at Receiver.receiverOnMessage (C:\Users\Ori\node_modules\ws\lib\websocket.js:789:20)
    at Receiver.emit (events.js:189:13)
(node:6004) 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(). (rejection id: 1)
(node:6004) [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.
#

like. I know I need to define my prefix.. But at the same time I want to say I have already

ember atlas
#

@jaunty stump send the code

#

Plus lib / Lang

earnest phoenix
#

^

#

Its djs

ember atlas
#

Rather than give an error that we have no idea where it comes from

#

Oh ya LULW

#

Ok so js and djs

jaunty stump
#

discord.js/Javascript
and I have like 814 lines of code. it won't all fit here

if I knew what line this is happening on then maybe it will help me

ember atlas
#

Use hastebin

sudden geyser
#

Well, it's saying prefix is not defined. So... did you define it correctly?

ember atlas
#

It happening on line 14 In index.js

jaunty stump
#

ok. i'll be right back

ember atlas
#

Js errors are self explanatory

jaunty stump
ember atlas
#

Which one is line 14....

jaunty stump
ember atlas
#

What do you want your bot prefix to be

jaunty stump
ember atlas
#

Above line 14 add
let prefix = '+';

#

Since you actually never defined prefix

jaunty stump
#

I have my prefix in my config.json

ember atlas
#

Then it needs to be config.prefix

earnest phoenix
#

Are you requiring the config

ember atlas
#

And you need to require config in one of the first lines of the code

jaunty stump
#

yes I am requiring the config.json file in the first lines of my code

ember atlas
#

Then anything with prefix needs to be config.prefix

#

Or however you required config .json

jaunty stump
#

ok. I will look through my code and try to update things. I'll keep you guys updated if I get anymore errors or problems

sage bobcat
#

One message removed from a suspended account.

ember atlas
#

I agree

#

Or use a command handler

amber fractal
#

you could just

#

have the config on the client

#

then have access to it everywhere

#

and not require something more than once when you dont need to

sage bobcat
#

One message removed from a suspended account.

jaunty stump
#

I just did

client.on('message', async(message) => {
    if (prefix || (message.content)) {
    var parts = message.content.replace(config.prefix, "").split(" ");
      switch(parts[0]) {
            case 'ping':
                const m = await message.channel.send("ping?");
                m.edit(`Latency is ${m.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(client.ping)}ms`);
            break;

and it responded to my ping and help command

#

if (prefix || (message.content)) {

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

jaunty stump
#

yea

sage bobcat
#

One message removed from a suspended account.

jaunty stump
#

just for the ping and help command and this

client.on("message", message => {
    if (message.author.bot) return; // ignore bots
#

and this

client.on('ready', () => {
    console.log('ready!');
});
sage bobcat
#

One message removed from a suspended account.

jaunty stump
#

?

sage bobcat
#

One message removed from a suspended account.

jaunty stump
#

it is to let me know what it does
it's a comment
I use comments to make my life easier

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

jaunty stump
#

well now that I got the ping and help command to work. Every other command I do is being completely ignored and I don't get any errors

manic basalt
#

is it possible to get the Guild.icon_url from a Guild.icon in discord.py? if so how

west spoke
#

guild.icon_url

manic basalt
#

its with oauth2 and the users guilds doesnt have an icon_url @west spoke

#

shouldve specified

west spoke
#

Ah

#

oauth d.py should work the same

#

<user>.<guild?>.icon_url?

stray garnet
#

How can i make args.join(" ") to lowercase?

earnest phoenix
#

args.join(" ").tolowercase

stray garnet
#

no. dont works at me

earnest phoenix
#

Sorry

#

Yes i have test

stray garnet
#

Uh k

earnest phoenix
#

.lower()# converts to lowercase

#

In python

#

What language do you want it in? @stray garnet

stray garnet
#

discord.jd

#

js

earnest phoenix
#

Oh okay

#

Lower case: .toLowerCase()

#

Upper case: .toUpperCase()

#

@stray garnet

stray garnet
#

i tried, but dont works

earnest phoenix
#

discord.js that's work

stray garnet
#

ik but not for me

quasi forge
#

Can embed footers contain custom emojis?

earnest phoenix
#

No

#

Footer can't contain emojis

quasi forge
#

They can contain unicode emojis

#

So I thought there was little hope

earnest phoenix
#

Okay

earnest phoenix
#

hello, how do i do that the embed fields will go the side like in that picture

#

in discord.js

ember atlas
#

You want their avatar in the corner?

earnest phoenix
#

no

slim heart
#

Or inline fields?

earnest phoenix
#

see the embed fields will go to sides

slim heart
#

Yeah inline fields

earnest phoenix
#

yh i think inline thas called

ember atlas
#

Ya you need to use true

earnest phoenix
#

so how do i do that?

slim heart
#

What Lib?

earnest phoenix
#

discord.js

twilit rapids
#

add ,true after each field

slim heart
#

.addField(title, text, inlineBool)

ember atlas
#

.addField('Hi', 'Info here', true)

slim heart
#

So inlineBool would be true if u want inline

ember atlas
#

I use true

#

Works fine for me

slim heart
#

That’s what I’m saying to do

ember atlas
#

Oh lol you said bool

slim heart
#

I’m just trying to not tell him to just throw true into his statement with no idea what it does

twilit rapids
#

You know what a boolean is right

slim heart
#

You absolute large brains

ember atlas
#

Yes

twilit rapids
#

U sure

ember atlas
#

Yes

#

Boolean = true or false

#

Pls timo

slim heart
#

Anyways @earnest phoenix got it?

earnest phoenix
#

kk

#

thx

#

and how do i like go one line down?

slim heart
#

Have it not inline

earnest phoenix
#

just change one to false?

#

kk thx

slim heart
#

The 3rd iirc

#

It’ll affect the next one over

#

If not the 4th

#

But it’ll auto format because it can’t just like go on forever

sage bobcat
#

One message removed from a suspended account.

hushed berry
#

like...what exactly?

#

the pages?

earnest phoenix
#

no, bulky text no one cares about, duh

#

i really wonder whose idea was to make that lool

sage bobcat
#

One message removed from a suspended account.

amber fractal
#

Well depends... Are you on master or stable

sage bobcat
#

One message removed from a suspended account.

amber fractal
#

I would think they iterate the Collection and fetchClientValue for https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=status and guilds.size

stray garnet
#

question for the dblapi.js:
how can i get the coding language of an Bot?

sage bobcat
#

One message removed from a suspended account.

near ether
#

Hey I’ve recently created an MMO for my bot but a lot of my players are having issues with the cooldowns.

I have a a few cooldowns that are 10 minutes long, but for some reason they are sometimes stuck on cooldown forever.

I originally implemented cooldowns by writing their ID’s to a JSON file and having the program check if their ID is in there. With a low amount of players, this works fine. When 100+ players are playing, it didnt work that well anymore. I thought it’s because if multiple people use the command at once, the file gets written to at the same time and therefore gets out of sync, and also because my PC was writing to a JSON file too slow.

Is there a better solution for this? Should I be putting the cooldowns in a player specific JSON file instead? I already have player specific JSONs to manage their MMO progress. Any help would be greatly appreciated!

earnest phoenix
#

stop using IO

#

keep cooldowns in memory

#

cease

#

you should never use files as a database

stray garnet
earnest phoenix
#

you don't unless the owner exposes it

#

e.g on an info command or on a website

#

you seem to be misunderstanding how bots are ran

stray garnet
#

@earnest phoenix info command

earnest phoenix
#

a bot being alive and listening to messages is no more than a mere websocket connection, what language it used to achieve that is not revealed unless the owner explicitly defined it in a command or on a website

grizzled jackal
#

I have my cooldowns stored in a Collection

earnest phoenix
#

^ yeah it's probably the best to keep cooldowns like that, in memory

near ether
#

Ok that’s exactly what I did a few days ago, I just stored the ID’s in a list instead of JSON files and called that list every time I needed to check for cooldowns

#

But I’m still running into the same issue when a lot of players use it

earnest phoenix
#

optimize it

near ether
#

True

earnest phoenix
#

make it store only the information it needs

#

use mutex if you need to

near ether
#

Yea it only needs the ID of the player, which is the only thing going in there. I just do set.add and set.delete when I need to mutate it and put them on or take them off cooldown. I have a setTimeout function to remove them from the cooldown list when it’s time

#

The bot is hosted on my PC and not a dedicated hosting service (yet)

earnest phoenix
#

javascript generally isn't a language that's performant so a huge amount will require bigger end hardware

near ether
#

I do have a very good pc, 64 gb of ram should definitely be enough

#

Do you think moving to a dedicated service would solve this problem? Or is there something I’m missing?

#

By the way thank you so much for helping out so far

earnest phoenix
#

i mean, yeah, obviously

#

your pc is being used for things other than the bot

#

meaning the bot process cannot use its hardwares capabilities properly

near ether
#

Yea lol I do play a lot of destiny with my friends

earnest phoenix
#

which is why there are flops in performance

near ether
#

But even when it’s idle during the day when I’m at work, it still has this issue

earnest phoenix
#

it's probably because of uncleared cache used by other processes/games

near ether
#

Ah ok

#

Thanks so much man, I’m gonna move it to AWS tonight

lunar crystal
#

Are we forced to create a new file for our commands or can we do everything in index.js ?

earnest phoenix
#

your choice

#

id probably recommend making each command a seperate file though

#

much easier to work with

lunar crystal
#

Ok but I can't associate index.js and fun.js ( The command file for fun :X)

near ether
#

If your bot is small/limited (like having 2 or 3 text commands), then having everything in one file is fine

lunar crystal
#

Oki thank u very muvh ;D

near ether
#

But if it is bigger or your foresee it getting bigger, then do multiple files

earnest phoenix
#

if you have a lot of commands it gets cluttered after a bit

lunar crystal
#

For the moment I'm gonna keep just only 1 file

near ether
#

You need to export the files

#

Ok

grizzled jackal
#

Aye, it's personal preference anyway - whatever is easier for you. And with big projects, seperate files are easier to maintain

earnest phoenix
#

you dont have to scroll through 5k lines to fix a command then

near ether
#

Exactly

amber fractal
#

Also performance and modularity

lunar crystal
#

Oki thank u ;O

#

I don't find the solution in discord.js 😬

near ether
#

Syntax error

#

I believe You need a bracket after class fun

earnest phoenix
#

^

harsh nova
#

is your command a class?

lunar crystal
#

I tried everything but still not working

slender thistle
#

Did you learn JS beforehand

grizzled jackal
#

Pretty sure he was told before about learning the basics of JS but refuses to do so

lunar crystal
#

I am actually /learning/, I just start yesterday a video about node.js ( Grafikart )

harsh nova
#

tthen maybe dont jump straight into bot? there are better ways to learn

slender thistle
#

Why not get off the not beginner-friendly library and learn the very basics first?

#

You are barely learning to do anything useful for yourself if you jump straight into something without learning

earnest phoenix
#

we told you yesterday to go learn the language

lunar crystal
#

Yes u are probably rigth, but I thpugth that create a bot would be a good way to lean js

slender thistle
#

It's a very bad idea

earnest phoenix
#

you can't create a project without even knowing the language syntax

#

what you thought was wrong

lunar crystal
#

You are right ...

earnest phoenix
#

please stop rushing into it, take your time and learn the language

#

it's not a thing you do in 15 minutes

near ether
#

You should probably start with python or something tbh

#

Python is very beginner friendly

slender thistle
#

JS and Python are somewhat beginner-friendly

near ether
#

True

slender thistle
#

Then again, it comes to preferences

near ether
#

I prefer python to teach people because it reads how you think, if that makes sense lol

earnest phoenix
#

python has a distinctive syntax from what you're going to be met with later on if you get into software engineering

#

it's also really not performant since it's interpreted code

#

Python is definitely a special child

#

not a bad one

#

just special

grizzled jackal
#

I still never bothered to try Python

earnest phoenix
#

i had basic experience with in cs

#

disliked the syntax so much

#

Yeah I've tried python for a bit, I just couldn't get used to it at all

mossy vine
#

depends on the developer

earnest phoenix
#

just make your own

#

learning is free

mossy vine
#

not everyone wants to or should learn

earnest phoenix
#

pssh

#

what even is it

#

you might be able to find something on https://top.gg/ if its not insanely specific

loud salmon
#

dbl needdev @winged rapids

covert turtleBOT
#

DBL is not a place to find developers for jobs. You can try and put a request on Fiverr or Freelancer. Please do not post the request again. Doing so may result in punishment.

winged rapids
#

Dude I am just trying to see a price for now

loud salmon
#

We aren't the place for that kind of commerce

#

sorry :/

winged rapids
#

Like a average I’m not asking for anybody to make it right now

raw sail
#

why my bot is n't verifyed to now

#

?

loud salmon
#

it takes a week or more @raw sail

raw sail
#

really?

loud salmon
#

yes

raw sail
#

u can't verify it now?

#

plzzzzz

loud salmon
#

no, because there are around 200 other bots to review @raw sail

#

there is a line

#

you must be patient

raw sail
#

k tnx man

#

shy glen
#

Efficiency at it's best.

data.timestamp = data.timestamp ? new Date() : undefined;

Now instead of typing timestamp: new Date() I can type timestamp: true

valid frigate
shy glen
#

I save 5 valuable characters

slim heart
#

If you’re gonna do that why not do
timestamp = timestamp.data || new Date()

#

So you can just leave timestamp undefined unless u want a certain time