#development

1 messages ยท Page 1564 of 1

hazy shale
#

i used to use it but it stops suddenly and cuts the whole program

crystal wigeon
#

actually i could really use a code review xD, well its gcp VM i dont think the internet is bad..

#

i upgraded it to 16GB 4vcpus

#

and a separate sql instance of 7.5GB and 2vcpus, i figured the bottleneck is not from the DB side

quartz kindle
#

gcp is soo expensive lul

crystal wigeon
#

yeah

quartz kindle
#

how big is your bot?

crystal wigeon
#

its growing rapidly

#

it was 1800 users last night

#

and its 2.1k now

quartz kindle
#

thats voice connections?

#

or what

crystal wigeon
#

the ping kinda fluctuates

#

no no

#

not voice connections

quartz kindle
#

4k ws ping is horrible

crystal wigeon
#

ikr but it fluctuates

earnest phoenix
#

Hello

quartz kindle
#

and 600 servers is very little

earnest phoenix
#

Please Help Me

crystal wigeon
#

really not sure why it keeps lagging

#

also i noted that whenever i send a message embed, it takesd more than 3sec even tho the data already computed

quartz kindle
#

well if your ws ping is 3k, that explains it

#

it takes 3 seconds for the command to reach your bot

crystal wigeon
#

why is the ws ping 3k in the first place ;-;;

#

i dont think it has something to do code?

quartz kindle
#

what is those 2.1k players?

crystal wigeon
#

2.1 users on the bot

#

rn

fickle basin
#

Hello everyone.

crystal wigeon
#

thats how many users use the bot

quartz kindle
#

thats all?

crystal wigeon
#

2.1k thats all ? ;-;

quartz kindle
#

nothing like a game or some activity?

crystal wigeon
#

its lagging a lot

#

itts a game

#

the bot

#

really think you have to try it out

#

xd

quartz kindle
#

how does the game work? what does the bot have to do with those players?

crystal wigeon
#

its an rpg game bot

#

with battles

#

and card collecting etc

quartz kindle
#

hmm

#

what operating system is your vm?

crystal wigeon
#

ubuntu

#

something like this

quartz kindle
#

have you tried measuring ram, cpu, disk and network?

crystal wigeon
#

yeah i see the graphs, the cpu util is 57% peaked today on a 16GB RAM and 4vcpu VM

earnest phoenix
#

lol

#

Hey

#

Please help me

crystal wigeon
#

the DB usage is fine, only 1GB out of 7.5

#

wait one problem at a time

#

eternal

earnest phoenix
earnest phoenix
#

I Want To Make Some Commands That Only Voters Can Use

crystal wigeon
earnest phoenix
#

How Do I Track If Someone Has Voted

quartz kindle
#

just for comparison

earnest phoenix
quartz kindle
#

my bot has 7.5k servers and runs on a single 1 core cpu, 1gb vm

#

and cpu usage is 5%

crystal wigeon
#

damn

#

what does your bot do tho

earnest phoenix
#

if has votes

quartz kindle
#

thats the issue

#

whatever your bot is doing, its possibly doing it very inneficiently

earnest phoenix
quartz kindle
#

djslight doesnt affect cpu

crystal wigeon
#

true,

quartz kindle
#

you get the same cpu with djs

crystal wigeon
#

im using djs

earnest phoenix
crystal wigeon
#

not the light ver

#

also could really use code reviews

#

since the player base keeps increasing and i have exams ;-;

#

so need to figure out a good vm

earnest phoenix
#

What is the docs exact name ?

crystal wigeon
#

my final exam starts next week

#

lel

quartz kindle
#

try measuing some stuff, like nethogs, htop and iotop

#

install them if you dont have them installed

crystal wigeon
#

also, how do i read htop?

#

i didnt understand a thing

quartz kindle
#

show a pic of yours and i'll show you

#

you're using 50% of a single core

#

scroll down with the arrow keys to find which process is using it

crystal wigeon
#

so its not sharing with other cpus?

#

got it

quartz kindle
#

also press F5 to view it in tree mode, its easier to understand

#

ah so your cpu is not constantly at 50%

crystal wigeon
#

yeah the client

quartz kindle
#

does it jump to 50% often? or is it always at 1% ?

crystal wigeon
#

yep

#

yes

#

it went to 99%

#

rn

quartz kindle
#

and its always the client?

crystal wigeon
#

yeah thats the bot

#

see it went to 103

#

its also going to 223

quartz kindle
#

ok

crystal wigeon
#

cpu%

quartz kindle
#

what about nethogs

#

apt install nethogs

crystal wigeon
#

gotcha

#

nethogs

quartz kindle
#

thats also a lot

#

does your bot need presences?

crystal wigeon
#

what does presences mean?

#

is it the "listening" thing thats displayed on the bot?

quartz kindle
#

to see people's activity and status

crystal wigeon
#

nop

quartz kindle
#

do you have presences enabled in your discord developer app?

crystal wigeon
#

nop

quartz kindle
#

does your bot do any downloads?

crystal wigeon
#

nop, except for lavalink where it streams YT music but it isnt using much

#

it streams audio only i presume, lavalink and erelajs

#

do you mind testing the bot? like actually using it and stuff

quartz kindle
#

ah ok, so that explains these numbers

crystal wigeon
#

you might know where its wrong

#

lavalink?

#

i even had lavalink on a separate vm

#

before

drifting wedge
#

like any ideas why?

quartz kindle
#

audio does cause huge network usage indeed, so thats fine

drifting wedge
modest maple
quartz kindle
#

now try iotop

#

install it if you dont have it

drifting wedge
#

can i fix it?

#

or just gotta wait?

crystal wigeon
#

iotop

modest maple
#

well cloudflare you can clear cache or switch to development mode

#

your browser you can clear cache for that size and storage

