#development

1 messages Β· Page 850 of 1

elder vine
#

Just don't do that, most likely you will API Abuse if you used timed status changing

earnest phoenix
#

Oh wait activity

#

I'm confused

elder vine
#

Yea

earnest phoenix
#

Some bots change their activites

#

And I wanna know how

elder vine
#

You can use something like this

#

const list = [
"this is one",
"this is two",
"this is three",
"this is four, and you can do more"
];

client.on('ready', () => {
setInterval(() => {
const index = Math.floor(Math.random() * (list.length - 1) + 1);
client.user.setActivity(list[index]);
}, 10000);
});

earnest phoenix
#

avoid spoonfeeding

copper cradle
#

^

earnest phoenix
#

instead instruct them on how to do it, but don't give them working code they can copy paste

elder vine
#

Well, sometimes you gotta learn code by reading code.

earnest phoenix
#

learn? they won't learn anything. they'll ctrl+c ctrl+v and forget about it

#

it's why spoonfeeding is so discouraged

#

you want to push the person to do some research for themselves and figure out how it works themselves

earnest phoenix
#

Is there a plugin to autoadd semicolons in nodejs/vsc

#

i like having em to make my code readable

delicate zephyr
#

probably

earnest phoenix
#

but i never do

#

lol

delicate zephyr
earnest phoenix
#

life saver

#

like wtf lol

zenith terrace
#

xD

warm marsh
#

@earnest phoenix use a linter?

earnest phoenix
#

/rbd/pnpm-volume/96be643d-4ea6-4656-8d52-496cc3b5a5a9/node_modules/quick.db/node_modules/bindings/bindings.js:135
on glitch

#

nvm uninstall and installed and it worked

narrow kettle
#

anyone here knows why when i press enter in spyder console it wont do anything?

earnest phoenix
#

hey ? bot.user.displayAvatarURL not working

opaque eagle
#

Just use ESLint like you should be already @earnest phoenix

warm marsh
#

When using ESLint you can force vscode to auto-lint on save.

sudden geyser
#

@earnest phoenix what version of Discord.js are you on.

finite bough
#

@earnest phoenix d.js version?

#

is 12

earnest phoenix
#

learn? they won't learn anything. they'll ctrl+c ctrl+v and forget about it
not true i actually learned alot of what i know by doing this
reading someones code and making it my own
so if i need to find out how to do a certain thing id search for it on stack or something and get the general idea then write my own code based on it

finite bough
#

add a ()

#

@earnest phoenix lets just do our job its upon them if they want to learn or not

#

if they are willing they will learn it or else they will just copy paste

#

u cant make them do anything by force

sudden geyser
#

pushing people to get and learn how to use the resources they have helps them more than just giving them the answer.

#

google is your best resource

main laurel
#

Hi guys i have a question. I am trying to optimize memory usage but i couldn't solve that. When i play a music and skip that in discord, ytdl continue to read stream from youtube. How can i solve this problem ?

gray pagoda
#

How am I able to see the bot's uptime?

#

in seconds, minutes and hours?

#

I have that, however, doesn't work

main laurel
#

in discord or console ?

#

you can define a async function and you can assign it to a variable every minute

#

with setTimeout() function

quartz kindle
#

@gray pagoda how are you calling that code?

#

and what does it return?

#

if thats all the code, then its not even returning anything

finite bough
#

didnt see u in a while tim

quartz kindle
#

long while

gray pagoda
#

@quartz kindle as a module

quartz kindle
#

i mean, show how you call it

#

the line of code where you do it

main laurel
#

var minute;

function sleep(){
return Promise(resolve =>{setTimeout(resolve,60000)});
}

client.on('ready',() =>{
while(true){
sleep().then(() =>{
minute += 1
});
}
});

tight plinth
quartz kindle
#

what the fuck

gray pagoda
#

wath?

main laurel
#

for uptime

quartz kindle
#

LOL

#

thats wrong in so many levels

main laurel
#

?

gray pagoda
#

My brain: Task failed successfuly

main laurel
#

i don't understand what is problem ?

quartz kindle
#

that code will make your process crash by infinite loop

main laurel
#

No there is promise function

gray pagoda
#

remember that I need the seconds then I do math from there to get the hour and all that, and process.uptime is a thing

quartz kindle
#

you are creating infinite promises

#

and not awaiting any of them

#

just delegating them

main laurel
#

aaa

#

sorry

quartz kindle
#

also, you dont even need to count time

main laurel
#

yes its true

quartz kindle
#

the process already does it for you

gray pagoda
#

the problem is that it overwrites it when you put it in a loop

#
const up = require('./uptime');
let currTime = parseInt(Math.floor(process.uptime()));
let arrayReturn = [];
setInterval(function () {
    arrayReturn = up.uptime.uptime(currTime, 'array');
}, 950);
setInterval(function () {
    console.clear();
    if (arrayReturn[0] > 59) {
        arrayReturn[1] = arrayReturn[1] - 60;
    }
    if (arrayReturn[2] > 59) {
        arrayReturn[2] = arrayReturn[2] - 60;
    }
    if (arrayReturn[3] > 59) {
        arrayReturn[3] = arrayReturn[3] - 60;
    }
    if (arrayReturn[4] > 59) {
        arrayReturn[4] = arrayReturn[4] - 60;
    }
    console.log(arrayReturn);
}, 875);
#

uptime has the function I sent on the ss, and returns it in an array

#
return [seconds, minutes, hours, days, months];
quartz kindle
#

why are you running a 1 second interval

#

using the same uptime

#

i see you're trying to get the time to show in the console in real time, but why?

finite bough
#

^

quartz kindle
#

that will prevent you from using the console for other things like logging

finite bough
#

well

#

not rlly

#

but

#

it spams the console

amber fractal
#

he clears console every second

finite bough
#

thats even worse

amber fractal
#

you cant log when it's constantly cleared

#

doesn't make sense

gray pagoda
#

i see you're trying to get the time to show in the console in real time, but why?
@quartz kindle I want to do it because I want to have real time info, not just a static log

finite bough
#

ik but

#

u can use somethin else

quartz kindle
#

by sacrificing your entire log capabilities?

finite bough
#

and not console

gray pagoda
#

you cant log when it's constantly cleared
@amber fractal you can, it's logging every second, then clears it

#

then log it again

finite bough
#

u can do it every hour

#

at minimum

gray pagoda
#

should I use async await?

quartz kindle
#

i mean, if you want real time info, just use a process manager

#

pm2 has a monitor mode

finite bough
#

^

quartz kindle
#

that shows uptime, among other things

#

without using the process's own console

finite bough
#

or use uptime robot

amber fractal
#

that has nothing to do with this

#

but ok

finite bough
#

i mean

#

if u r using glitch

#

no use yes

#

but else

gray pagoda
#

wat

finite bough
#

it shows the uptime

main laurel
#

you can use my code with awaiting the sleep function πŸ˜„

gray pagoda
#

we are not talking about node project hosting

quartz kindle
#

lmao

gray pagoda
#

hmmmmmmmmmmm

#

Maybe

finite bough
#

oh and tim

#

i wanted to ask u smthing

amber fractal
#

you could use any other application that monitors other applications

#

like tim said

quartz kindle
#

@gray pagoda if you do it like you're trying to do, you will lose the ability to use console.log for other things. so please dont do that lol

