#development

1 messages · Page 690 of 1

sage bobcat
#

One message removed from a suspended account.

modern elm
#

or DV

#

whoever can pls

#

im stupid

#

so it doesnt work

#

there is link to code

#

its not handling my aliases

west spoke
#

I dont code in java

#

yet

modern elm
#

its javascript...

west spoke
#

fuck off

#

I cant tell the difference

modern elm
#

lol

west spoke
#

I may have infinite iq but I cant tell the difference between java and js

topaz fjord
#

If you can't tell the difference between js and Java you shouldn't be allowed to code

#

c++ and c makes sense

#

Not java and js

inner jewel
#

c++ is very different from c

#

unless you're using it wrong

modern elm
#

@topaz fjord apologies for the extra ping, but may you please help?

#

@inner jewel cn you help ?

#

Link to code^

inner jewel
#

don't randomly ping people

trim swallow
#

pinging multiple people doesn't warrant help

modern elm
#

Its not random technically Thonk

inner jewel
#

bot.aliases.set(pull, pull.config.alias);

modern elm
#

yes

inner jewel
#

you're setting the key to the command

modern elm
#

?

inner jewel
#
  jsfile.forEach((f, i) => {
    let pull = require(`./commands/${f}`);
    bot.commands.set(pull.config.name, pull);
    pull.config.alias.forEach(alias => {
      if(alias !== "") {
      bot.aliases.set(pull, pull.config.alias);
      }
    });
  });```
#

think about the types there a bit

#

bot.commands.set(pull.config.name
vs
bot.aliases.set(pull

modern elm
#

should i be setting alias instead of pull?

#

oh

inner jewel
#

think about what you want to do

modern elm
#

so i reversed the set

#

it should be (pull.config.alias, pull) ?

inner jewel
#

think a bit more

modern elm
#

pull.config.alias, alias?

hushed berry
#

😂

inner jewel
#

...

modern elm
#

idk

hushed berry
#

oh im behind sorry

inner jewel
#

are you even trying?

modern elm
#

ive been trying for a long time

#

im not super experienced with js

inner jewel
#

this isn't language specific

#

it's just logic

#

you want to have each alias (a name) point to the command

modern elm
#

Yeah Thonk

inner jewel
#

bot.aliases.set(pull, pull.config.alias);
this points the command to it's list of aliases

modern elm
inner jewel
#

user input will never be a command object

#

so it's useless

west raptor
#

ghost ping?

modern elm
#

no

#

some idiot pinged all the staff

inner jewel
#

(pull.config.alias, pull)
this sets the list of aliases to point to the command

modern elm
#

oh

inner jewel
#

user input will never be an array of aliases

#

so it's also useless

modern elm
#

yeah im not sure what to do tbh

#

call me stupid

#

cause i am

trim swallow
#

@west raptor I'll pull your aliases owo

modern elm
#

wait

#

should it be

#

bot.aliases.set(alias, pull) ?

inner jewel
#

idk

#

you tell me

modern elm
#

ill try it

#

idk either

inner jewel
#

don't "try it"

#

think about what that's doing

modern elm
#

yeah nvm i thought about it

#

so the input is pull

#

and i want pull to point to the aliases Thonk

#

so bot.aliases.set(pull, pull.config.alias)

inner jewel
#

no

modern elm
inner jewel
#

you have a string, which is the command name

#

you need to get the command from that

#

bot.commands.set(pull.config.name, pull); is correct

#

if the input is the same as the name, you get the command

modern elm
#

yeah

inner jewel
#

now you need to do the same for aliases

#

you'll map a string to the command object

modern elm
#

pull.config.alias, alias?

inner jewel
#

pull.config.alias is not a string

#

and what would setting the value to be the alias help with?

modern elm
#

i dont know, im totally lost

#

i know i want to take the input

#

and change it to the command name

#

so

#

...

#

the first value should be pull

#

because that takes the string no?

inner jewel
#

pull

#

is

#

not

#

a

#

string

modern elm
#

no

#

its the cmd file

#

from the string

inner jewel
#

the first value is what identifies the entry

#

which will be a string if it's the command name

modern elm
#

yeah

#

so f

#

cause thats the cmd name

#

so the second value should be what i want the input to be translated to

inner jewel
#

what you want is to have each alias (a string) map to eg the command

modern elm
#

but pull wont get anything because it only looks for a file with the same name

#

so how do i get a cmd from an alias if the cmd filename is different

inner jewel
#

you already know the aliases

modern elm
#

Yeah

inner jewel
#

you just need to make them point to the same command

modern elm
#

Yeah

inner jewel
#

setting the name already works

#

so you just need to do the exact same thing but for each alias instead of name

modern elm
#

pull.config.alias, pull

#

thats the exact same thing in a literal sense FatThonk

inner jewel
#

no

modern elm
#

oops

inner jewel
#

pull.config.alias isn't a string

#

it's a badly named array

modern elm
#

oh

#

true

#

oh wait

#

so i would set the name to the alias

inner jewel
#

no

modern elm
#

WHY AM I DUMB

inner jewel
#

the name doesn't point to the aliases

#

the aliases point to the name

#

or, even better, directly to the command

modern elm
#

or just alias.pull

#

alias, pull*

inner jewel
#

yes

modern elm
#

seriously?

#

alias, pull

#

lets test

#

it didnt work

#

@inner jewel i just dont get it

#

@orchid raft thats the code

#

but its not recognizing my aliases

orchid raft
#

rip idk js

#

pythonk is my thing

modern elm
#

oh

#

oh well thanks for trying anyway

orchid raft
#

np lol

quartz kindle
#

what are you having trouble with? just do the exact same thing you did with the name, with each of the aliases

modern elm
#

Thats what the other guy said

#

but it didnt work

quartz kindle
#

how did you try it?

modern elm
#

bot.aliases.set(alias, pull.config.alias);

quartz kindle
#

thats pointing an alias to a list of aliases

modern elm
#

oh

quartz kindle
#

think about it

#

imagine this

#
pull = {
    config: {
        name: "something"
        alias: ["alias1","alias2"]
    },
    run: function(){}
}```
#