#

if server is caching it just restart it

drifting wedge
#

i think its cloudflare

#

cuz the other stuff works fine

#

when i update

#

wait

#

the entire /static/ folder isnt updaying

#

so i think its ngiinx

modest maple
#

i dont use nginx for anything other than the reverse proxy so cant help you much there

drifting wedge
#

uhh i dont wanna like restart the server

crystal wigeon
#

same

drifting wedge
#

so what can i do?

modest maple
#

just restart nginx?

crystal wigeon
#

well changes might require you to restart

drifting wedge
crystal wigeon
#

check for logs

modest maple
#

well then something in your implementation is wrong shrug

crystal wigeon
#

also the browser logs

drifting wedge
#

uhhh

feral aspen
#

I'd like to ask a question.

#

I am making a mute command and I basically saved a role ID into a variable named as Mute

#

Which one is correct.

#
const muterole = message.guild.roles.cache.find(role => role.id === Mute.id)

// or
const muterole = message.guild.roles.cache.find(role => role.id === Mute)
#

Which one is correct?

#

The second one?

cinder patio
#

Neither. Use get if you have a role's id to get the object

feral aspen
#

Basically I have the user be able to set a muted role for his server.

#

And once he set the muted role, the role ID will be saved.

#

The role id is considered as server.mutedRole

#

server.mutedRole = Mute Role ID

#

Now for the mute command to work, should I use get or find?

#

I did this.

const muterole = message.guild.roles.cache.find(role => role.id === server.mutedRole);
cinder patio
#

you can use both, but using find is way slower, because role objects are already paired with their ids

#

so use get

feral aspen
#
const muterole = message.guild.roles.cache.get(server.mutedRole);
#

Like this?

cinder patio
#

yes

feral aspen
#

and the server.mutedRole is the muted role ID.

#

I will be trying now! ๐Ÿ˜Š

midnight spoke
stable nimbus
#

Is there a way to get discord.js to communicate with github and update the code with a command?

summer torrent
#

Like running git pull ?

stable nimbus
#

Yes, automatically running git pull with a command.

#

I can't find any documentation on it or I am just blind af

summer torrent
#

it is not related with discord.js. You can create a exec command which executing command

cinder patio
#

Look into the child-process built-in module

summer torrent
#

use built-in module

cinder patio
summer torrent
#

require("child_process").exec("git pull")

stable nimbus
#

Okay.

summer torrent
stable nimbus
#

Okay, thank you.

#

So the child process will send a message to the chat or will I have to program that myself?

cinder patio
#

The child_process module is for executing shell commands

summer torrent
#

yes you have to code it

feral aspen
#

Doesn't work.

cinder patio
#

Better to do !server.mutedRole in case it's undefined and not null

stable nimbus
#

Okay, how would I get it to post the results then? I never used child_process before.

cinder patio
stable nimbus
#

Okay, how would I put that in a message?

cinder patio
#
    // stdout is your result
});
stable nimbus
#

Okay, thats what I need.

#

Thats perfect thank you.

feral aspen
#
            const muterole = message.guild.roles.cache.get(server.mutedRole);

            if(!server.mutedRole) {
                return message.channel.send("No mute role")
            }

do I make it !muterole instead?

cinder patio
#

both work, but in the future you may have to fetch the role instead of getting it from the cache, so checking if the server.mutedRole is missing first is better

feral aspen
#

Ok.

#

I will do it, one second.

#
if(server.mutedRole === null) {
        message.channel.send("You have not set a muted role.");
}

const muterole = message.guild.roles.cache.get(server.mutedRole);
#

Is that the correct order?

cinder patio
#

yea

#

but like I said earlier, use !server.mutedRole instead

stable nimbus
#

What database are you using?

earnest phoenix
#

Hello

stable nimbus
#

@cinder patio Thank you! It does exactly what I need it to do.

earnest phoenix
#

Can You help me with on_dbl_vote

stable nimbus
#

Majority d.js here.

earnest phoenix
#

lol

eager crag
#

Hi

feral aspen
cobalt spruce
#

lol

#

thanks u for helping alot

cinder patio
#

np! โค๏ธ

feral aspen
#

GoogleFeud, I have done it all

            if(!server.mutedRole) {
                return message.channel.send("You have not set a muted role.")
            }

            const muterole = message.guild.roles.cache.get(server.mutedRole);

Sometimes people put wrong role ID and makes the bot error, is there an if statement that checks if it's a valid role?

cinder patio
#

You should also check if muterole is undefined

feral aspen
#

Didn't !server.mutedRole check the problem already?

cinder patio
#

That only checks if there's a role id in the database

feral aspen
#

Oh, so !muterole?

cinder patio
#

oh, wait.. where do people put the wrong id? You're not using any user-provided arguments in the snippet

feral aspen
#

People will be able to provide a valid role by using my !config command, but if they somehow outsmart the bot and do stuff, I want to do an if statement just to be safe you know, that's why.

cinder patio
#

You should put a check in !config if the role is valid, and in the snipped above, too

feral aspen
feral aspen
cinder patio
#

An if statement checking if muterole is falsey should be enough

feral aspen
#
if(!muterole) return "Mute role is not a role or whatever."
#

I put that after declaring it, okay I'll try it out.

cinder patio
#

yup, but make sure to also send the string

#

to the channel

feral aspen
#

The message right?

#

Yes I know.

lyric mountain
#

@crystal wigeon did u find the cpu issue?

feral aspen
#

It works! ๐ŸŽ‰

#

Thanks! ๐Ÿ˜Š

fierce ether
#

pluginsautomod: true if plugins and automod are both objects how can i get there, because i cant use .?

earnest phoenix
#

show your entire object structure