amber fractal
#

pm2 has a monitoring mode

quartz kindle
#

if you absolutely want to do that way, you need to create an entire logging system to not lose your other logs, which is basically reinventing the wheel

finite bough
#

like a command handler uses other command files to execute commands

#

i am adding a logging system in my bot that logs, create channel, msg delete.. bla bla

#

is it a good idea to move that shit in some other file

gray pagoda
#

@gray pagoda if you do it like you're trying to do, you will lose the ability to use console.log for other things. so please dont do that lol
@quartz kindle Then I'll try to do it every 2 seconds

quartz kindle
#

personal preference i guess @finite bough

finite bough
#

yea

#

what do u prefer

gray pagoda
#

I'd explain but idk how to, my brain made this complicated thing that I can't decrypt to english xD

#

I'll find a way to show life stats about he project and the bot

#

somehow

quartz kindle
#

ok but

#

is this code running inside the bot?

gray pagoda
#

no, I am just testing

finite bough
gray pagoda
#

no Discord.js imported

quartz kindle
#

but are you planning to put it inside the bot?

gray pagoda
#

yes

main laurel
#

My offer is still valid πŸ˜„

quartz kindle
#

then for example if you do console.log(command) or whatever, when your bot users use commands, the log will be deleted every second

#

how do you plan on dealing with that?

gray pagoda
#

it will loop, it will send an array with the last command use, and it will pass it to the console log and check if it exist, if it dosn't then not print i

#

very hard to explain

finite bough
#

commands are not the only thing which are logged

quartz kindle
#

how would you log errors?

finite bough
#

^

quartz kindle
#

how would you see past errors to fix them?

finite bough
#

well

#

if he uses vsc

#

then errors can be seen

gray pagoda
#

comment the stats

#
let lastCommand = [];
setInterval(funtion(lastCommand, time){ console.log(...); }, 2000);
// bot.on :
case 'commad':
  lastCommand.push('commad')
  break;
#

my idea

quartz kindle
#

ok but then you need to do this for EVERYTHING, all errors, all logs, all possible situations. and also, this will make your process use a LOT of cpu

gray pagoda
#

ik

quartz kindle
#

and you need to regularly clear it

gray pagoda
#

yes

quartz kindle
#

to avoid making the list too long

gray pagoda
#

yes, I allready made a sketch

#

how to fit the content

quartz kindle
#

then good luck lol

gray pagoda
#

I just need the way to get the time

#

I can get the time but then It goes like seconds: 300

#

if I do if (seconds > 59){ seconds = seconds - 60 }

#

but then it sets it to 0

quartz kindle
#

you need to call process.uptime() from inside your uptime function

#

and not store it in a variable outside

#

else it wont get updated

#

and you dont need to use -60, you can use modulo

#

75 % 60 = 15

topaz fjord
#

modulo ftw

gray pagoda
#

I did it this way: parseInt(Math.floor(seconds/60), 10);

quartz kindle
#

you are doing a huge pile of unnecessary operations

#

the whole thing can be greatly simplified

gray pagoda
#

kinda works

sullen salmon
#

When I run it myself it works fine

quartz kindle
#

wrong node.js version

elder garnet
#

what does [fs] readfile do?

sullen salmon
#

@quartz kindle you sure? It only gives this error when it's running as a cronjob

earnest phoenix
#

I have two questions
1. Why should everything change?
2. Where can I see the changes?

pl: ${bot.guilds.size} not working

quartz kindle
#

your cron job is using the wrong version

#

cron runs process as a separate user

#

so its possible that its using different settings

sullen salmon
#

Ooh

#

How do I chance this version?

quartz kindle
#

you might need to force cron to run with the correct user or the correct version

warm marsh
#
  async loadCommands() 
  {
    const dir = `${process.cwd()}/commands`;
    const files = await readdir(dir);
  
    if (files.constructor.name === 'Array' && files.length == 0)
      return;
    for(const file of files) 
    {
      let module = new (require( dir + '/' + file ))('test');
      let proto = Object.getPrototypeOf(module);
      let methods = Object.getOwnPropertyNames(proto)
        .filter(item => item !== 'constructor' && typeof proto[item] == 'function');

      for (const method of methods) 
      {
        this.commands.set(method, {
          proto,
          method
        });
      }
    }
  }```
#

Is there a better way in which I could write this?

earnest phoenix
#

I have two questions
1. Why should everything change?
2. Where can I see the changes?

pl: ${bot.guilds.size} not working

warm marsh
earnest phoenix
#

thanks

#

πŸ˜‰

sullen salmon
#

@quartz kindle can I force it to run it as just me

#

Also are you sure it's a seperate user on Ubuntu? I can't seem to find anything about this user online

finite bough
#

tim comes back and all the questions too

main laurel
#

@quartz kindle

Hi guys i have a question. I am trying to optimize memory usage but i couldn't solve that. When i play a music and skip that in discord, ytdl continue to read stream from youtube. How can i solve this problem ?Do you know the answer to this question?

sullen salmon
#

Also it pulls from my git fine so it definitely uses my ssh keys at least

earnest phoenix
#

so good that bot.guilds.size is not listed

#

why not working ?

warm marsh
#

bot.guilds.cache.size

#

?

earnest phoenix
#

WHATR

#

and that's where discordjs.guide writes @warm marsh

#

?

warm marsh
#

I don't think it's in there.

#

Just some things are.

#

best bet is checking docs.

earnest phoenix
#

okey

warm marsh
#

Most things like that use .cache now.

#

If you wish to add to the collection you need to use fetch.

cinder patio
#

I'm looking for an API for uploading images but with no authorization needed because I'll be using it client-side, if anyone has any suggestions that'd be grand

quartz kindle
#

@sullen salmon

Crontab runs shell script as root by default, that means it's using the root user node.js instead of the node version which you are using to run the script

If you have root privilege, you can check root user node.js version by,

$sudo su
$node -v

#

from stackoverflow

tight plinth
#

Petition to rename this chan "Tim's house"

sullen salmon
#

That might be outdated, but anyway root has same node as my user

quartz kindle
#

then make it console.log(process.version) and see what it outputs when it runs from cron

#

whats your current node.js version btw?

#

and how did you install it?

sullen salmon
#

12.16.1

#

I installed it with apt but that installed v8 so I upgraded with npm

earnest phoenix
tight plinth
#

I mean maybe

warm marsh
#

Do decorators in plain js exist?

finite bough
#

well if u want to colour them

sullen salmon
#

Just checked with whoami and the process is definitely being run as me @quartz kindle

finite bough
#
discord.js
#

maybe like that

earnest phoenix
#

no

#

embed

finite bough
#

yea u can like .addField('```css
lol

quartz kindle
#

@sullen salmon but did you test the node process version from within the script? because the error you posted is related to that

finite bough
#

thats a hyperlink

sullen salmon
#

@quartz kindle I'm on mobile so it would be a hassle to do that so how would that help exactly

quartz kindle
#

to confirm it lol

#

but anyway, try adding the absolute path to the correct node version in the cron job

earnest phoenix
#

how do i know what color js .addField(`Library`, `[discord.js](https://discord.js.org/#/)`, true)

quartz kindle
#

is that even possible?

prime cliff
#