this is more or less how your command looks like, right?

modern elm
#

for the most part

#

i export them

#

as modules

quartz kindle
#

so if you do aliases.set(alias,pull.config.name) you get ["alias1","alias2"] pointing to "something"

modern elm
#

yeah

quartz kindle
#

so a user would need to type ["alias1","alias2"]

#

to get a name

modern elm
#

oh

quartz kindle
#

you want the user to type an alias, to get a command

#

or the entire file by the looks of it

modern elm
#

yeah

quartz kindle
#

your entire file is contained in the pull variable, so you need to point whatever it is to it, for starters

#

.set(anything,pull)

#

pull is always the result you want

modern elm
#

ok

quartz kindle
#

so it should always be the second argument

modern elm
#

ok

#

that makes sense

quartz kindle
#

now the first argument is the key, the name the user needs to use to access the result

modern elm
#

oh shit its an array

quartz kindle
#

you already did it with pull.config.name

modern elm
#

so i would call

#

using []

#

right?

quartz kindle
#

no, you need to loop over the array

modern elm
#

oh

quartz kindle
#

and for each item, set it as a the name

modern elm
#

its a forEach loop

#

so

#

pull.config.alias -> pull

#

?

quartz kindle
#

pull.config.alias is the array

#

it contains all aliases

modern elm
#

yeah

quartz kindle
#

you cant use it as a key

modern elm
#

ok

quartz kindle
#

you need to take each of them and use each of them as a key separately

modern elm
#

in the forEach loop, the variable assigned is called alias

#

so just alias -> pull ?

quartz kindle
#

yes, that should do it

modern elm
#

ok FatThonk

#

it didnt work

quartz kindle
#

how did you do it?

#

show the full code

modern elm
#

bot.aliases.set(alias, pull);

#

well

#
pull.config.alias.forEach(alias => {
    if(alias !== "") {
        bot.aliases.set(alias, pull);
    }
});
quartz kindle
#

that should work

#

if it doesnt work, your problem is elsewhere

modern elm
#

ok

#

so the problem is with my command then?

quartz kindle
#

could be anything

modern elm
#

the error im getting is
``cannot find module './commands/b.js'`

#

b is one of the aliases for ban

quartz kindle
#

then you did something wrong

modern elm
#

ok

quartz kindle
#

how are you checking the command when a user types one?

modern elm
#

um

#

lemme copy-paste the code rq

#
bot.on('message', async(message) => {
    if(!message.guild) return;
    if(message.author.bot) return;
  if(message.content.startsWith(`<@${bot.user.id}>`)) {
    let embed = new Discord.RichEmbed()
      .setTitle(`${message.guild.name}`)
      .setDescription(`My prefix is \`p!\`.\nTry running the commands \`p!help\``)
      .setColor(`RANDOM`)
      .setTimestamp();
    message.channel.send(embed);
    return;
  }
    let prefi = false;
    for(const thisPrefix of bot.config.prefix) {
        if(message.content.startsWith(thisPrefix)) prefi = thisPrefix;
    }
    const prefixMention = new RegExp(`^<@!?${bot.user.id}> `);
    const prefix = message.content.match(prefixMention) ? message.content.match(prefixMention)[0] : prefi;
    if(!message.content.startsWith(prefix)) return;
    if(bot.working && !bot.config.admins.includes(message.author.id)) return message.channel.send(`The bot is currently under maintenance!\nPlease check back later.`);
    let args = message.content.slice(prefix.length).trim().split(' ');
    let cmd = args.shift().toLowerCase();

    try {
        //alias handler
        if(cmd === "") cmd = '';
      
        delete require.cache[require.resolve(`./commands/${cmd}.js`)];

        let ops = {
            ownerID: ownerID,
            active: breep
        }
        let messageArray = message.content.split(" "); //args but whatever it works easier this way
        let cm = messageArray[0];
      //return console.log(bot.aliases.get(bot.commands.get(cm.slice(prefix.length))));
        let commandFile = bot.commands.get(cm.slice(prefix.length)) || bot.commands.get(bot.aliases.get(cm.slice(prefix.length)));
        if(commandFile) commandFile.run(bot, message, args, ops, tools);
    } catch (e) {
        console.log(e.stack);
    }
});
#

wait a tic

#

i have inconsistent variables

#

nvm

earnest phoenix
#

quick question, you know how you use "node ." to run node.js files in visual studio code?

Is there an equivalent for .c files ?

quartz kindle
#

why are you deleting a require cache before validating the command?

modern elm
#

i dont know, a guy told me to put that in there to avoid problems

quartz kindle
#

you delete it before any validation, so your code will attempt to delete anything you write to it, even invalid commands

modern elm
#

he didnt explain it

#

oh

quartz kindle
#

deleting the require cache is used for reloading commands without restarting the bot

#

it should not be used blindly like that

#

and you dont want to reload a command every single time you use it

#

it will spam your machine with disk reads

modern elm
#

ok

#

so should i remove that line

quartz kindle
#

yes

modern elm
#

ok

inner jewel
#

if(cmd === "") cmd = ''; does nothing

#

also the delete of the require cache doesn't really matter since it doesn't call require

modern elm
#

i know that line was there as my old innefficient cmd handler

#

i removed it

quartz kindle
#

but its not doing anything anyway

inner jewel
#

also let commandFile = bot.commands.get(cm.slice(prefix.length)) || bot.commands.get(bot.aliases.get(cm.slice(prefix.length)));

#

bot.aliases.get is already the command

modern elm
#

i dont understand

#

Is it just me

#

or did the server crash

#

@quartz kindle so uh, im not getting the error anymore, but now it wont run the command

#

WAIT

#

NO

#

IT WORKED

#

OMG

#

@inner jewel @quartz kindle THANK YOU GUYS SOOO MUCH

#

you have no idea how long ive been trying to figure that out