fierce ether
#
await client.updateGuildData(message.guild.id, {
   pluginsautomod: true
            })```
cinder patio
#

That's mongodb right?

lusty quest
#

looks wrong for mongodb

fierce ether
#

yes, i tried js await client.updateGuildData(message.guild.id, { plugins.automod = { enabled: true, ignored: [] }; })

cinder patio
#

plugins: { automod: { ... } }

fierce ether
#

oh

#

its not updating for some reason tho

cinder patio
#

show the updateGuildData function

fierce ether
#
async updateGuildData({ id: guildID }, settings){
    let guildData = (await this.guildsData.findOne({ id: guildID }));

 if(!guildData) {
        guildData = new this.guildsData({ id: guildID });
       this.databaseCache.guilds.set(guildID, guildData);
   } else {
       await this.guildsData.findOneAndUpdate({ id: guildID }, settings);
       return guildData;
   }
}```
#
this.guildsData = require("./models/Guild")```
cinder patio
#

You need to do {$set: settings}

fierce ether
#

inside the function or the call?

cinder patio
#

inside of the findOneAndUpdate call

fierce ether
#

same thing

cinder patio
#

Are you sure you're refreshing the collection?

woven hamlet
#

anyone here work with python?

modest maple
#

dont ask to ask

woven hamlet
#

well then

earnest phoenix
#

why?

woven hamlet
#

this is just going to be a dumb question but is it possible to assign an if statement to a value like this? ```py
value = if ctx.author.id is self.config.owner

modest maple
#

value = <true condition value> if condition else <other value>

#

value = "foo" if bar == "baz" else "foobar"

earnest phoenix
#

python has more vb syntax than vb has vb syntax

#

finna be writing with a whole ass english dictionary

modest maple
#

yeahhh generally you dont see that sorta stuff

modest maple
#

you see

value = X or Y
though

#

bro

earnest phoenix
#

Lol

modest maple
#

i litterally just say yes and demonstrate how it can be used and you say no

woven hamlet
#

i think i might just pull a big brain move just to make user acknowledgments

modest maple
#

my god its painful

mental flume
#

how to i setup multiple saves for multiple servers?

earnest phoenix
#

idk

mental flume
#

xD

woven hamlet
#

yeah im just putting the if statement inside the embed

#

and then ima follow it with an elif

woven hamlet
shy turret
mellow kelp
#

hm

mental flume
#

Do you use python or js?

#

Im sorry, I'm not good ad js :(

stable nimbus
#

Does anybody know how to walk through a command folder and reload all the files?

quartz kindle
#

fs.readdir

#

for each file check if it exists in require.cache

#

delete it from the cache and re-require it

stable nimbus
#

Okay how do I do that?

#

Cause I made a command reloader, I just need it to read a whole directory now.

quartz kindle
#

show your command