yea why are you using ` and not '

earnest phoenix
#

do not know just saw it on the net

quartz kindle
#

link?

earnest phoenix
prime cliff
#

Lul

copper cradle
#

undifend @earnest phoenix I think you meant undefined

earnest phoenix
#

just because no hits were specified

quartz kindle
#

looks like discord mods idk

copper cradle
#

yeah they have client mods

#

there's no way of changing the color of a link

earnest phoenix
#

you can't do it?

copper cradle
#

nope

earnest phoenix
#

i am sad 😒

copper cradle
#

you may get banned if they discover you're using client mods

#

with they I mean discord

quartz kindle
#

imagine if discord allowed css in embeds

earnest phoenix
#

but it would have been so nice

copper cradle
#

that'd be neat

#

but like

#

a lot of smart ppl would break it

quartz kindle
#

yup

#

discord would become like old reddit

zenith terrace
#

Oof

quartz kindle
#

shurimashurimashurimashurimashurima

copper cradle
#

yeah

prime cliff
#

Imagine Discord actually listening to bot devs and adding useful stuff /s took them years to implement stuff like whitelisting pings instead of hacky methods

copper cradle
#

they should at least allow the use of full markdown

earnest phoenix
#

thanks for the information

copper cradle
#

Like having

Welcome

rules
in a channel would look neat

quartz kindle
#

sometimes its simply too difficult to add certain features

copper cradle
#

yeah

quartz kindle
#

ie: it requires a rewriting a large part of the code base

copper cradle
#

tbh they should've added it from the very beginning

prime cliff
#

Discord was not as big as this at the beginning so they probably diddn't even think of it as useful

quartz kindle
#

the absolute worst thing in software engineering is
client: "i want to add XYZ"
dev: "WHY DIDNT YOU SAY SO BEFORE??? NOW ITS TOO LATE"

copper cradle
#

well yes but they could've though about it

#

who knows

#

now, that deserves a star

quartz kindle
#

lmao

copper cradle
#

:cuddle:

earnest phoenix
#

wanna hear something even worse?

#

actually asking the client for their opinion during development, them saying it's fine, and then at the final stages complaining about the thing that they said was fine

amber fractal
#

That's why you dont ask for opinions mmLol

unique nimbus
#

Nah Cry, they say the opinion is fine but then tell your boss getting you in trouble

#

because big brain

slim umbra
#

lmao

earnest phoenix
grizzled raven
#

does pm2 monit have any effect on the processes?

heavy anchor
#

None that I noticed @grizzled raven

grizzled raven
#

ok

carmine knoll
#

I run fighting game servers. We use webhooks to get specific information when a # is used from twitter. (IFTTT runs the webhooks)
Is there a way for all post in a specific channel to receive a up/down vote? (if downvote exceeds a number the post is deleted and if upvoted it stays)
or can the bot do wehooks with this option?

late hill
#

A bot would be able to do that yes

knotty steeple
#

ok so i see d.js v12 is

#

very different from v11

#

whats this message.channel.cache stuff i see

royal portal
#

Who knows what the new 'get' is?

knotty steeple
#

or something similar to it

royal portal
#

for discord.js

knotty steeple
#

wtf does that do

#

do i cache stuff

royal portal
#

well

#

it takes the code from a site

#

res.body.file

#

it sets the image to that

#

so like random cat command

knotty steeple
#

im not asking for your get function

royal portal
knotty steeple
#

i didnt know you can do http requests with d.js

royal portal
#

oh

elder vine
#

You can just use snekfetch?

agile orchid
#

^

warm marsh
#

I thought snekfetch was dep or outdated?

pale vessel
#

yes

#

in v12 djs used node-fetch instead

grizzled raven
#

@knotty steeple cache is the collection of stuff we already had in djs 11

#

for example, client.channels.cache replaces client.channels

#

client.channels is then used as a manager, where you can fetch a channel from discord and other stuff

agile orchid
#

i think he asked the get function of snekfetch or something like that, not d.js

knotty steeple
#

dont use snekfetch then

finite bough
#

node fetch

grizzled raven
#

how many servers does your bot need to be in in order to be able to shard? or can it shard straight from 2?

oak cliff
#

technically you can shard whenever

finite bough
#

^

crimson vapor
#

you can shard at 1

finite bough
#

u can have 1 server and have multiple shards

crimson vapor
#

but there is no reason to

grizzled raven
#

ok good

#

if you shard at 2 servers with 2 shards, would you have 1 shard per server?

quartz kindle
#

depends on the server ids

#

could be 1/1 or 2/0 or 0/2

royal portal
#

does anyone know a random dog generator api

grizzled raven
#

how does it depend on the server id

quartz kindle
#

because of the formula that decides which server goes to which shard

grizzled raven
#

do you know the formula or you just know it exists?

quartz kindle
#

its detailed in the discord api

zenith terrace
#

@quartz kindle if I ever need to shard in the future im coming to you, docs or no docs xD

quartz kindle
#

lmao

#

theres a bot thats on 270 servers with 10 shards

#

and one thats on 17 servers with 8 shards

grizzled raven
#

im at 1700 and i still havent sharded

zenith terrace
#

Ooof

grizzled raven
#

i need to finish this current update first thouuuugh

quartz kindle
#

i went past 2500 without sharding

zenith terrace
#

πŸ‘€

#

How did that go

quartz kindle
#

bad

zenith terrace
#

xD

#

Imagine sharding at 17 servers

quartz kindle
#

i had to start autoleaving guilds until i finished my update

zenith terrace
#

Oof

grizzled raven
#

if im not fast enough i might--

#

nah i think im good lol

quartz kindle
#

well, took me about 3 months to go from 1700 to 2500

#

i guess you have time

zenith terrace
#

Depends

grizzled raven
#

well it took me 3 months to go from 0 - 1700

quartz kindle
#

lmao

zenith terrace
#

Took me around 5 months to go to 70

#

Hold on lemme look

quartz kindle
#

if you're using discord.js v12 just use internal sharding

grizzled raven
#

well im at exactly 100 days (woohoo) and im at 1660

zenith terrace
#

80

grizzled raven
#

by internal you mean d.js' sharding manager, right?

quartz kindle
#

nope

grizzled raven
#

or your own

#

oh

#

is it bad

quartz kindle
#

internal sharding = shard:"auto"

#

basically multiple ws connections under the same process

grizzled raven
#

so like

#

uh

#

oh wait

#

oh okay so just dont do anything and put shards: "auto" innthe client?

quartz kindle
grizzled raven
#

yeah thats what i meant

quartz kindle
#

yeah

grizzled raven
#

so it would shard, under one process.

#

?

quartz kindle
#

yup

zenith terrace
#

shards right now just to be safe

grizzled raven
#

but would it work like the sharding manager, where you can broadcast eval and have to fetch stats?

quartz kindle
#

no, you dont have to

#

all guilds are cached in the same process

#

so they are all available

#

you can do client.guilds.cache.size and get 5000+

grizzled raven
#

is it like the two client's guilds in one collection, but then to discord they have two different sets of guilds?

#

if that made sense

quartz kindle
#

nope, its all in the same collection

#

the only difference is that each guild has a shardID property

grizzled raven
#

would doing that in d.js v11 be any different?

quartz kindle
#

v11 doesnt have that

topaz fjord
#

this isn't related to bots but would it be better to use a memory cache or disk cache

quartz kindle
#

memory cache as much as possible

grizzled raven
#

i hate when i become a whitename

quartz kindle
#

disk as minimum as possible

grizzled raven
#

one last question, would you say i'm better off rewriting to discord.js v12 and then sharding, or shard now, then rewrite after

quartz kindle
#

i did both at once

topaz fjord
#

even when the items in the cache are images?

quartz kindle
#

for images it depends

grizzled raven
#

you rewrote to djs v12, sharded, then rewrote again? GWmythiBlobLUL

tardy estuary
#

i think if you suspect your bot is going to get big, go ahead.

topaz fjord
#

isn't related to bots

grizzled raven
#

well okay i'd rewrite cause i need partials lol

topaz fjord
#

but like are display the images in a grid and they get resized before being displayed

quartz kindle
#

if its like a background image for use in canvas or whatever, and that is used many times, cache it in memory. if its only accessed here and there by very specific commands, put it on the disk

topaz fjord
#

Resizing them takes a while and the app is starting to lag when scrolling

#

so I was gonna cache the resized images and only resize if the cache version isn't available

quartz kindle
#

if its a browser/client side thing, its always better to put it in the memory

#

unless its a very heavy app that takes hundreds of mb

#

@grizzled raven i rewrote to v12 while thinking about sharding as well

#

but in the end i went for internal sharding

#

my biggest concern was caching tho, because discord.js sucks at it

#

so i spent months dealing with that

grizzled raven
#

were there any problems, that i would have to look out for when i do it or nah

quartz kindle
#

depends how you want to scale it

#

traditional discord.js bots require tons of ram, which i wasnt willing to pay for

grizzled raven
#

i'd switch to djs-light but then i would have needed to fetch the users of a reaction all the time

#

starboard bot lol

quartz kindle
#

why do you need to fetch them?

#

you need their usernames?

grizzled raven
#

because i've heard that count could be unreliable

#

never actually tested - i was going to - but tonkku said it wasnt correct

#

i'll see for myself though

quartz kindle
#

yes count can be unreliable, its better to count it yourself

#

ie: fetch the messge, fetch message reactions, store message id with count, update it with reactionadd/reactionremove

grizzled raven
#

but then if the message gets uncached

#

ok see i have it where people can star the starboard message too, kinda like luca i guess

#

so then if the message gets uncached and starboard message gets another star, i'd fetch the reaction of the original message

quartz kindle
#

after you store a message once in your database, you dont need to fetch it again, except on bot start to confirm its initial number of reactions

#

i mean, thats probably how i would do it

grizzled raven
#

ok the real reason i do it anyway is because i dont have partials yet

#

but

#

if someone reacts on a message that's not in channel.messages but the message is still in a seperate collection, does the reaction count change?

quartz kindle
#

the message shouldnt be in a separate collection

grizzled raven
#

in my own collection

quartz kindle
#

hmm good question, if the message gets stored as a reference, it will update

#

objects are usually linked as references by default

grizzled raven
#

really? now im getting confused GWmythiBlobLUL

#

oh okay

quartz kindle
#

but you dont need to store the entire message object in your collection

#

you can store only the data you need

grizzled raven
#

then would it not be a reference then?

#

the message isnt in any database (yet), so wouldnt i be better off storing the whole object?

#

or nah

quartz kindle
#

i would only store ids

grizzled raven
#

so you think i should fetch the message whenever i wanna get its properties?

#

i think im going to stick with storing the message as a whole, so i wouldnt confuse myself or ruin any caching but i wanna see your take on it

quartz kindle
#

what properties would you need and when?

grizzled raven
#

for the embeds i would create about with that message

quartz kindle
#

but you only need it after X stars no?

knotty steeple
#

how can i get where an error originated from without the stack

#

aka

#

im trying to catch an error

grizzled raven
#

users can make it go to the starboard at whatever count they want

knotty steeple
#

and i want to know where its from without printing the whole stack and just the 1 file it actually came from and the line number

grizzled raven
#

so from 1-30

quartz kindle
#

i would still do it that way

#

on reaction add -> if reaction === star -> add count to message id in database, if no message id create message id in database
if message id count > threshold -> fetch message and repost on startboard

grizzled raven
#

hm

quartz kindle
#

@knotty steeple you kinda do need the stack for that

knotty steeple
#

thonkdead

grizzled raven
#

i always check stuff with the message object though, i could make a little object containing what i need

knotty steeple
#

cuz like i dont want to print

#

all of it

grizzled raven
#

is there any loss with caching the whole message?

quartz kindle
#

@knotty steeple you can catch the error, and process the stack yourself

knotty steeple
#

thats pain

quartz kindle
#
// promise example
promise.catch(e => {
  if(e.stack) {
    let text = e.stack.toString().split("\n");
    console.log(text[0])
  }
})```
#