#

thanks a load for helping me

earnest phoenix
#

richembed not working

#

}
const mapjoin = new Discord.RichEmbed()
.setColor(0x008B)
.setTitle(Here are some tips for joining MAP-Projects, ${message.author}! )
.setDescription( 1. Check the Open MAP-Project playlist run by TrailTracker. It usually has every open Warriorcat MAP in it. https://www.youtube.com/playlist?list=PL32DNLXWzFRH0FZx_pnPMZDFiam-qO28H 2. Ask for multiple parts. If the part that you want is already taken, the host will be able to offer you your second, third, or even fourth preferece! 3. Don't comment asking for a part multiple times. This can be frustrating for the host. Unless they ask you to, don't comment again. 4. Apply with the right additude! If you think, or comment "I'm not going to get the part" chances are, you won't. It's best to go in with a positive outlook! 5. Keep in touch with the host. This way, you'll be able to provide a WIP when needed, or update the host on the status of your part! Communicate through discord, twitter, skype, email, or anything!)
.setFooter("**Those are all of the tips I have for today! If you have any suggestions, DM @earnest phoenix!")
if (message.content === 'mapjoin')
channel.send (mapjoin)

})

modern elm
#

@earnest phoenix whats not working about it?

quartz kindle
#

@earnest phoenix please use code blocks, i cant understand your code

earnest phoenix
#

sorry i dont know how do code blocks

modern elm
#

shoot

quartz kindle
modern elm
#

``` ```

earnest phoenix
#

gtg

modern elm
#

like that

#

wow

#

ok

wet void
#
}
    const mapjoin = new Discord.RichEmbed()
    .setColor(0x008B)
    .setTitle(`Here are some tips for joining MAP-Projects, ${message.author}!`)
    .setDescription(`1. Check the Open MAP-Project playlist run by TrailTracker. It usually has every open Warriorcat MAP in it. https://www.youtube.com/playlist?list=PL32DNLXWzFRH0FZx_pnPMZDFiam-qO28H 
     2. Ask for multiple parts. If the part that you want is already taken, the host will be able to offer you your second, third, or even fourth preferece!
     3. Don't comment asking for a part multiple times. This can be frustrating for the host. Unless they ask you to, don't comment again.
     4. Apply with the right additude! If you think, or comment "I'm not going to get the part" chances are, you won't. It's best to go in with a positive outlook!
     5. Keep in touch with the host. This way, you'll be able to provide a WIP when needed, or update the host on the status of your part! Communicate through discord, twitter, skype, email, or anything!`)