stable nimbus
#
if(!cmd) {
                const embed = new MessageEmbed()
                .setAuthor(message.member.displayName, message.author.displayAvatarURL())
                .setTitle(`:warning: Error In: Command :warning:`)
                .setColor(0xFFD700)
                .setDescription(`Hey <@${message.author.id}>! That command could not be found!`)
                .setTimestamp(message.createdAt)
                .setFooter(config.copyright);
                await message.channel.send(`Hey <@${message.author.id}>!`, embed);
            }
            else {
                //
                await this.client.unloadCommand(cmd.conf.location, cmd.help.name);
                await this.client.loadCommand(cmd.conf.location, cmd.help.name);
                client.logger.log(`Loading Command: ${cmd.help.name}.`, "log");
                //

                const embed = new MessageEmbed()
                .setAuthor(message.member.displayName, message.author.displayAvatarURL())
                .setTitle(`Done!`)
                .setColor(0xA1EE33)
                .setDescription(`Hey <@${message.author.id}>! I have reloaded \`${cmd.help.name}\`!`)
                .setTimestamp(message.createdAt)
                .setFooter(config.copyright);
                await message.channel.send(`Hey <@${message.author.id}>!`, embed);
#

Here is my loader:

async loadCommand (commandPath, commandName) {
        try {
            const props = new (require(`.${commandPath}${path.sep}${commandName}`))(this);
            props.conf.location = commandPath;
            if (props.init){
                props.init(this);
            }
            this.commands.set(props.help.name, props);
            props.help.aliases.forEach((alias) => {
                this.aliases.set(alias, props.help.name);
            });
            return false;
        } catch (e) {
            return `Unable to load command ${commandName}: ${e}`;
        };
    };
#

@quartz kindle

quartz kindle
#

do you know how to use fs?

stable nimbus
#

Not really. I used documentation and tutorials.

#

and.... a little open source...

quartz kindle
#

fs is a built-in node module

#

you can use it to read/write files and folders and interact with your local file system

#

fs has a function to read a folder and return the names of the files inside it: fs.readdir() and its sync version: fs.readdirSync()

#

and also a promise version fs.promises.readdir()

stable nimbus
#

And a promise ensures that it happens.

restive furnace
quartz kindle
#

no, promises have nothing to do with assurance

stable nimbus
#

Oh.

#

So using fs.readdirSync(); how would I get it to see if a file is there but not in the cache?

quartz kindle
#

the function returns a list of file names as an array

#

so you have to loop over the array and check if that file exists in your require cache

#

you probably know how to use the require cache, you should have some code for it in your unloadCommand function

stable nimbus
#

I do.

#

But, how would I define the folder?

quartz kindle
#

you give it to readdir

exotic portal
#

I need some help for setting bot vote logs. Can anyone help me please.
Language:- discord.py
Dm me if you know the same

stable nimbus
#

Through Args?

quartz kindle
#

fs.readdirSync("./commands")

stable nimbus
#

./commands/${folder}/?

#

(Folder would be defined with args)

quartz kindle
#

sure

woven hamlet
#

lmao fs is what made me switch from js to python

cinder patio
#

why lmao it's so easy

stable nimbus
#

@quartz kindle So this is what I have:

const folder = args.slice(0).join('');
if(!folder) {
//Returns an error
}
else {
fs.readdirSync(`../../commands/${folder}`);
woven hamlet
#

i think it was because i got mad at it for not reading the directories to make a better help command

mellow kelp
#

recursion is always your friend gokart_doggo

quartz kindle
#

then files will be an array of file names in that folder

stable nimbus
#

Okay, fixed.

quartz kindle
#

also, if you're giving it a user defined folder, use a try catch

stable nimbus
#

Now what?

quartz kindle
#

because it will throw an error if the folder was not found

stable nimbus
#

I should do that huh.

#
try {
if(!folder) {
//error
}
else {
const files = fs.readdirSync(`../../commands/${folder}`);
}
catch (e) {
console.error(e);
return message.channel.send(`error`);
}
#

Hows that?

modest maple
#

please tell me that discord is just removing your indents?

stable nimbus
#

Yes it is.

woven hamlet
#

lmao so unclean and impure

stable nimbus
#

Trust me I love my indents.

tired panther
#

lol someone pinged me again ping_triggered

stable nimbus
#

@quartz kindle Does that look right?

earnest phoenix
#

is
Intel(R) Xeon(R) CPU @ 2.30GHz
Good for a discord bot?

stable nimbus
#

Yes

#

Thats what my bot runs on.

earnest phoenix
#

ok

stable nimbus
#

And thats what I'm connected to lmao

quartz kindle
#

even an atom cpu can run a discord bot

#

even an arm64 cpu can

stable nimbus
#

A rasberry pi can as well.

earnest phoenix
#

alr

#

thanks

quartz kindle
#

if you're looking into buying a vps, dont fret so much about cpu

#

ram will give you more issues

stable nimbus
#

It will always be RAM.

modest maple
#

ehhh to a point

#

it wont always be ram

stable nimbus
#

True

modest maple
#

if you have members intent off CPU suddenly becomes a more reasonable factor with growth

lusty quest
#

at some point you will just get I/O locked

fierce ether
#

is there a way of adding a user to your mongo db?

lusty quest
#

yea

#

did you do it commandline or did you use Atlas?

fierce ether
#

atlas

stable nimbus
lusty quest
#

you can manage them over the webinterface, but i cant say where exactly

quartz kindle
stable nimbus
#

@quartz kindle

quartz kindle
#

well, the error says it all

stable nimbus
#

Even though the directory exists.

pale vessel
#

if it's a valid directory, try using `${__dirname}/../../commands/Civilian`

stable nimbus
#

I start in my administration folder, then I need to step out into my commands folder and get that one. I might be going too far back.

#

But I also put it before commands so

stable nimbus
#

Loading it up like that now

#

I think it worked! I didnโ€™t get any console logs about the files being unloaded or loaded tho so

#

@pale vessel

#

Yup it works!

#

Thanks guys, sorry I was such a pain.

fickle basin
#

When I make the command an on_message event it still does not work.

earnest phoenix
#

did you take those with a microwave

fickle basin
#

Alright

summer torrent
fickle basin
#

I will delete these and bin it

midnight spoke
#

https://sourceb.in/Bu0hcqUg8M
Getting a problem with my " tempmute command "
After I mute someone for like 1 hour .. its unmute him less than a sec
How I can fix this ??!

fickle basin
#

I am not sharing it. I was asking a question

modest maple
#

it wasnt a question it was a statement but sure

fickle basin
#

https://paste.mod.gg/doyuyiyuhu.py No, I asked a question... I asked what I was missing inside my bot.command codeline because the event works, but even when I turn the command into another event, it does not seem to want to do it's function.

#

It is like Pycharm is not letting me call upon multiple actions or events or commands.

modest maple
#

no

fickle basin
#

Wdym by that? I can run multiple commands and events on my other bot.

#

It is set up properly

#

It is the coding itself

modest maple
#

blobpain Maybe you should read the link

#

cuz i can guarantee you're code is causing the error lol

fickle basin
#

I know it is too, but that is strange because my other bot uses just bot.command and bot.event, no .process required

modest maple
#

again, you do... if you're overriding the event that the commands require mmLul

fickle basin
#

Well I get that, but my other bot does not have it and it runs all events and commands fine

#

Which is why I was confused

modest maple
#

The framework's system hasnt changed majorly in the last 2 years it behaves the same way regardless

#

you either have a listener or are processing the messages or just not using a message event at all mmLol

fickle basin
#

I have my other bot in another server lmfao

#

It works

modest maple
#

again, you're point doesn't matter lol The framework doesn't magically behave differently for a different bot

fickle basin
#

Again, your point doesn't matter because it is in a damn server rn and IS WORKING x'D

#

I can .bin the code and show it to you

modest maple
#

sure blobpain

mellow kelp
#

i just read this last conversation

#

this is an extreme bruh moment

fickle basin
#

I basically used the RedM Help Bot coding for Project Rin, but for some reason it hasn't been working on Project Rin, just RedM Help Bot.

obtuse jolt
#

how can I send at everyone + an embed

#

without sending 2 messages

pale vessel
#

channel.send(content, { embed })

lyric mountain
#

btw, define "send at everyone"

obtuse jolt
fickle basin
#

Okay I see my issue, possibly.. The Help Bot coding says it is somehow saved as .sql when it is .py.. Idk. I have just never ran into this issue before while developing.

quartz kindle
#

are you developing on windows?

fickle basin
#

Yes

quartz kindle
#

do you have file extensions enabled?

fickle basin
#

Nope

quartz kindle
#

enable them

lyric mountain
#

lul

#

solved

fickle basin
#

I have the py extension ienabled

#

*enabled

#

Not sql

lyric mountain
#

he doesn't mean that

modest maple
#

thats just using commands

lyric mountain
quartz kindle
lyric mountain
#

damn tim

fickle basin
#

So on_message is what needs overriden?

quartz kindle
#

lmao

modest maple
#

override on_message removes it's internal event

#

which is what the commands use by default

#

interally it

glacial pagoda
#

I need help, Everytime I Type a message it puts out those reactions but i want the reactions to come when im mentioned

#

How

modest maple
#
async def on_message(self, message):
  await self.process_commands(message)
pale vessel
#

don't you have to use process_commands() or something

#

lul

#

okay then

fickle basin
#

Gotcha

quartz kindle
fickle basin
#

I thought I used on_message in Help bot..

quartz kindle
#

.first() is not a filter

fickle basin
#

Guess not Facepalms

glacial pagoda
quartz kindle
#

you need to check if the mentioned id is equals to the id you want

#

or .has also works yes

glacial pagoda
#

Ok

fickle basin
#

But it does say the Help Bot is Sql and the other one py lmao So I will have to go fix that too

#

Anyway, thanks. Just feel really dumb rn.

#

*I just

modest maple
#

i mean you did decide to question someone with significantly more experience than you mmLol

fickle basin
#

Yeah but that isn't why lmao. It was because I thought I used on_message in the help bot

#

I was just over-looking too much too fast

wicked pivot
#
if (message.member.presence.activities.find(a => a.type === "CUSTOM_STATUS")) {
            if (array.some(link => message.member.presence.activities.find(a => a.type === "CUSTOM_STATUS").state.includes("discord.gg/" + link))) {
            }
        }```


``` TypeError: Cannot read property 'includes' of null```
fierce ether
#

your trying to access a property that is null

wicked pivot
#

how to check if a user has a status? @fierce ether

lyric mountain
#

do you have GUILD_PRESENCES intent enabled?

oak cliff
#

@wicked pivot dont ping random people please.

wicked pivot
#

sorry"

silent cloud
#

Heyyo guys

#

After playing spotify album trough lavalink

#

I have this error

#

GaxiosError: The request cannot be completed because you have exceeded your quota.

#

It says from youtube api

pale vessel
#

Gaxios?

lyric mountain
#

.state returns an optional

#

so if it doesn't have a value, it'll return null

silent cloud
#

How i can fix it? Without waiting, if i try to play album again, it will again, so i need answer

lyric mountain
#

also, double check you have GUILD_PRESENCES intent enabled

silent cloud
lyric mountain
silent cloud
#

Oh

#

Thats node module

wicked pivot
#
if(..state !==null)``` ?
pale vessel
#

?. ๐Ÿ˜Ž

#

my favorite operator

misty sigil
#

?.?

earnest phoenix
#

is anyone else's bot not purging messages?
no other bot seems to be able to

fickle basin
#

Yeah I see now @modest maple I was putting the bot.process_commands at the bottom instead of using an else statement conjoined to the If statement. That was what I was having problems with earlier. I just misused bot.process_commands and assumed it did not need it because I misused it and took it out earlier. I apologize.

#

Which all lead me to thinking I had it in the other bot and that it ran it without it

obtuse jolt
earnest phoenix
#

well currently the Discord.js API is F*cked

obtuse jolt
#

isnt it always

earnest phoenix
#

It's back to normal again, the images send through

obtuse jolt
#

buty

#

why wont my catch statement work

mellow kelp
#

what do you mean by "won't work"

obtuse jolt
#

it does nothing

#

still get errrors

mellow kelp
#

because the .catch doesn't catch that particular error

obtuse jolt
#

discords image embed server is having fun today

earnest phoenix
obtuse jolt
#

oncall

#

poor guy

#

on a wednesday night

drifting wedge
#

when i try running lavalink

#

this is my output

#

anyone can help?

obtuse jolt
#

how can I check if the bots online

#

and if not have a response

pale vessel
#

br .catch() catches promise rejections

#

not a normal error

#

use ?.

#

actually

#

do checks

#

?. won't error

obtuse jolt
#

i only get the error when the bots offline so is there a way to like check if the bots online or not

#

because its a webserver sending requests to the bot

pale vessel
#

make sure client.user isn't null

lyric mountain
#

@earnest phoenix @earnest phoenix discord is having a seizure

#

nothing special

urban surge
#

I get an error because you can't write more than 1024 characters on a single line. Is this glitche special?

earnest phoenix
earnest phoenix
earnest phoenix
quartz kindle
#

and everything together cannot exceed 6000 characters

sharp thicket
#

Hi

sharp thicket
#

lol i was like huh is this the same tim and then i just came here cuz i knew you would be here lol

quartz kindle
#

lmao

sharp thicket
#

lol

quartz kindle
#

thank <3

sharp thicket
#

np

#

lol is it on npm?

#

@quartz kindle

quartz kindle
#

ye

sharp thicket
#

o

#

whats the install thing

#

npm i discordjs-light ?

quartz kindle
#

discord.js-light (or timotejroiko/discord.js-light if you want the master version)

eternal osprey
#

hey guys

#

https://hatebin.com could anyone please tell me why my code doesn't work properly? I mean, the console.log() does give the good id tho

#

but after that it doesn't do anything else.

umbral zealot
#

we would except that we can't see it with that link ๐Ÿ˜›

#

try saving the page first (CTRL+S)

pale vessel
umbral zealot
#

which is unfortunate.

quartz kindle
#

so many bins

opal plank
#

trash bin the most useful one

#

specially for code here

pale vessel
quartz kindle
#

recycle bin

#

:^)

opal plank
#

nah nah

#

dont even recycle that tim

#

code frm here is cursed

pale vessel
#

no you can't even recycle them

opal plank
quartz kindle
#

imagine if the fbi/cia/nsa make recycle.bin

#

a website that stores everything you ever deleted from your pc

opal plank
#

sounds about right

eternal osprey
#

owh hatebin does not work>

#

why?

#

holy shit i am stupid

quartz kindle
#

hatebin

opal plank
#

literally 5 lines above

#

lmao

eternal osprey
opal plank
#

maybe a couple more actually

quartz kindle
#

hatebin is designed to hate you

eternal osprey
#

there we go sorry,

opal plank
#

hastebin is amazing

#

but its not working rn

eternal osprey
#

i can't save anything with hastebin

quartz kindle
#

if its not working, why is it amazing

opal plank
#

shush

earnest phoenix
#

tbh i just upload the text to discord and let it do the message.txt

eternal osprey
opal plank
#

thats an array

#

with a number inside

#

what about it?

eternal osprey
#

for some reason it logs every info around, but it just does not perform the rest of the code.

opal plank
#

frick, tim, take this one, i gotta head to the market

opal plank
#

shits bout to close in 15 minutes

earnest phoenix
#

im trying to make it where i can do db.guild(guildId).member(memberId) but idk how to things

#

can someone help pls

eternal osprey
#

anyways, thanks in advance if someone can explain the problem. Ping me when someone answered please!

quartz kindle
earnest phoenix
solemn latch
#

indentation for functionality is really only a thing in python

earnest phoenix
solemn latch
#

which is why many devs dont like python

quartz kindle
#

depending what you want to do, you dont need a class for guild

#

or for dbfile

eternal osprey
#

owh

earnest phoenix
eternal osprey
#

but what would the problem be then?

pale vessel
#

python good

quartz kindle
#

also, fs db bad

#

insert slap emoji

mellow kelp
#

oh no

#

another civil war is about to start

quartz kindle
#

stonks

#

rip gme

earnest phoenix
#

...

eternal osprey
#

uhhm so all jokes aside, can someone please help me out and have a look at the hatebin?

quartz kindle
#

i'll tell you why

#

if you tell me what you plan to store on it

mellow kelp
#

fs isn't optimized for stuff like several writes at the same time

quartz kindle
#

are you storing json files?

earnest phoenix
mellow kelp
earnest phoenix
mellow kelp
quartz kindle
#

LOl

mellow kelp
#

but it would take some extra effort

earnest phoenix
#

but i can

#

so i will

mellow kelp
#

aight

quartz kindle
#

but are these text files, binary files or json files?

#

or something else?

earnest phoenix
quartz kindle
#

well thats less bad

#

the worst thing about json is its inability to be partially edited, so every single operation needs to process the entire file

#

if the file is small its not that much of an issue

earnest phoenix
#

thats why

#

rn i have like a 1.35mb json file

#

its not happy

quartz kindle
#

i had a 15mb json file

mellow kelp
#

oh no

quartz kindle
#

lmao

earnest phoenix
#

but im thinking lots of byte size json files

quartz kindle
#

just make sure your vps has a decent disk

#

because you're gonna be trashing it quite a lot

earnest phoenix
#

imagin using a vps

quartz kindle
#

google/amazon have horrible disks

earnest phoenix
#

i just host on my desktop

#

970 pro ssd

quartz kindle
#

alright

#

another tip

#

dont overwite files directly

#

write a temp file, then rename

gloomy quarry
#

Hello
How do I get the voting information?
Library Python

quartz kindle
earnest phoenix
quartz kindle
#

tools -> python

quartz kindle
earnest phoenix
quartz kindle
#

yup

earnest phoenix
#

tbh i had a bug with my code so it crashed every 3 minutes so...

quartz kindle
#

xD

mellow kelp
earnest phoenix
#

i fixed and havent had it yeet yet...

#

๐Ÿคž

mellow kelp
#

it might work with a backup system or something

#

but i mean

#

at this point i guess a proper database would be easier kek

quartz kindle
#

writing then renaming will ensure the data will be intact, as the rename operation is atomic and done by the operating system

#

and if it crashes during writing, the original file wont be affected

earnest phoenix
#

h

#

my thought was if i make it lots of small files

#

and a queue

#

it can only yeet one member in one guild at once

#

so miniscule loss

quartz kindle
#

well thats also true

gloomy quarry
#

how to get webhook_auth='password'?

urban surge
#

I did this because I exceeded the character limit, but this time it says undefined. How do I fix it?

quartz kindle
#

go to your top.gg bot edit page

#

in the webhook section

#

you write your own auth password there

gloomy quarry
#

?

quartz kindle
#

yes

gloomy quarry
#

ok

quartz kindle
#

you put there whatever you want

#

and then you put the same thing in your code

gloomy quarry
#

ok

quartz kindle
gloomy quarry
urban surge
earnest phoenix
#

you cant not have a title

quartz kindle
#

you need to have a title. if you dont want a title, you can use a zero width space

earnest phoenix
#

^^^

#

didnt realise you could do the zero width space oop

quartz kindle
#

.addField("\u200B", content here)

mellow kelp
#

that's really pog

#

hope they don't fix it

gloomy quarry
quartz kindle
gloomy quarry
#

vps

earnest phoenix
quartz kindle
#

put the vps's ip address and port

gloomy quarry
#

Which port is in the code?

quartz kindle
#

for example if in your code you have webhook_port=3000 and webhook_path="/dblwebhook"

quartz kindle
#

then your url is http://YOURVPSIP:3000/dblwebhook

gloomy quarry
#

ok (:

urban surge
quartz kindle
earnest phoenix
urban surge
#

thanks it worked

mellow kelp
#

well today i learned that a bad purge command is a really bad idea

#

some guy decided it was a great idea to delete 9999 messages and my bot's cpu usage just skyrocketed to 100%

solemn latch
#

yeah

#

purge commands are typically api abuse if over 100

mellow kelp
#

welp

#

bye bye purge command

sudden geyser
#

You reek of O(n^2)

gloomy quarry
quartz kindle
#

how

#

you mean discord bulk delete right?

mellow kelp
#

yea

quartz kindle
#

that shouldnt affect your cpu at all

mellow kelp
#

well my cpu usage went to 100%

#

maybe too many requests

quartz kindle
#

that makes no sense, its api requests, your cpu has no business doing anything, its just waiting 90% of the time

mellow kelp
#

i mean tbh i don't know how many messages the guy deleted exactly

#

but the last thing on console was a "Command 'clear' executed [...]" message

quartz kindle
#

you're not blocking anything are you? lmao

mellow kelp
#

nope pEnSiVe

quartz kindle
#

then how, it makes no sense

mellow kelp
#

no idea

#

my bot divides the message deletion into groups of 100

#

so it sends a request for every 100 messages

#

maybe a really big number could have caused too many requests?

urban surge
#

Can we put photos here without affecting the underlying text?

quartz kindle
#
for(let i = 0; i < 99; i++) {
  await channel.bulkDelete(100);
}
``` if you do something like this
#

its gonna be idle 99% of the time

#

0% cpu usage

mellow kelp
#

yeah that's what i've coded more or less

#

let me see

quartz kindle
#

blame discord

urban surge
mellow kelp
#
await channel.bulkDelete(rest);
for (let i = 0; i < extra; i++) {
  await channel.bulkDelete(100);
}
#

yeah this should have worked

#

now i got no idea how my bot crashed

quartz kindle
#

weird

earnest phoenix
#

Is anyone able to help me make a dashboard for my bot

quartz kindle
#

a dahbore

earnest phoenix
#

dashboard

#

Can soneone help me make a bot dashboard

solemn latch
#

do you have a specific question or?

earnest phoenix
#

No

lyric mountain
#

Sometimes it's handy to have a trace log

#

Or debug if you want less verbosed file

mellow kelp
#

yeah that's probably a good idea

solemn latch
# earnest phoenix No

I would start by reading the discord oauth docs then, or if you dont understand web development doing some research on that.

opal plank
# earnest phoenix No

its very hard that anyone will handhold you throughout the whole way, you need either a more specific question or ask something like what i should use

#

as far as finding someone to help co-work with you, this isnt the place. If you need guides or ask a question, then just ask for it

earnest phoenix
#

Would you like to be a developer for me

opal plank
#

this is not the place to ask for that, you'll need to hire a dev for you

earnest phoenix
#

Do you know any good servers

opal plank
#

ido not, i think the coder's den had an advertising thing somewhere

#

either that or discord bots, though that was talked about long time ago in Discord-Api

earnest phoenix
#

Ok

gloomy quarry
opal plank
#

who pinged me?

gloomy quarry
#

me ๐Ÿฅฒ

opal plank
#

im not too keen on python, only in js/ts

gloomy quarry
#

ok ๐Ÿฅฒ

drifting wedge
gloomy quarry
#

print date {'bot': '751151926959276050', 'user': '608094296595496970', 'type': 'test', 'query': '?test=data&notRandomNumber=8', 'isWeekend': False}

normal sage
#

Holdon.

gloomy quarry
#

ok

fringe pendant
#

don't you access dict elements with []?

#

or am I mistaken

normal sage
#

yes

gloomy quarry
#

yes

normal sage
#

so it should be ["user"] or ["bot"]["user"]

fringe pendant
#

data["user"]

gloomy quarry
#

im try

lyric mountain
#

hi try, I'm sora

gloomy quarry
normal sage
#

pog

blissful coral
#

Anyone use the mongoose library for js

#

Got a question

delicate zephyr
#

sup

delicate zephyr
blissful coral
#

So

#

I am trying to make a leaderboard

delicate zephyr
#

yea

blissful coral
#

But I can't seem to figure out how to find more then one schema at a time

#

Is that not possible?

delicate zephyr
#

wdym

blissful coral
#

There is

#

.findOne()

delicate zephyr
#

find()

blissful coral
#

But is there a .findMany()

#

Oh

delicate zephyr
#

find({user_id: ''}, { sort: { valueInObject: -1 } })

blissful coral
#

valueInObject?

delicate zephyr
#

placeholder

#

find({user_id: ''}, { sort: { points: -1 } })

#

etc

blissful coral
#

ah

#

So it would sort it by neg 1?

#

Or how exactly does sort work

delicate zephyr
#

I cant remember exactly

#

do some testing

#

it should basically sort -1 / 1

#

to asc / desc

blissful coral
#

When I go to the docs

#

I click on sort and it sends me here

delicate zephyr
#

hold on

#

give me a second

blissful coral
#

ok

delicate zephyr
#

-1 = ascending
1 = descending

#

by the looks of it

#

also

#

looking at the mongodb docs is kinda meh

#

I also just realised

#

the example I gave

#

was meh

#

since it was using the custom func xig build for dblstats

#

sorry

steel arch
#

"I made this on paint because i cant find nothing compared" im trying to make when i put the command "?off" that he will show in an embed that is offline but when i put "?on" this will make that on again, how can i do this, pls help me!

blissful coral
#

Off and on for what

steel arch
#

Is an example

#

Im trying to make the bot show a thing when i put the command

#

I dont know how to explain very well

blissful coral
#
//command function
//End of command
message.channel.send('command done')```?
steel arch
#

No its not that, AHHHH i dont know how to explain...

#

Dang it

blissful coral
#

Can't help if you can't explain it

steel arch
#

For example i put the command "?closed" or "?open" and when i put that command he will send that for the embed, and when i put the command "?showembed" he shows the embed, and the embed shows if its close or open. I think its this

#

Its an intuitive embed, i think

lyric mountain
#

you what?

#

you want two commands for one thing?

steel arch
blissful coral
#

Then you need a db

lyric mountain
#

well, look, what is the use-case for this?

#

like, give an example of usage

steel arch
#

Im gonna use it on a fiveM discord server, and if the guy say ?close, then in the embed he gonna show that the applications are closed

blissful coral
#
//Close command 

class close extends Command {
execute: (client, message, args) {
const db = require(``) //Require your db or if assigned to client use that instead

db.query //Or whatever you use [mysql, mongoose, etc.]
//save

message.channel.send(`Closed`)
}
)```
#

Example of close command

#

bad example but

#

Then just make a query to the db to check if it is open or closed

bitter badger
#

I have to do the bot verification and for the intents, do I need to specify like GUILDS or more specifically GUILDS -> GUILD_CREATE etc?

outer perch
#

my bot is in 100 servers, but I didn't unlock the 2 privileges

#

anything left to do?

lyric mountain
#

so you want two commands basically: an "apply" command to register yourself in something and an application manager command, which opens or closes applications right?

#

if it's closed then show an "applications are closed" error to whoever uses the apply command

#

so yeah, definitely go for databases

bitter badger
#

Actually, what are Privileged Gateway Intents? I don't currently have them enabled, but I don't really even know what the option is

raw ledge
#

Yo guys help me please

fast trench
#

What are some good vps to use? Iโ€™m finally gonna upgrade to one

solemn latch
#

galaxy gate or digital ocean

fast trench
#

Also how do I know how much ram Iโ€™ll need?

severe pike
#

just use free tier amazon aws

fast trench
bitter badger
#

That's what I use

#

It's easy and free

severe pike
#

Because its free, and amazing

raw ledge
quartz kindle
raw ledge
#

guys can someone help please

severe pike
#

Literally its perfection

fast trench
severe pike
#

because it is powerful enough to run a bot, stable, effective and free

severe pike
raw ledge
#

pls help me ur a bot dev u should know this stuff pls ๐Ÿ˜ฆ

stable nimbus
#

I need help with something, my bigger reload command (for reloading my command folders) is still fucked. Its not loading commands and its not unloading commands.

fast trench
#

Ok so what option do I choose when I look at the free tiers? There is a lot

severe pike
#

whatever u want sam

stable nimbus
fast trench
#

But some are database some are compute some are mobile. What one do I use?

severe pike
#

....

bitter badger
# quartz kindle the privileged intents are members and presences

If I've been using my bot up to this point without them enabled, I don't need to apply for them now, right? I don't think I really understand when they're actually triggered or what they may contain. The only thing I've seen is like guild member caching, but I sometimes use that to get the GuildMember from a User. I'm so confused

severe pike
#

ur not going to run a discord bot off of a database hoster are you

raw ledge
#

i did not ask for the SPoon feed i just need help there is nothing bed with this Question.

fast trench
#

Iโ€™m asking because I donโ€™t know the difference between the other options. Thatโ€™s the point

severe pike
#

google

stable nimbus
#

... sigh

raw ledge
#

Ok

#

8au

solemn latch
#

or are you just asking for general help

raw ledge
severe pike
#

Security guard i suggest going to learn how to make a simple bot before you start going for advanced ones like this...

raw ledge
#

that

solemn latch
#

you should ask something specific

mellow kelp
#

that's the entire bot

severe pike
#

^

raw ledge
#

Ok what ever guys LOOk

severe pike
#

Do you want it to respond to sentences that are predefined? Or respond like us humans do?

stable nimbus
#

Thats extremely advanced stuff, and stuff you would really do on your own. Why do you think I said to go read the docs?

quartz kindle
mellow kelp
#

they're like special permissions for your bot

stable nimbus
#

@quartz kindle I do still need help, its not doing what I thought it was doing.

bitter badger
severe pike
#

Filling out the intents form was so aids

bitter badger
mellow kelp
#

o

#

aight

fast trench
#

@severe pike so what option do you use?

severe pike
#

windows server because cba to learn linux

quartz kindle
#

F

severe pike
#

but if you know linux use that

quartz kindle
#

even if you dont know linux, you should use it

severe pike
#

eh its a headache

fast trench
#

Out of these options though? Iโ€™m really confused tbh. Digital ocean looks a lot more simple

quartz kindle
#

compute is what you're probably looking for

severe pike
#

yea compute thats it

#

not done this in like a year haha

mellow kelp
#

wait is that form something important

fast trench
#

Thatโ€™s all Iโ€™ve been asking lmao but thanks

#

@earnest phoenix not sure what you are asking? You want a one use command?

quartz kindle
#

by what definition?

#

once per user? once per server? once per channel?

#

once per hour? once per year?

severe pike
#

once per covid positive case?

quartz kindle
#

once per earthquake?

#

forever? until the bot restarts?

severe pike
#

this man asking the real Qs

quartz kindle
#

then you need a database

severe pike
#

or if you are a real pleb you can use a text file

quartz kindle
severe pike
#

๐Ÿ˜‰

neon ingot
severe pike
#

the heck is that

neon ingot
#

Yes

solemn latch
neon ingot
#

UnU

#

Mk

misty sigil
#

bruh

solemn latch
#

what kind of database do you have?

misty sigil
#

gacha cringe in dev

neon ingot
#

??

quartz kindle
#

so when a user uses the command

#

yes

#

so the next time they use it

#

check if it exists in the db

#

yes

solemn latch
#

if(check2) {
what you want to happen if its true;

}

quartz kindle
#

if(check2) return message.channel.send("you cannot use this anymore")

solemn latch
#

you should do your set after the check if they have ran it before

restive willow
#

you fix this?

drifting wedge
#

Oh ye

#

That's from ages ago

#

Wait

#

I think I didn't

#

@restive willow u know how?

restive willow
#

naw

outer perch
blissful coral
#

Well