something like that

knotty steeple
#

oh ok cool

grizzled raven
#

wouldnt that be the message?

quartz kindle
#

@grizzled raven its basically just how much ram you wanna waste with it

grizzled raven
#

error.stack, isnt that like ```js
Error: you suck lol
at Client.emit.message("whatever")

quartz kindle
#

yeah

#

the stack is the at something part

grizzled raven
#

does it just show at x in console or is it the same

quartz kindle
grizzled raven
#

so then wouldnt [0] be referenceerror: bla is not defined?

#

well either way, it doesnt matter to me i guess

quartz kindle
#

yup it would

grizzled raven
#

im getting off track xd

#

i might just stick with what i'm doing and if i get big or need more ram i could try that

quartz kindle
#

sure

small prairie
#

any way to check who banned someone WHO
d.js 11.5

#

Also on guild ban
How can i log who banned and everything

quartz kindle
#

you need to fetch the audit log

small prairie
#

On guild ban event
i fetch audit and check the latest entry

#

is that okay?

#

i mean the latest ban entry ofc

#

@quartz kindle

quartz kindle
#

something like that yeah

flat pelican
#

Uhhh

#

Not really a good idea to only check the last entry

#

On massive actions, if your bot is a bit delayed, it may fail

#

Or if Discord’s API drunk as usual

#

I usually take at least the last 3 entries

#

Or 2

grizzled raven
#

never seen eri speak here

quartz kindle
#

just check latest ban entry where target ban matches user that was banned, if that even exists

#

i've never used the audit log api lol

grizzled raven
#

is having one collection with 2 million entries better than 20 collections with 100k entries?

#

because when numbers get high i sometimes wonder

quartz kindle
#

they should be offloaded to a database way before they reach that high

grizzled raven
#

i mean say with guilds or users

quartz kindle
#

just stick with whats consistent

#

dont split the guilds collection into 20 collections for no reason

grizzled raven
#

i

#

ok idk why i asked that but i was just curious

#

xd

quartz kindle
#

its a valid question, i know what you mean

#

but afaik there is little to no difference

grizzled raven
#

okay bloblul

quartz kindle
#

having more collections will have more overhead, but its negligible

#

unless

#

you need to loop/find/scan over them

grizzled raven
#

unless

quartz kindle
#

then its better if they are split into something that can be targeted/indexed

grizzled raven
#

okay

#

if you have an array with length 2 and you fetch the first entry - [0] - would it be the same as having an array with length 400 and fetching the 49th entry - [48]

#

or length 430k and feching the 70,099th entry

#

basically, does it matter how big an array is when you fetch an entry

quartz kindle
#

when you fetch it by id or index, it shouldnt matter

#

thats what indexes are for

grizzled raven
#

okay

#

thats all of my random curiousness gone for now xdd

quartz kindle
#

xD

small prairie
feral fiber
#
fetchAuditLogs({ user: UserResolvable });```
small prairie
#