.setFooter("**Those are all of the tips I have for today! If you have any suggestions, DM @semi hiatus!")
if (message.content === 'mapjoin')
channel.send (mapjoin)

})
``` @modern elm
earnest phoenix
#

hey

#

im trying to make a giveaway system and i need to fetch all the members that reacted thats my code and its returning a error that fetch users is undefind

onyx summit
#

You have to use the unicode emoji

earnest phoenix
#

how?

onyx summit
#

Not 🎉

earnest phoenix
#

whats the unicode emoji

onyx summit
#

You can copy it out of the block

earnest phoenix
#

ok

onyx summit
#

\🎉

#

This one, I think

empty owl
#

Yooo

#

nvm i got it

reef sonnet
#

is there a way to change what a users current chat is? For example if I was looking in #development something happens and my chat changes to #topgg-api

earnest phoenix
#

no

reef sonnet
#

oh thats a bummer

#

Thank you

onyx summit
#

That would be like, really abusable

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lusty dew
#

Explain don’t work

#

Give errors

sage bobcat
#

One message removed from a suspended account.

onyx summit
#

Wait what

lusty dew
#

Where are you even logging anything to the console in that

inner jewel
#

does the bot have permission to send

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lusty dew
#

Mk

sage bobcat
#

One message removed from a suspended account.

onyx summit
#

Get a debugger MmmYea

sage bobcat
#

One message removed from a suspended account.

onyx summit
#

What

sage bobcat
#

One message removed from a suspended account.

lusty dew
#

Gotta know how to use it

onyx summit
#

vsc debugger is fucking great

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lusty dew
#

He just doesn’t know how to use it

sage bobcat
#

One message removed from a suspended account.

onyx summit
#

she it

lusty dew
#

She He doesn’t matter

#

We all equal

sage bobcat
#

One message removed from a suspended account.

lusty dew
#

Anyway back to the problem

onyx summit
#

Are the other commands working?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

lusty dew
#

Totally unrelated but a question

#

Why do people require Discord but don’t use it

onyx summit
#

You have something like client.commands? Right?

sage bobcat
#

One message removed from a suspended account.

onyx summit
#

It will

lusty dew
#

It will

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

onyx summit
#

send is a function on the channel object, requiring discord won't change anything

#

Anywaayyy

#

You have something like client.commands? Right?

lusty dew
#

Isn’t async(blah, blah) a function

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

onyx summit
#

Log it in the message event

#

console.log(client.commands) in the message event

lusty dew
#

Or eval it ;)

#

Jk

#

I wonder brb

onyx summit
#

Yeah you can eval it but he/she/it only has a help command (I think)?

earnest phoenix
#

they

#

just use they lol

lusty dew
#

Yea

#

I can’t eval mine

#

It returns as an empty message

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

onyx summit
#

Yeah I guess

lusty dew
#

I have to use Object.entries(client.commands)

sage bobcat
#

One message removed from a suspended account.

topaz fjord
#

because client is actually bot

onyx summit
#

Oh you named it bot

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

onyx summit
#

Nonono

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lusty dew
#

It doesn’t matter what you name it in the command file

sage bobcat
#

One message removed from a suspended account.

modern elm
#

👀

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lusty dew
#

In the command file you can have it as shithead because it’s just a param

#

At least that’s what I was told

#

😂

onyx summit
#

Okay, just do console.log(bot.commands)

#

Instead of client

lusty dew
#

But in the main file you have it as bot

#

So you use bot

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

onyx summit
#

And if u do <prefix>roll nothing happens?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

onyx summit
#

Okay I would love to help you but ablobsleep

sage bobcat
#

One message removed from a suspended account.

onyx summit
#

Weird

topaz fjord
#

this is weird

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

topaz fjord
#

yes

#

how does the other command look

onyx summit
#

Set a breakpoint at the rand calculation and then press the second button (next step shitty button) as soon as it triggers

topaz fjord
#

@sage bobcat

sage bobcat
#

One message removed from a suspended account.

unique nimbus
#

amazing

lusty dew
#

Mmm wonderful embed

sage bobcat
#

One message removed from a suspended account.

onyx summit
#

Stop shitting, we all started small

topaz fjord
#

no i mean code

sage bobcat
#

One message removed from a suspended account.

lusty dew
#

I’m not

topaz fjord
#

no how the actual command looks

lusty dew
#

I’m being serious

onyx summit
#

Yes me too, good night

lusty dew
#

I literally did worse then that when I first made an embed

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

static help commands 🤢

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lusty dew
#

Lol

topaz fjord
#

basically you add all the commands yourself

lusty dew
#

When you hardcode in the list of commands

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

topaz fjord
#

other bots filter through their commands and generate the help embed that way

sage bobcat
#

One message removed from a suspended account.

onyx summit
#

You hardcoded the help.
But it's not the problem here

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lusty dew
#

Some people loop through their commands and list them in an embed

onyx summit
#

Well you actually have to code that functionality

lusty dew
#

Which is what I do and it’s a simple for loop as well

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lusty dew
#

Use a for loop.

#

If you wanna do it my method

#

Probably other methods.

#

As for your problem with the message send I don’t know

#

It’s confusing me as well

topaz fjord
#

^

onyx summit
#

Instead of only exporting a name property, you have multiple properties (like example, description, category).
And in the help command you get all commands and filter trough their properties

#

Requires some work to setup

sage bobcat
#

One message removed from a suspended account.

lusty dew
#

I just have a help command that just spits out the name splitting them up in their correct modules. Then have another function inside the help command that gives you more info on the command

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

lusty dew
#

Wdym?

topaz fjord
#

these commands are identical

#

but one is executing

#

one isn't

modern elm
#

weird

topaz fjord
#

@sage bobcat if you use message.channel.send("hi") does it work

sage bobcat
#

One message removed from a suspended account.

lusty dew
#

It’s rand

#

I’m guessing at least

#

Try sending just rand like message.channel.send(rand)

#

@sage bobcat

sage bobcat
#

One message removed from a suspended account.

lusty dew
#

Just try I’m trying to see if it is indeed rand

sage bobcat
#

One message removed from a suspended account.

lusty dew
#

Hm

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

lusty dew
#

Try this:
message.channel.send('You rolled a ' + rand)

topaz fjord
#

im wondering why `` isn't working tho

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

modern elm
#

${rand} doesnt work?

lusty dew
#

Nope

modern elm
#

wow

#

thats weird

lusty dew
#

Yea

sage bobcat
#

One message removed from a suspended account.

lusty dew
#

Np

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

did you ever like

#

place a breakpoint or try catch

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lusty dew
#

I forgot try/catch was a thing

#

👀

#

How can I sweep my db monthly for users that have left a guild so I can erase their entry for that guild

light forge
#

I have a question about Pollmaster. Hopefully this is the right place. I'm admin of a server and am conducting an anonymous poll with no live results and i'm wondering if there's a way for me, as overseer of the poll, so see the progress/results at any time other than when the election ends?

earnest phoenix
#

go to the bot's support server

light forge
#

Ah I see that link now, thanks!

quartz kindle
#

@lusty dew make a persistent scheduler with your database

#

or use something that does it for you, like node-schedule

lusty dew
#

Oh?

#

Well fuck didn’t know that existed

#

Okay next question

#

How would I know which people to erase from the database

topaz fjord
#

get all user ids by filtering through guilds, get all user ids stored in db, if the ones stored in db aren't contained in the array full of ids gotten from guild

lusty dew
#

Cause it could be multiple people not just 1 or 2

topaz fjord
#

delet

lusty dew
#

That’d be api spammy no?

topaz fjord
#

uh

#

idek

#

seems to work or me on d.js

earnest phoenix
#

you aren't doing anything with the api except requesting all members

#

it's not spammy

lusty dew
#

True.

quartz kindle
#

what about uncached members?

lusty dew
#

Yea

quartz kindle
#

you will mistakenly delete them from the db that way

lusty dew
#

Yea

earnest phoenix
#

yeah, you should request all members for that reason

quartz kindle
#

rip ram

earnest phoenix
#

yes

#

especially on discord.js

quartz kindle
#

i would do something like this

inner jewel
#

you can fetch individual members by id

topaz fjord
#

that works too

earnest phoenix
#

that's even more spammy

#

you're going to get yourself ratelimited by the time you fetch every user in the database

lusty dew
#

Fetching 25k+ members individually

inner jewel
#

fetch only the ones not cached

quartz kindle
#
let ids = await getAllIdsFromDatabase()
for(let i = 0; i < ids.length; i++) {
    if(client.users.get(ids[i])) continue;
    let fetched = await client.users.fetch(ids[i]);
    if(!fetched) delete from database
}
earnest phoenix
#

i mean

#

you'd still be filling up the cache and using more and more ram

#

so why not request all users at once and avoid the risk of a ratelimit

#

i forgot if d.js handles ratelimits

inner jewel
#

it does

quartz kindle
#

you're only caching users for which you have an entry in the db, not all of them

inner jewel
#

all libs that have a channel in dapi handle ratelimits

#

also it's something done once a month

#

discord won't care about the users you'll fetch

quartz kindle
#

and you're fetching them one by one with await

#

not all at once

earnest phoenix
#

yeah that's the concern

lusty dew
#

Okay now to figure out how to use node-schedule

earnest phoenix
#

if you fetch all of them at once it's one request, you send a payload to the gateway saying "hey send me all members in chunks"

#

this way you'd individually be making a request for each uncached user

inner jewel
#

one request per guild

#

and then you get spammed with every single member

#

if you get the data

#

which you might not get because discord is discord

lusty dew
#

I’d have to optimize this one day won’t I?

quartz kindle
#

there might be guilds where none of its users are in your database because they never used your commands

lusty dew
#

True.

inner jewel
#

pretty sure djs caches members as they log in

#

not only if they send messages

lusty dew
#

I’m making it so on guild join they get an entry

inner jewel
#

iirc it caches on PRESENCE_UPDATE

quartz kindle
#

yes, but im saying creating an entry in the database for them

#

should only be done on command usage

lusty dew
#

Why?

quartz kindle
#

why create entries for people who will not use it?

lusty dew
#

Eh true ig

#

I’d have to add in checks though.

inner jewel
#

i never delete any data and my db is less than 4MB

#

on disk

lusty dew
#

Eh but it’s pointless keeping them in the db if they aren’t in the guild anymore.

quartz kindle
#

they might come back

#

and they will want their data intact

earnest phoenix
#

when i had a public bot i usually deleted user data from my db 48 hours after the user left the guild

quartz kindle
#

i'd clean a database like that maybe once a year

lusty dew
#

Only reason I’m sweeping on a one month interval is because some people get too aggravated

#

And leave the guild but come back but eh

quartz kindle
#

log a time stamp for last time they interacted with your bot

#

and delete them if they havent done so for over a year

#

lul

lusty dew
#

I could increase the time limit on the sweep

inner jewel
#

i've never cleared it and it's small enough i don't need to worry about cleaning it

#

although i only create data when needed

lusty dew
#

Same.

earnest phoenix
#

it also depends on how much data you store

quartz kindle
#

my database is like 2mb

inner jewel
#

instead of always having an entry per user

#

mine's <4mb on disk, 12mb on memory

quartz kindle
#

but my user-generated image folder is 600mb lul

lusty dew
#

Yea only entry I’ll create for table will be for guilds.

#

Guild and Economy.

#

I have a separate table for Economy functions.

#

But users get a balance written to them

earnest phoenix
#

TimToday at 1:24 AM
but my user-generated image folder is 600mb lul
relatable, except i kept my images stored in memory in a byte array so i hit around 1.8 gigs ram usage once

quartz kindle
#

why

earnest phoenix
#

i dont know tbh

#

i had retarded design back in the day

lusty dew
#

Hm, I wonder where I’d get the images from for my api

earnest phoenix
#

i think it was mainly because it was served from a web server

quartz kindle
#

i could say the same, since my bot still uses a json db

#

lul

lusty dew
#

Really?

quartz kindle
#

ye

lusty dew
#

Big brain

#

That’s cool tbh

quartz kindle
#

its not cool

topaz fjord
#

json db cool

inner jewel
lusty dew
#

Usually my data corrupts after 1h

quartz kindle
#

it hardly works

inner jewel
#

that's about how much data i store

quartz kindle
#

1.1k guilds and 7k users

inner jewel
#
  • some oauth data
quartz kindle
inner jewel
#

that's in the db

#

the bot has way more than that

quartz kindle
#

yeah i have 5k users in the db

lusty dew
#

Any suggestions on how to get/store images for an image gen api

quartz kindle
#

the users i show are only those who interacted with the bot and have a db entry

#

lul

inner jewel
#

there's also oauth and starboard data

#

but those are a pain to count because of how they're stored

quartz kindle
#

i believe it

earnest phoenix
#

tfw you can't be bothered with refresh tokens so you make your sessions expire after a week instead

topaz fjord
#

lmao

quartz kindle
#

just store their ids in localstorage huehue

earnest phoenix
#

ohmy

#

google updated their fonts page to MD2

#

it looks so good

lusty dew
#

Any suggestions on how to get/store images for an image gen api

dusky geode
#

no

inner jewel
#

@quartz kindle that's what i do (kinda)

#

but i keep the tokens so i can fetch the user's guilds

lusty dew
#

Uhm discord bot list disappeared from my server list

#

Had to go to the website to get the invite again to view the server

earnest phoenix
#

discord's servers casually having a stroke

lusty dew
#

Kek

unique nimbus
#

Discord bot list in general gets shortages

earnest phoenix
#
    const mapjoin = new Discord.RichEmbed()
    .setColor(0x008B)
    .setTitle(`Here are some tips for joining MAP-Projects, ${message.author}! `)
    .setDescription(`
     1. Check the Open MAP-Project playlist run by TrailTracker. It usually has every open Warriorcat MAP in it. https://www.youtube.com/playlist?list=PL32DNLXWzFRH0FZx_pnPMZDFiam-qO28H 
     2. Ask for multiple parts. If the part that you want is already taken, the host will be able to offer you your second, third, or even fourth preferece!
     3. Don't comment asking for a part multiple times. This can be frustrating for the host. Unless they ask you to, don't comment again.
     4. Apply with the right additude! If you think, or comment "I'm not going to get the part" chances are, you won't. It's best to go in with a positive outlook!
     5. Keep in touch with the host. This way, you'll be able to provide a WIP when needed, or update the host on the status of your part! Communicate through discord, twitter, skype, email, or anything!