Thanks!

earnest phoenix
#

!x

#

!ixi

sick cloud
#

discord provides a color option that = 3447003 for example
how do i convert it to hex, ie. #ffffff

earnest phoenix
#

Bro databases are heard

#

there's no good tutorial

#

someone should make an easy module that does it 4 me :)

amber fractal
#

your use of the term database is extremely broad

#

there are many modules that do SQL, NoSQL, and other types of databases

earnest phoenix
#

Anyone use it before?

summer torrent
sick cloud
#

awesome ty

split hazel
#

If you have no experiences in database queries, I'd recommend sequelize

summer torrent
#

mongoose is easy to use

sick cloud
#

@earnest phoenix easyDB is an ephemeral database provider. That means that after some time, your database will be removed. By default, databases will stick around for 24 hours. If you make an account with us, the database will last for 72 hours. If you really want to keep it longer, you can upgrade your database to a persistent database for $5/month.

#

basically it'll get deleted

#

= not a persistent db

split hazel
#

That thing is a scam

earnest phoenix
#

$5 a month

#

and it's persistent

#

lol

sick cloud
#

you can buy a vps for that

#

and host your own

split hazel
#

Or you can just screw the server databases and use local, such as sqlite

#

There's plenty of easy sqlite wrappers

earnest phoenix
#

idk how to do a DB anyway, I'n tryna find a good nosql one I can install with npm and someone got a tutorial on

#

πŸ€·β€β™‚οΈ

split hazel
#

Sequelize supports sqlite as a dialect

amber fractal
#

Mongo is nosql

summer torrent
#

mongo

amber fractal
#

It's not difficult to set up either

#

On windows or linux

earnest phoenix
#

Nah, gotta be npm sir

#

long story

#

πŸ€·β€β™‚οΈ πŸ€·β€β™‚οΈ

#

I'll try sqlite

amber fractal
#

It is npm tho

summer torrent
amber fractal
#

npm i mongodb

sick cloud
#

lemme guess

#

you're on glitch

earnest phoenix
#

no

sick cloud
#

where are you hosting

earnest phoenix
#

I got an ovh vps, I just don't wanna install shit off of npm

sick cloud
#

in such case of a host like glitch/repl.it literally no db will work since you don't have write permissions on them

#

okay

split hazel
#

Honestly if you have no clue what you're doing just use something as simple as keyv which requires like 2 lines to get started, persistent and local

earnest phoenix
#

keyv

#

loo

#

Nah, I want a DB I can host on another server

sick cloud
#

why another server

split hazel
#

Then your option is to either pay, or use a local database

earnest phoenix
#

My house has a server on fiberoptic that got like 50tb

sick cloud
#

good job

split hazel
#

That's great

earnest phoenix
#

and so I can just I go to it from my vps

#

lol

sick cloud
#

host your db on the same server as your bot/etc

#

quicker speed and no security concerns

earnest phoenix
#

so buy a vps with more storage?

#

ok

sick cloud
#

dbs use little storage man

#

i run a bot with 27000 servers and use 2gb of db storage

summer torrent
#

Which db are you using

sick cloud
#

rethinkdb myself

split hazel
#

I have a database with >200,000 total entries and it uses about 20-30mb storage

earnest phoenix
#

It has like a kb of data per day per user

split hazel
#

Not much at all

earnest phoenix
#

πŸ˜’

sick cloud
#

dbs are really efficient and use little data

earnest phoenix
#

rn it's just writing to local jsons which is what I'm tryna fix rn because JSON databases are bad

#

so a DB would bring down the size?

sick cloud
#

yeah

split hazel
#

😭

earnest phoenix
#

Ok

sick cloud
#

generally

#

you don't need much storage

split hazel
#

And wont corrupt as easily

earnest phoenix
#

Funny thing is they haven't corrupted

#

lol

#

It's been a year or so

split hazel
#

That's great, still poses a threat

earnest phoenix
#

Aight ill go check out mongo

split hazel
#

Low risk or no risk i'd go for no

earnest phoenix
#

I heard they only corrupt if u write to them at the same time

#

so I just havent

#

but yeah, I want a DB anyway

#

the JSON "database" is getting huge

#

lol

split hazel
#

Not forgetting to mention it's also extremely inefficient

#

Since you're constantly reading and writing to disk

#

With FS

knotty steeple
#

YES

#

I HAVE WIFI BACK

#

EEEEEEEE

#

ok so

#

how would someone go by making command handler using classes as the command

#

does that make sense

grizzled raven
#

yes

#

but actually

#

no

#

but im smart so yes 😎

#

basically you do the exact same thing as a normal command handler

#

except you do ```js
new (require("./pathtofilelol/destroybotcommand.js"))(args)

knotty steeple
#

mmyes thats what i was doing

#

aight cool

grizzled raven
#

oh okay

#

that it?

knotty steeple
#

yes

#

except im putting all the stuff in the constructor

#

is that also ok or how ur supposed to actually do it

grizzled raven
#

however you want

earnest phoenix
#

Does anyone know how to make console.log output to the console when using pm2 to host?

knotty steeple
#

the same thing?

grizzled raven
#

you can pass everything into the super constructor of the actual command class

knotty steeple
#

yea how about in the actual class

#

cuz run being a function is ok but what about my aliases and stuff

grizzled raven
#
const Command = require("../Command.js") // Command base class
class Ping extends Command {
  constructor(client) {
    super(client, {
      name: "ping",
      aliases: ["pong", "p"]
    })
  }
}
#

something like that

#

then

crimson vapor
#

that is how I do it

knotty steeple
#

i see

#

ok thanks

crimson vapor
#
class pingCommand extends Terano.Command {
  constructor() {
    super({
      name: "ping",
      memberName: "Ping",
      description: "Find out my ping",
      usage: "ping",

      silent: true,
      cooldown: 0
    });
  }
}```
knotty steeple
#

but then whats command base

crimson vapor
#

I also have an

async run (message, args, data) {
  //stuff
}```
#

command base is annoying

grizzled raven
#
class Command {
  constructor(client, data) {
    this.client = client

    this.name = data.name
    this.aliases = data.aliases
  }
}
knotty steeple
#

oh yea makes sense

crimson vapor
#

does passing client make any sense? because it would be client from start

grizzled raven
#

depends on what you want

earnest phoenix
#

Does anyone know how to make console.log output to the console when using pm2 to host as a daemonized process?

knotty steeple
#

what console

#

huh

grizzled raven
#

in my first codeblock i passed client so then the super could define this.client

earnest phoenix
#

when I do node index.js if I have more than 4 apps infront of my command window it doesnt accept commands

crimson vapor
#

I dont because client.user could change and message.client is already defined

#

so no reason to waste

grizzled raven
#

pm2 has its own logs, do pm2 logs [id] to see them

knotty steeple
#

^

earnest phoenix
#

oh, did not know that

#

thaks

#

thanks*

grizzled raven
#

np

#

and im pretty sure if client.user changes the command will change aswell as its a reference to the original object?

#

idk ask tim

crimson vapor
#

Tim would know

#

or

#

we can try it

#

this is gonna break like all of my commands for a few mins

grizzled raven
crimson vapor
#

I dont understand

earnest phoenix
#

oh, hell yeah

#

thank you

#

its loading new commands when I use them aswell

grizzled raven
#

i think its because the object is only stored in one place in ram, and to get the object anywhere, it would reference that one place in the ram

earnest phoenix
#

star eval console.log("thenoob is a noob")

#

oh

grizzled raven
#

bad

crimson vapor
#

it works

#

does it save ram though?

#

I will find out

knotty steeple
#

oh also

#

at what times do you actually use cache

#

like msg.channel.cache

#

etc

sudden geyser
#

Are you asking your own separate question, or asking a question to a question?

knotty steeple
#

what

warm marsh
#

Caches are used when something returns a collection of common items for instance; members, guilds, channels but not the singular. message.channel.name, message.guild.channels.cache.size.

high bough
#
(node:11051) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message```Can someone help? I'm getting this for the code:
```js
if (command === "readuser") {
    if (message.author.id !== config.ownerID) {
      message.channel.send(NL3Embed);
    } else if (message.author.id === config.ownerID) {
      const user = client.users.fetch(args[0])
      message.channel.send(user.username);
    }
  }
#

I've already defined NL3Embed, don't worry about taht

hollow granite
#

It could be that it is not finding the user you are trying to find, maybe try this to verify the user exists before sending their username

if(user) message.channel.send(user.username);
high bough
#

Hmm...

#

Didn't help

hollow granite
#

then maybe it is something to do with NL3Embed

high bough
#

NL3Embed is completely fine, the other ones that uses the same embed works just fine.

#

Besides, it's not calling NL3Embed at all since the condition```js
if (message.author.id === config.ownerID)

hollow granite
#

hmm, im not sure

#

Oh i think I got it. You need to wait until you get the user until you can send it, so you should add await to it

const user = await client.users.fetch(args[0])
message.channel.send(user.username);
high bough
#

Okay, thanks

neat gazelle
#

does any one know how to fetch message by its id?

#

or delete message by its id

high bough
#

I have no idea

#

Though, this would probably work

#
channel.fetchMessage(lastmsg).then(msg => msg.delete());
#

sorry, i mean js channel.message.fetch(lastmsg).then(msg => msg.delete());

#

@neat gazelle

neat gazelle
#

do i need to do message.channel since its in the event of a message?

high bough
#

maybe, i'm not sure

#

last time i used that command it was like, 3 weeks ago

warm marsh
#

<Channel>.messages.fetch("id").then(delete code here)

#

There is an easier way.
<Channel>.messages.delete(resolved message object)

neat gazelle
#
let userID = message.channel.topic.split(" ");
let userFetch = message.client.users.cache.get(userID[0]);
let messageFetch = channel.messages.fetch(userID[1]);
let messagePop = messageFetch.split(" ").pop();
messageFetch.edit(messagePop);

TypeError: Cannot read property 'split' of null

#

help me out here. lol

#

userID[1] is the message id

warm marsh
#

You're going to have to give some context as looking at the code I kinda want to smash my head. ✌️

#

You use the topic to store id?

hollow granite
#

maybe add await?
let messageFetch = await message.channel.messages.fetch(userID[1]);

neat gazelle
#

basically trying to fetch the message by its id then edit the message with the same one without the last word

warm marsh
#

After reading the docs fetch on messages might be the wrong thing to use.

earnest phoenix
#

what the fuck

#

if you want to persistently store data

#

use a database

#

it's what they are for

neat gazelle
#

?

hollow granite
#

does it know what channel is defined as on line 3?

#

bc you might have to do message.channel.messages.fetch(userID[1]);

neat gazelle
#
let userID = message.channel.topic.split(" ");
let userFetch = message.client.users.cache.get(userID[0]);
let messageFetch = channel.messages.fetch(userID[1]);
let messagePop = messageFetch.split(" ").pop();
messageFetch.edit(messagePop);

TypeError: Cannot read property 'split' of null

#

still the same

warm marsh
#

What are you trying to split?

#

The content?

#

messageFetch.content.split

#

It fetches a message and returns a message object

neat gazelle
#

the content of the message so i can pop the last value

hollow granite
#

does it say if the error is on line 1 or 4

warm marsh
#

Try the messageFetch.content.split

#

As pretty sure it's that and if it's not that would be an error later.

neat gazelle
#

line 1

warm marsh
#

Use the console instead.

#

It's more useful as it's right with you.

#

Log message.channel

#

See what you get

neat gazelle
#

lol i was typing in the wrong channel one sec

#
let userID = message.channel.topic.split(" ");
let userFetch = message.client.users.cache.get(userID[0]);
let messageFetch = channel.messages.fetch(userID[1]);
let messagePop = messageFetch.split(" ").pop();
messageFetch.edit(messagePop);

TypeError: messageFetch.split is not a function

warm marsh
#

Like I said

#

messageFetch.content.split...

neat gazelle
#
let userID = message.channel.topic.split(" ");
let userFetch = message.client.users.cache.get(userID[0]);
let messageFetch = channel.messages.fetch(userID[1]);
let messagePop = messageFetch.split(" ").pop();
messageFetch.edit(messagePop);
#

TypeError: Cannot read property 'split' of undefined

#

line 4

warm marsh
#

Okay

#

Console.log messageFetch

neat gazelle
#
TypeError: Cannot read property 'split' of undefined```
warm marsh
#

Asd await before channel.messages.fetch

#

On line 3

#

After the =

hollow granite
#

maybe add await?
let messageFetch = await message.channel.messages.fetch(userID[1]);
@hollow granite

neat gazelle
#

its not in a async funtion tho

warm marsh
#

Make it async

#

Or use .then

neat gazelle
#

how lol

warm marsh
#

How to do what?

#

Make it async or .then

neat gazelle
#

use async

warm marsh
#

Add async before the function keyword.

hollow granite
#

async function myFunction() {//code}

warm marsh
#

Or if you use a lambda async () =>

#

But first, might be good learning basic js. As it will help a lot.

#

Or re-learn.

#

JS arrow function not lambda

neat gazelle
#

one sec

#
async function myFunction() {
     let userID = message.channel.topic.split(" ");
     let userFetch = message.client.users.cache.get(userID[0]);
     let messageFetch = await channel.messages.fetch(userID[1]);
     let messagePop = messageFetch.split(" ").pop();
     messageFetch.edit(messagePop);
}
myFunction();
node_modules\discord.js\src\rest\RequestHandler.js:170:25```
#

@warm marsh @hollow granite

warm marsh
#

The error is self explanatory

#

Fetch takes fetch query options

#

Read the docs for understanding

neat gazelle
#

d.js docs?

warm marsh
#

Scroll to fetch

#

Message wasnt found so the id is incorrect

neat gazelle
#

but it is correct. so hold on my bad. the message that its fetching by its id is actually in a different channel. is that the problem here?

#

@warm marsh

warm marsh
#

Yes

#

If channel doesn't equal the channel that you're fetching the message from

#

The variable channel