`)
.setFooter("**Those are all of the tips I have for today! If you have any suggestions, DM @semi hiatus#5641!")
if (message.content === 'mapjoin')
channel.send (mapjoin)

})```
#

richembed not working

#

what is not working

#

the command. just doesnt work

#

how are you invoking the command

#

just typing mapjoin

#

fixed it

lusty dew
#

I love getting ratelimited and having to wait 3h to get my beta bot back online

slim heart
#

How did you manage to get rate limited that much

lusty dew
#

Apparently something caused an error and made my bot login over and over

slim heart
#

It wasted all your identifies?

lusty dew
#

I don’t even know when or how

#

Yea

slim heart
#

Owie

lusty dew
#

The bot was offline though so idk how it got ratelimited

slim heart
#

You got the email from discord?

#

I’ve always been curious what it looks like

lusty dew
#

No I didn’t

#

Which is odd

#

Usually they do

slim heart
#

Atleast its just be beta bot

#

Nobody to be mad at you

lusty dew
#

Yea lel

#

The production bot still up and working properly

#

Just noticed it stopped posting to dbl for some odd reason

earnest phoenix
#

why are you sending a message instead of logging it to your console 💀

lusty dew
#

Eh

#

I don’t wanna check console every single time

#

Kek

#

If it isn’t working I can look at that channel and tell bc it isn’t sending

ebon ermine
#

My bot has the mute role ... why ...?

slim heart
ebon ermine
#

I see ... Thank you for telling me.

earnest phoenix
#

you can ask a unmute to a mod, just ping a mod and explain your problem

valid silo
#

I got a quick question regarding a role assignment I added then tried to remove but the reaction is still there. Is this the appropriate place to ask?

#

for Zira bot

earnest phoenix
#

@valid silo blobthis

valid silo
#

lol thanks

stray garnet
#

how can i fix that when i leave vc but my bot keeps playing music, and when rejoin it still plays?

topaz sphinx
#

@warm marsh @amber fractal sorry for being a little mean yesterday, been stuck at that issue for long :c

ivory vessel
#

Hi guys, do you think you could add Runescape Patch news to your bot? Would be much appreciated

amber fractal
#

@ivory vessel this iant a support server for a bot

#

Join the bot's server and ask there.

ivory vessel
#

ah sorry, alright. thanks

amber fractal
#

:+1:

stray garnet
#

Code: <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>Yukki</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="wrapper"> <h1>Page</h1> <img class="img" src="img/img.png" alt="img"> </div> </body> </html>

#

im new to html and css

slim heart
#

Are u asking for help?

stray garnet
#

yea...

slim heart
#

Where’s this file located and where’s the image that you want

stray garnet
#

in my folder

slim heart
#

From root /

#

If it’s from root you can do /img/img.png

stray garnet
#

its on my desktop

slim heart
#

Use /img/img.png instead

stray garnet
#

ok

slim heart
#

And I mean root of the website

#

/ at the beginning signifies starting at root

stray garnet
#

its still just "img"

slim heart
#

Screenshot the folder for me

stray garnet
#

kk

slim heart
#

Well

#

You put img.png

#

Rather than jpg

stray garnet
#

fml

slim heart
#

:P

stray garnet
#

Still lol

#

and yyes i saved it

slim heart
#

What’s the code now

stray garnet
#
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Yukki</title>
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <div class="wrapper">
      <h1>Page</h1>
      <img class="img" src="/img/img.jpg" alt="img">
    </div>
  </body>
</html>
slim heart
#

DiD yOu ReLoAd ThE pAgE

stray garnet
#

...ofc i did

slim heart
#

Try and remove the beginning / again then

stray garnet
#

kk

slim heart
#

Yes ik big yoke

stray garnet
#

OMG FINALY

#

hard nut lol

slim heart
#

Lol

stray garnet
#

thx

peak quail
#

how can i fetch the last ban in audit log
🤔
(discord.js)

earnest phoenix
peak quail
#
guild.fetchAuditLogs({ type: "MEMBER_BAN_ADD" }).then(logs => console.log(logs.first()));

TypeError: logs.first is not a function

late hill
#

Just read what the person above said and use options.limit

west raptor
#

logs.entries.first()

late hill
#

or that

#

Limit would probably be better so you're not fetching stuff you don't need

west raptor
#

that also

peak quail
#

hmmm

amber fractal
#

limit would still return a collection so you'd need to do .first() still anyways

#

But yeah if you're trying to get 1 fetching other stuff isnt needed anyways mmulu

topaz sphinx
#

Alright lets retry

#

The guy who solves this issue is bigbrain of the year smh

earnest phoenix
#

hey im trying to build a invites command, thats my code, its returning me invites_.find(...).catch is not a function error

#

does somebody knows whats wrong?

#

thats the code in the ready functions thats backsup all the old invites

quartz kindle
#

because its not a function

earnest phoenix
#

so how to do it?

quartz kindle
#

.catch is used to catch an error generated inside a promise

#

.find is not a promise

earnest phoenix
#

so i need to remove the .catch?

amber fractal
#

.find doesnt return a promise, so .catch

#

Also returning in a .catch will just return, the rest of the function will continue I believe

quartz kindle
#

yes, returning in a catch does nothing

earnest phoenix
#

i did it because if the bot doesnt have perms to look at the invites so itll just return

quartz kindle
#

it wont, it will error anyway

earnest phoenix
#

so if ill remove the catch itll work?

quartz kindle
#

try it

earnest phoenix
#

ok

#

the new error

#

what have i done wrong now?

quartz kindle
#

ei.get() is not finding anything

earnest phoenix
#

so what should i do?

topaz sphinx
#

Tim refer me to a PostgreSQL specialist or smth

quartz kindle
#

idk any lol

topaz sphinx
#

dammet, my problems are too difficult FeelsBadEh

earnest phoenix
#

thats the code in the .on ready

#

so its backing up all the invites

#

i need to do like a interval that updates it?

quartz kindle
#

returning inside a catch doesnt do anything, you could simply have .catch() and it would do the same thing

#

but thats not your problem

#

for your problem you need to console.log(ei) to see what it looks like

#

you can also console.log(i) inside the find, to see if i is what you expect it to be

earnest phoenix
#

and remove the other catches?

quartz kindle
#

when something isnt working, just console.log all variables, and you will probably find some of them do not have the values you think they do

earnest phoenix
#

ok

#

thx

quartz kindle
#

99% of programming problems can be solved that way

earnest phoenix
#

ill try it

#

but

#

lets pretent

#

that someone

#

making a new invite link

#

after the bot is already ready

#

so the invites variable wont update

#

so

#

i need to do like a interval that updates it?