#

Not the channel you're getting the id from

neat gazelle
#

do i need to make a new variable getting the channel that the message is in then doing variable.messages.fetch??

warm marsh
#

No

neat gazelle
#

on line 4

warm marsh
#

Just make sure channel is equal to a resolved channel

#

The channel being the one with the message in

neat gazelle
#

but its always going to be in 2 different channels.

warm marsh
#

Then resolve it by using fetch

#

const chan = message.guild.channels.fetch(chanid)

#

chan being the channel variable

neat gazelle
#

so then do

let messageFetch = await chan.messages.fetch(userID[1]);
warm marsh
#

Yes

neat gazelle
#

aight one sec

#
async function myFunction() {
     let userID = message.channel.topic.split(" ");
     let userFetch = message.client.users.cache.get(userID[0]);
     let channelFetch = message.guild.channels.fetch('694833153617166438');
     let messageFetch = await channelFetch.messages.fetch(userID[1]);
     let messagePop = messageFetch.split(" ").pop();
     messageFetch.edit(messagePop);
}
myFunction();

(node:14056) UnhandledPromiseRejectionWarning: TypeError: message.guild.channels.fetch is not a function

warm marsh
#

Check the docs, I'm going to head to bed. Good luck.

neat gazelle
#

thanks for you help tho. im pretty close now because of you

robust moth
earnest phoenix
#

serverQueue.songs[0].url how do i cut the id https://www.youtube.com/watch?v=RKW6rjnYEkc

#

RKW6rjnYEkc

neat gazelle
#

@warm marsh i was able to figure it out now. thanks for the help

hollow granite
earnest phoenix
#

k thx

#
      const serverQueue = message.client.queue.get(message.guild.id);
      const vurl = serverQueue.songs[0].url;
      const vidid = vurl.split("https://www.youtube.com/watch?v=");```is this right ?
tight plinth
#

Waaaaaaat

#

Just do.split('v=')

earnest phoenix
#

k

tight plinth
#

Wait no

#

@earnest phoenix

#

If server Queue.songs[0] is already defined, serverQueue.songs[0].id should exists

earnest phoenix
#

ik but it doesn't work

#

other wise why would i do that

tight plinth
#

How do u define song

earnest phoenix
#
        song = {
          title: songInfo.title,
          url: songInfo.video_url,
          duration: songInfo.length_seconds,
          vidid: songInfo.video_id```
tight plinth
#

vidid is already defined

#
const song = {
		  id: video.id || video.video_id,
		  title: video.title,
		  url: video.video_url || "https://www.youtube.com/watch?v=" + video.id,
		  duration: `${minute}:${seconds}`,
		  author: {
id: message.author.id,
username: message.author.username
}
		} ```
#

Like thzt

earnest phoenix
#

hmmm

tight plinth
#

why vote is marked unused

#

weird

#

hmmmmmmmmmmmmmm

#

oh

barren swallow
#

Ye see?

#

You*

tight plinth
barren swallow
#

πŸ˜„

hallow sandal
#

when I make an anti spam feature, what would I need to put in the anti_spam define for python?

slender thistle
#

I assume you want a dictionary

hallow sandal
#

pretty much

high bough
#

There has been some issues...

(node:163) UnhandledPromiseRejectionWarning: SequelizeDatabaseError: SQLITE_IOERR: disk I/O error
```help?
#

Code? @earnest phoenix

#

Hmm...

#

I think after using ```js
message.guild.owner

Something like this :
```js
message.guild.owner.tag
```? If that's not the issue, then I have no idea.
#

Or maybe actually you didn't have the message.guild.owner cached

#

Maybe you should fetch it first, idk.

cinder patio
#

owner can be null

#

use ownerId and fetch the owner

finite bough
#

works for me

high bough
#

Can u tell me how to make the eval command?

#

I got issues with mine

#

Tons of issues

elder vine
#

Tell me about it

#

Any errors?

compact tundra
#

hey my bot is listed as offline while still being online this only happens when i daemonize the node file is there something i’m doing wrong

elder vine
#

If it was offline for a while, it might have been shown as offline. Just wait, and the website should update it after some time.

compact tundra
#

well has been online for an hour but it only shows that it’s online when someone interacts with the bot

modest maple
#

isnt that like

#

the purpose of daemon threads?

#

they run in the background using as little as possible reasources

#

then when somthing happens that it actually needs todo loads up and does stuff

compact tundra
#

yeah that’s the reason that i daemonized it

modest maple
#

well then

#

problem solved

compact tundra
#

o wait

#

i know what i done wrong

high bough
#
TypeError: Cannot read property 'execute' of undefined
```Can someone tell me what happened?
#
 if (!message.guild || message.channel.type === "dm" || message.author.bot || message.author === client.user || message.webhookID)
    return;
  if (message.content.toLowerCase().startsWith(config.prefix)) { //I'm using config.json to store my prefix
    const commandName = message.content.slice(config.prefix.length).toLowerCase().split(" ")[0].toLowerCase(); //k
    const args = message.content.slice(config.prefix.length).split(" ").slice(1);
    const command = client.commands.get(commandName);
    try {
      await command.execute(client, message, args, Discord, config, eco, leveling, db, avatarURL, footer, clientname, NL3Embed, DevEmbed);
    } catch (err) {
      console.log(err);
    }
  }
  return;
#
//Locator and Link + Configuration
const fs = require("fs");
const Discord = require("discord.js");
const client = new Discord.Client();
require("dotenv").config();
const config = require("./config.json");
var eco = require("discord-economy");
var leveling = require("discord-leveling");
var db = require ("./db.json")

//Important Embed Pieces
var avatarURL =
  "https://cdn.discordapp.com/avatars/683597011693469698/d9733c732d874e5137a9738b21d54acd.webp";
var footer = "Β©Mineko | v1.5.2 Beta | 31 Loaded Commands";
var clientname = "Mineko";

//Other Variables
if (client.guilds.cache.size === 0) {
  var clientactivityset = `Booting up System... ${footer}`;
} else if (client.users.cache.size === 0) {
  var clientactivityset = `Booting up System... ${footer}`;
} else {
  var clientactivityset = `)help | ${client.guilds.cache.size} guilds | ${client.users.cache.size} total users`;
}

//Command Ban Embed
const NL3Embed = new Discord.MessageEmbed()
  .setAuthor(`${clientname}`, `${avatarURL}`)
  .setColor([173, 216, 230])
  .setDescription("Command restricted to Developers only.")
  .setFooter(`${footer}`, `${avatarURL}`);

//Dev-Lock Embed
const DevEmbed = new Discord.MessageEmbed()
  .setAuthor(`${clientname}`, `${avatarURL}`)
  .setColor([173, 216, 230])
  .setDescription(
    "This Command is still under development, it will be available soon."
  )
  .setFooter(`${footer}`, `${avatarURL}`);