quartz kindle
#

you should update it when the user creates it

earnest phoenix
#

theres any listener on discord.js to when a new update link is generated?

quartz kindle
#

there should be

#

maybe part of guildUpdate

earnest phoenix
#

ok

#

ill try that

#

thank you

onyx summit
#

Even better than console.logs are breakpoints (or even conditional breakpoints)

earnest phoenix
#

a interval can solve it too?

#

cuz i tied to use guild update and i didnt got how to capture new invites links

#

just do every time that the guild is updated

#

just to update the invites var automaticly?

#

or i need to see if any invite link has been added

late hill
#

You could do some testing to see if guildUpdate actually fires for new invites

#

If it does

#

You can fetch the invites on each guild update and replace the ones you have saved ig

#

But that would also fire a lot for other reasons

earnest phoenix
#

discord.js need to make a new listener for that

#

but ill try it

#

is the order good?

#

cuz i need the new guild and the old guild

#

the first one is the old guild or the new one?

potent ivy
#

do i need to perform extra steps to get server count and online check on the discord bot list website?

#

or it just takes some time?

earnest phoenix
#

the guild update isnt fired when a new invite is generated

#

theres another method of doing that?

#

maybe raw?

potent ivy
#

guildCreate

earnest phoenix
#

guild create is when the bot joining a server

potent ivy
#

ah

#

well i guess you can try listening to any and see what pops up when you create the invite

earnest phoenix
#

yeah but its just i think useless

#

somebody else maybe?

#

ill ask in discord.js's server

#

i asked in theire server

#

and i didnt got it

#

thats why they said

#

the usual option is to force invite creation to go through the bot so it can track it

#

they also said that theres no event that fired when a new invite is created

slim heart
#

Djs doesn’t manage listeners

#

They port discord’s events

earnest phoenix
#

i know

#

i just asked if there is one

#

i didnt asked them to add

#

did someone know what they ment>

slim heart
#

discord.js need to make a new listener for that

earnest phoenix
#

i ment discord

potent ivy
#

theres also the ugly ass way of just checking invite lists and comparing them in intervals

summer torrent
#

can bot mute member in voice channel?

amber fractal
#

If it has perms

summer torrent
#

thx

indigo geyser
#

how to play an audio (discord.py) with .play? I tried bot.play / channel.play / ctx.channel.play.......... but nothing

unique nimbus
#

you need to define whats the channel

#

and where the file is

modern elm
hollow prawn
#

@earnest phoenix try getting audit logs, however idk should it be periodic or what

stray garnet
#
  margin: 0;
  padding: 0;
}

.img {
  width: 2500px;
  height: auto;
}

body {
  width: 100%;
  height: auto;
  overflow: hidden;
}

.content-wrapper {
  width: 80%;
  margin: 4% 10% 5% 10%
}

.content-wrapper img {
  width: 100%
}

.text-wrapper {
  width: 100%;
  position: relative;
  margin-top: -40%
}

.text-wrapper h1 {
  text-align: center;
  color: #ffffff;
  font-size: 10vw;
  font-family: "manjari", "cursive"
}```
#

help

#

how do i get it in center

#

pls

amber fractal
mossy vine
#

how can i communicate between the ShardingManager and the shards it spawns in d.js master?

#

trying to create sort of a "global cache" system, where the shard would retrieve a value from the ShardingManager, so the shards can stay consistent

#

(i know redis is made for that, and i also did it with a webserver solution before, but wouldnt this be signifcantly faster?)

onyx summit
#

client.shard.send

#

tbh its kinda cancer, I would use veza, and on start the master process sends his ipc port to the shards, and then they connect

#

cuzz veza allows request => response and more

jade thistle
#

Where do i put the code of the bot that makes the bot do the things?

mossy vine
quartz kindle
#

i ended up using pm2's own functions for my IPC system

onyx summit
#

yeah

quartz kindle
#

since im making it heavily pm2 based

loud salmon
onyx summit
#

I mean, its just how I would do it, you are free to use what you want

jade thistle
#

@loud salmon thanks

onyx summit
#

I already use veza for all my shit and I really like it

mossy vine
#

i will look into it, thanks

onyx summit
#

Basically like this:

  1. Master forks child
  2. Master sends the child his IPC port
  3. Child connects to given IPC port
  4. woho, the server can now emit events, respond to requests from children, etc
mossy vine
#

is it compatible with what d.js already does with ShardingManager?

onyx summit
#

You dont need the d.js sharding manager to communicate with your childs (only once after you forked a child)

mossy vine
#

aight, thanks

stray garnet
#

@jade thistle Ok lol

#

@amber fractal didint solved it

idle basalt
#

i normally use flex to center

#

great tool

spark star
#

I'm running into some issues installing erlpack@discordapp/erlpack please tell me what to do to fix it. I tried running it as root as well.

#

Doing 'npm install discord.js` doesn't do anything either

#

Lemme try getting a better view

#

A dependency discord.js needs

#

Lemme give the error in text

smoky spire
#

You don't have to manually install the dependencies of your dependencies

spark star
#

Oh ok

#

:P

#

I feel dumb now

#

For my bot?

#

K gimme a sec to get it up

#
const client = new Discord.Client()
const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
})