#
module.exports = {
  name: "say", //command name
  async execute(client, message, args, Discord, config, eco, leveling, db, avatarURL, footer, clientname, NL3Embed, DevEmbed) {
   ///Command Starts Here
    if (message.author.id !== config.ownerID) {
      message.channel.send(NL3Embed);
    } else if (message.author.id === config.ownerID) {
      if (isNaN(args[0])) {
        var user = message.mentions.users.first();
        if (!user) {
          var user = message.author;
        }
      } else {
        var user = await client.users.fetch(args[0]);
      }
      var amount = args[1];
      var cmdusage =
        "Please use  `" + `${config.prefix}` + "give` `<user>` `<amount>`";
      if (amount < 0) {
        return message.reply("That's subtracting!");
      } else if (isNaN(amount)) {
        message.channel.send("That's not a valid Number!");
      } else if (!user) {
        return message.reply(`${cmdusage}`);
      } else if (!amount) {
        return message.reply(`${cmdusage}`);
      } else {
        var output = await eco.AddToBalance(user.id, amount);
        message.channel.send(
          `${message.author} gave ${amount} to ${user}. Newbalance : ${output.oldbalance} >> ${output.newbalance}`
        );
      }
    }
  }
}
twin iron
#

await command.execute(client, message, args, Discord, config, eco, leveling, db, avatarURL, footer, clientname, NL3Embed, DevEmbed);

#

TypeError: Cannot read property 'execute' of undefined

high bough
#

Yes

knotty steeple
#

why did you give all that code

high bough
#

IDk, i felt like it was needed

twin iron
#

you just have a probleme with your function

high bough
#

you just have a probleme with your function
@twin iron Where?

twin iron
#

in the last code clock

knotty steeple
#

no

#

the first

high bough
#

Which piece did i miss?

twin iron
#

async function execute(client, message, args, Discord, config, eco, leveling, db, avatarURL, footer, clientname, NL3Embed, DevEmbed) {

#

use that instead async execute(client, message, args, Discord, config, eco, leveling, db, avatarURL, footer, clientname, NL3Embed, DevEmbed) {

high bough
#

umm, okay..?

knotty steeple
#

wait

high bough
#
 async function execute(client, message, args, Discord, config, eco, leveling, db, avatarURL, footer, clientname, NL3Embed, DevEmbed) {
                 ^^^^^^^
SyntaxError: Unexpected identifier
knotty steeple
#

the last codeblock is just a normal command right

twin iron
#

ah no sorry its a method

high bough
#

Yes

knotty steeple
#

then the first is how you run your commands?

high bough
#

Yes

knotty steeple
#

maybe it cant get the command then for some reason

high bough
#

Also, I would like to point out that my other commands are just fine

#

When it loads, no error, but when i execute it, it comes out as an error

knotty steeple
#

can you log what commandName is

#

before you execute

high bough
#

No.

#

I don't think so

knotty steeple
#

what

#

oh and there is a bunch of stuff u should actually not be doing

#

beside that

#

why do you pass all of those args

#
var eco = require("discord-economy");
var leveling = require("discord-leveling");
var db = require ("./db.json")
#

var

#

goddamn var

#

and a json database

twin iron
high bough
#

and a json database
@knotty steeple Static Database

knotty steeple
#

oh

#

ok

#

thank god

high bough
#

I use sqlite

knotty steeple
#

also discord-economy

high bough
#

yes

#

and discord-leveling

knotty steeple
#

it isnt that hard to handle economy yourself

high bough
#

Which i played with like hek

#

it isnt that hard to handle economy yourself
@knotty steeple I didn't know, I'm a nub

white gate
#

@high bough module.exports = {
name: "say",
execute: async function(client, message, args, Discord, config, eco, leveling, db, avatarURL, footer, clientname, NL3Embed, DevEmbed) {
...
}
}

knotty steeple
#

js is weird with its errors

earnest phoenix
#

No πŸ€”

high bough
#

@high bough module.exports = {
name: "say",
execute: async function(client, message, args, Discord, config, eco, leveling, db, avatarURL, footer, clientname, NL3Embed, DevEmbed) {
...
}
}
@white gate I fixed it already

#

It was that the command is addbalance but the name was say

nocturne grove
#

Hey. Does anyone know in what way collections like client.channels and client.guilds are ordered? (Discord JS)

high bough
#

Number

#

Of ID

#

Or Name

#

Depending how you order it

knotty steeple
#

the default

nocturne grove
#

I did not order it

high bough
#

By default it's generally ID

knotty steeple
#

check it out yourself

nocturne grove
#

but I checked it, well let's do it again

#

ohh well I see it now

#

it's ordered like this:

-first made channel
-second made channel
- ...
second guild it joined
-first made channel
-second made channel
- ...
last guild it joined
-first made channel
-second made channel
- ...```
narrow kettle
#

[python]anyone have any idea how to fix this error?
[Errno 2] No such file or directory

#this function gets a file full of number from one to n, not sorted, but one of the numbers are missing, suppose to find the number, add it to another file and return it.
# file_name tpye - str
def who_is_missing(file_name):
    fille = open(file_name, 'r')
    string = fille.read()
    string.replace(',', '')
    my_list = list(string)
    fille.close()
    my_list.sort()
    for x in range(0, len(my_list)): 
        my_list[x] = int(my_list[x])
    num = my_list[-1]*(my_list[-1] + my_list[0]) / 2 - sum(my_list)
    new_file = open("found.txt", 'w')
    new_file.write(str(int((num))))
    new_file.close()
    return int(num)

print(who_is_missing(r"D:\codes\nums.txt"))

and yes, this file exist, i didnt just put a random path

lofty grotto
#

How do I get out of Discord v12 and go to v11? which command on the console?

tight plinth
#

npm i discord.js@11.6.3

lofty grotto
#

Thanks

main laurel
#

Hi i am using latest ytdl-core version and i am trying to optimize my code for memory usage . I want to clean buffer of the stream data. How can i do that ?

#

i am using node.js

quartz kindle
#

if you are storing a buffer in a variable/array/object, you can simply rewrite the value to null

#

if you're using streams directly, make sure they are not stored in any persistent variable after they end

#

anything that is not stored or referenced in a persistent variable outside of the scope, will be garbage collected automatically

main laurel
#

Is it valid in Ytdl or only in my code?

hallow sandal
#

I'm pretty sure python is compatible.

modest maple
#

heroku is built for python

hallow sandal
#

well, yeah.

#

but it does support other program languages as well.

plucky heart
nocturne grove
#

wait... has there never been client.roles in Discord JS? (because guild.roles and client.channels both do exist)

lyric mountain
#

@narrow kettle print(who_is_missing(r"D:\codes\nums.txt"))
Is that "r" supposed to be there?

modest maple
#

@lyric mountain yes

#

it denotes opening the file in read mode

lyric mountain
#

ah

#

but he already used the "r" here: fille = open(file_name, 'r')

#

after the method is called it'll be: fille = open(r"D:\codes\nums.txt", 'r')

slender thistle
#

Python raw string treats backslash (\) as a literal character.

sudden geyser
#

wait... has there never been client.roles in Discord JS? (because guild.roles and client.channels both do exist)
@nocturne grove yeah that's never been a thing.

nocturne grove
#

oh lol. Thanks for answering

tight plinth
#

@plucky heart check dbl.webhook.on('vote'

#

lol

sullen salmon
amber fractal
#

Basically mrans it can create more columns

#

So it isnt just 1 big column

sullen salmon
#

Ooooh

#

Thx

narrow kettle
#

@lyric mountain im pretty late with answering but i gotta use it else it gives me an error

sullen salmon
#

How do I properly fetch a member from an id?

uneven egret
sudden geyser
#

What version