client.on('ready', () => {
    var generalChannel = client.channels.get("619559849264676864") // Replace with known channel ID
    var message = readline.question("Please type your message")
    generalChannel.send(message)
      console.log(`Your message has been sent. Your message was :`message`)
      readline.close()
    })
})

bot_secret_token = "This is my token I am not gonna reveal it lel"

client.login(bot_secret_token)```
#

I'm trying to get user input working

#

Yeah

#

No

#

Not yet

#

I was about to do that for the guide

#

It's just a general userinput guide for nodejs

smoky spire
#

Is the end user going to be typing in the console?

spark star
#

Other wise I'm following this guide: https://www.digitaltrends.com/gaming/how-to-make-a-discord-bot/?amp
How to Make a Discord Bot | Digital Trends

Digital Trends

Discord bots can make life a lot easier for users of the gaming-centric online chat application. However, it's not as simple as clicking a few buttons to get one up and running. Here's what you need to know to get started making your own Discord bots, from coding them to addi...

#

Nah only me

#

Wait wrong guide

#

Eh

#

Idc

smoky spire
spark star
#

Ok thanks!

#

But I'm tryna get userinput mahself

quartz kindle
#

erlpack is an optional library that can make discord.js slightly faster and/or use less resources

earnest phoenix
#

im making progress bar for level

#

using canvas contructor :

#

so i make a rectangle

#

then

#

?

#

i can do the math

#

but idk how to make the color go across the screen

quartz kindle
#

make another rectangle

earnest phoenix
#

ok

#

done .

#

.addRect

quartz kindle
#

and make its width equivalent to the width you got from your math

earnest phoenix
#

ok

spark star
#

Can someone help install erlpack then?

#

If it makes it faster that would be a huge boost

quartz kindle
#

the current version is outdated and not compatible with node v12

#

you can try using a fork made by someone else

spark star
#

Oh ok thanks

quartz kindle
#

if you're using discord.js master (v12) then i also suggest instaling zlib-sync

spark star
#

I'm using v11 cuz for some reason it won't go above that

#

It's on my rpi

quartz kindle
#

the installation process is different for v12

spark star
#

Oh how do I do it?

quartz kindle
#

you need to have git installed, then npm install discordjs/discord.js

spark star
#

Do I do npm install zlib-sync or something else?

quartz kindle
#

yes

spark star
#

Oh ok thanks

#

Btw do you have any recommended ssh clients?

quartz kindle
#

im using mobaxterm

spark star
#

For Android?

quartz kindle
#

idk about android

spark star
#

Ok

#

Welp thanks anyway!

earnest phoenix
#

nvm , idk how to do the math :/

#

calculate the percentage of completed xp and then cover that amount of percentage in the width of your xp bar

#

hm

quartz kindle
#

get current xp
get xp needed for next level
convert both into percentages
make a rectangle with a specific width, that width represents 100%
make another rectangle with the width equal to the percentage of the xp needed

earnest phoenix
#

so i get percentage

#

what will i put in rect

#

.addRect( , , , ,)

#

has to be numbers in?

quartz kindle
#

the first rect you decide

#

its the rect for the 100%

#

the second rect is the width that is equivalent to the percentage

#

for example, if you make a rect with 400 width

#

and someone has 50% exp

#

the second rect should be 50% of the max with

#

or 200

earnest phoenix
#

hm

#

ok

#

ill come back if i need help

#

ima get

#

percenttage

#
        .addRect(169, 500, 500, 30) // bar 1 base```
#

i calcualted

#

percenttage

#

now?

#

@quartz kindle

quartz kindle
#

did you draw them? what do they look like?

earnest phoenix
#

the rect

#

wont appear

#

:/

quartz kindle
#

you didnt draw it?

#

nvm, canvas-constructor is supposed to auto-draw

earnest phoenix
#
const output = await dl.Fetch(message.author.id)
 var xpDifferenceBetweenLevels = (100*output.level);

    var pxp = ((output.xp - output.level) / xpDifferenceBetweenLevels)
    
    console.log(Math.floor(pxp*100))

    var barsize = Math.floor(pxp * 100);
 if ((barsize <= 0) == false) {
        barsize = (barsize - 1);

 }
const fsn = require('fs-nextra');
    const image = await fsn.readFile('./profile/profile.jpg');
     return new Canvas(1010, 750)
        .setColor("#2C2F33")
        .addRect(169, 500,pxp*100, 30)
      .setShadowColor('rgba(22, 22, 22, 0.8)')
      .setShadowOffsetY(5)
      .setShadowBlur(30)
//.setColor("rgba(10,10,0.1,0.2)")
      .save()
      .fill()
      .restore()
      .setTextAlign('center')
    .setTextFont('24px Impact')
      .setColor('#FFFFFF')
        .addRect(169, 500, 400, 30)
#

oh

#

so

#

what should i use?

#

Canvas

#

?

amber fractal
#

Log randomName

#

Does the bot have perms?

quartz kindle
#

@earnest phoenix if you cant use canvas-constructor you wont be able to use canvas lol, its much harder

#

try removing those save fill restore lines

#

idk why you have them there

#

also, how are you sending the drawing to discord?

earnest phoenix
#

nvm , i got it.

#

thank you so much Tim ❤

quartz kindle
#

nope

#

add a catch to it

#

setNickname().catch(console.log)

amber fractal
#

No

spark star
#

Nope

#

Test it on another bot

#

How do I input a message into the terminal and make it output a message to my desired channel

quartz kindle
#

you need an i/o interface in your terminal

spark star
#

How would I set that up... 😅

quartz kindle
#

look for a library that does something like that

#

or use node's inner libs if you're using node

spark star
#

I am using node

#

But I am a complete newbie...

amber fractal
#

Look up

#

Node console input

spark star
#

Ok thanks

amber fractal
#

There are probably a ton of modules

#

Oh wait

quartz kindle
#

the problem is

amber fractal
#

@quartz kindle does node have a console input by default?

quartz kindle
#

to use an interface like that, you need to set up your program to await user input

#

meaning you need to be manually running it

#

and if you close it, your bot will go offline

#

to do something like that reliably, your bot would need to run a service or a server that is listening to something

#

and have another application send messages to it

amber fractal
#

Have your bot recieve post requests and have another server (or something else like a website only you can access with an input) send the requests to the server to reply mmulu

#

Jk I have no idea if that would work

quartz kindle
#

pm2 has a way to send messages to a process

#

using their pm2 i/o library

amber fractal
#

Oh wow I know nothing of pm2's capabilities

#

Like clusters and such

#

Lol

quartz kindle
#

pm2 clusters for discord bots are tricky

#

but i made a lib for it

#

works pretty well

#

pm2 clusters are designed for things that can run completely independently of each other