#development

1 messages · Page 701 of 1

drowsy sentinel
#

Gotta try and test things.

cobalt mesa
#

Ok thanks

#

But freeram of module os give me total ram of my machine, not the process of node ??

drowsy sentinel
#

You wanted to know the total freeram/totalmem, so I figured you wanted to use the operating system of which the bot is hosted on to determine that.

#

But, if that ain't it you gotta figure it out.

glacial mango
#

Could someone help me with an event so my bot sends a message when someone voted?

earnest phoenix
#

2 Questions,

  • How would I map out all of the shards data in an embed
  • How would I restart a shard in a command.
    ^ Mostly is how could I call a shard I spawned in a command..?
valid frigate
#

what lib

earnest phoenix
#

JS

#

ping me if u can help me.

twilit rapids
#

what lib

#

discord.js, eris, etc...

earnest phoenix
#

djs

#

@twilit rapids

twilit rapids
#

and what version?

earnest phoenix
#

^11.5.1

sinful lotus
#

process.memoryUsage tells you the usage of your node process

obtuse ermine
#

Hey can someone help me?
I have the code for a pat command but it only sends 1 gif. Does somebody know the code to make it send a random gif?

amber fractal
#

Array of files

#

Send a random picture

#

Or you can use an api if you dont want local files

obtuse ermine
#

Okay, thank you for the answer doggowave

harsh nova
#

And pls use string interpolation

amber fractal
#

I mean does it matter?

mossy vine
#

good practices are always good

amber fractal
#

Does using the + operator have any drawbacks over template literals?

inner jewel
#

no

amber fractal
#

I mean I use template literals, but is there anything wrong with using a + operator

quartz kindle
#

nothing wrong with it, i use it too when concatenating only one or two variables

blissful wind
#

Template literals are easier processing compared to do "text" + "more text" + variable

inner jewel
#

i'd rather do a + b than \`$a$b\`

#

fuck you discord

inland ridge
#

How to make like when that the fs says how much files are in a map in the code like (commands)
Libary: discord.js btw

inner jewel
#
c = a + b

c = `${a}${b}`
inland ridge
#

Nobody me

earnest phoenix
#

How Do I Integrate A Discord Bot With A Site / Game?

torn folio
#

What do you mean? @earnest phoenix

earnest phoenix
#

@torn folio
For example, how do I get analysis on a Minecraft server?

torn folio
#

Man that is a loaded question. Probably a query server into a script that checks your .yml files and other Minecraft files relevant to your tastes/setup

#

There is a lot of ways you could do that. Look into how other users are doing it. Minecraft has a pretty grand knowledgebase of information to go through

earnest phoenix
#

Thanks 🙂

torn folio
#

If you get stuck anymore, come back here with more specific development questions with code

#

People are more than happy to help you fix your code but a really broad question like that will only give broad to no answers lol

storm solar
#

can anyone please help me with this - i'm using Discord.JS and just tried to get better-sqlite3 via npm
i already looked at problems on websites like stackoverflow, etc... and none of the answers on those websites helped

Error: The module '/[path to my bot]/node_modules/better-sqlite3/build/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).```
If you need any info just tell me please
P.S. npm rebuild and npm install don't solve the problem
earnest phoenix
#

if (!message.content.startsWith(ayarlar.prefix) | message.content.startsWith(`<@${client.user.id}>`)) return;

It does not work . Please help me .

mossy vine
#

|| instead of |

earnest phoenix
#

@storm solar No Error Message.

storm solar
#

try what cyber28 said

earnest phoenix
#

Not Work

grim aspen
#

is there an error message

#

hold up

mossy vine
#

negate your second statement

grim aspen
#

i realized same thing

earnest phoenix
#

(node:2082) DeprecationWarning: Collection#find: pass a function instead

mossy vine
#

unrelated, but still a warning

#

you are probably using an old guide/tutorial

earnest phoenix
#

i have message.js **```(const ayarlar = require('../ayarlar.json');
let talkedRecently = new Set();
module.exports = message => {
if (talkedRecently.has(message.author.id)) {
return;
}
talkedRecently.add(message.author.id);
setTimeout(() => {
talkedRecently.delete(message.author.id);
}, 2500);
let client = message.client;
if (message.author.bot) return;
if (!message.content.startsWith(ayarlar.prefix) || message.content.startsWith(<@${client.user.id}>)) return;
let command = message.content.split(' ')[0].slice(ayarlar.prefix.length);
let params = message.content.split(' ').slice(1);
let perms = client.elevation(message);
let cmd;
if (client.commands.has(command)) {
cmd = client.commands.get(command);
} else if (client.aliases.has(command)) {
cmd = client.commands.get(client.aliases.get(command));
}
if (cmd) {
if (perms < cmd.conf.permLevel) return;
cmd.run(client, message, params, perms);
}

};)```**

mossy vine
#

in the name of everything that is holy

#

what the fuck

earnest phoenix
#

Is it Forbidden to Send Code?

#

tab not even once

grim aspen
mossy vine
#

the entire code is wrapped in that

#

for some reason

#

and its not an IIFE either

earnest phoenix
#

What should I do ?

grim aspen
#

i've never seen a command handler like thatt

earnest phoenix
#

trying to make a list of server name + member count

#

gotten it to work with just server names but not sure how to also get member count at the same time

#

also tried this

#

but it only returns member count

#

the example at the very top returns this

west spoke
#

Ight likely a dumb, and probs off topic question. I digged around through google, how do I get+store player coordinates in 1.12.2 using scoreboard values

eternal mesa
#

@earnest phoenix I mean you are mapping to an object...

#

So why are you surprised when you get an object back

earnest phoenix
#

:<

eternal mesa
#

Alternatively you can map to a string and use template literals

earnest phoenix
#

not sure how i would do that

#

could you link me to somewhere with examples ?

eternal mesa
#

@earnest phoenix think about what map does. First explain that to me.

#

Then I will help you with the next step

earnest phoenix
#

to my understanding map lets you go through an array or similar and run a function on each element ?

eternal mesa
#

Correct

#

And what does it return

earnest phoenix
#

depends on the function ?

eternal mesa
#

Well what will the overall result of a map me

#

Be

#

Regardless of the function itn operates on

vital lark
#

It returns an Generic Type of U aka it'll be be an array of what you return

eternal mesa
#

August shut up

#

I am teaching right now

#

Please see me after class

earnest phoenix
#

an array :>

vital lark
eternal mesa
#

But yeah it returns an array

#

So if you want to display data what should your map function return

earnest phoenix
#

string ?

eternal mesa
#

Yeah

#

So how can you combine the server name and member count into a string

earnest phoenix
#

str = a+" "+b ?

eternal mesa
#

I mean yeah but this is where I was talking about template literals

earnest phoenix
#

i looked into it a bit

#

but wasn't sure how it related

#

from what i saw it's handy if you want to avoid using stuff like "\n"

#

for readability

vital lark
#

Template literals are just this: ${any} in an "`" strings

eternal mesa
#

^

sullen yacht
grim aspen
#

that's table flip

#

oops shit

eternal mesa
#

Instead of a lot of pluses, you can do that

sullen yacht
#

(╯°□°)╯︵ ┻━┻

#

ah

eternal mesa
#

But I think you can figure it out now @earnest phoenix

earnest phoenix
#

aight i'll try

pliant needle
#

Who tf is twist

#

Like lmao

eternal mesa
#

@earnest phoenix nice

earnest phoenix
#

very nice

#

👌

#

so string literals uses placeholders like in c ?

#

asking cause i ended up just using the plus operator :>

#

${any} cause that confused me, never seen that before

#

my var value is ${var} ?

eternal mesa
#

Exactly

earnest phoenix
#

so just like placeholders in c ?

copper cradle
#

just remember

#

``

eternal mesa
#

Equiv to “my var value is “ + var

earnest phoenix
#

printf("my var value is %d",var);

copper cradle
#

no

#

`my var value is ${var}`

#

you put the var in the string

earnest phoenix
#

i get it

#

just reminds me of placeholders in c

copper cradle
#

ye

earnest phoenix
#

does js have placeholder options like %.d

#

or %*.d

copper cradle
#

ye

#

%s String.
%d,%i Integer number.
%f Floating point number.
%o Object hyperlink.

#

but

#

node.js doesn't support %f

#

just use %d

earnest phoenix
#

oh wow, js literally has the %d etc. placeholders

#

very neat

copper cradle
#

ye

earnest phoenix
#

all the servers with arabic names has the order of servername, membercount switched

#

so it's membercount, then server name

#

because arabic is being written in right to left

unique nimbus
#

I think its the same in Hebrew

#

but idk

earnest phoenix
#

so anything that has a arabic letters in it is assumed to be an arabic system and auto flips for it to be readable to arabs

#

yeah

#

isn't that problematic for Arabic coders though ?

#

because they would have to write their code in "reverse" order

amber fractal
#

You can switch to right-left in some code editors I'd expect

earnest phoenix
#

ah okay

#

Wait what, you would have to code from right to left if ur arabian and coding in arabian?????????

unique nimbus
#

yes

earnest phoenix
#

That hurts my brain

unique nimbus
#

Arabic countries was raised to do that

#

sooo

#

¯_(ツ)_/¯

quartz kindle
#

Well, some asian countries write from bottom to top

#

Imagine programming that way

copper cradle
#

oof

earnest phoenix
#

arabic shouldn't exist #remove-arabic
if only you knew the historic impact

copper cradle
#

it's a joke

#

do I need to use the /s ?

loud salmon
#

yes

copper cradle
#

bruh what

pliant needle
#

So member.kick isn't working, and I assume I'm doing it wrong. Lib is discord.js

sudden geyser
#

Are you sure member is an instance of GuildMember

pliant needle
#

....Maybe

#

Not 100%

sudden geyser
#

try logging it to see if it's a guildmember object

pliant needle
#

Aight

slim heart
#

What does a stringified FormData look like when it’s sent in a request body? Like how does it send it

lusty dew
#

How can I make a variable that is set to args[0] be optionla?

#

optional&

#

**

#

Because that variable is meant to pick up a number

#

but in some casses a number may not always be required

#

and it errors saying that -users is not a valid int

quartz kindle
#

if you're giving it to a function, you can declare the function with default values

#
function something(arg = "default") {
    // arg will be "default" if nothing is given to the function
}```
lusty dew
#

Nah

#

It is for a purge command

#

I am having flags and such to delete certain things like:

-bpurge 100 -users //Deletes 100 user messages but 
-bpurge -users //Will only delete 1 user message (1 being the default) but it errors saying -users is not a valid int
#
let num = args[0];
            const parse = isNaN(num);
            if(parse){
                args[0] = 1
            }

Someone was talking about replacing what args[0] was

quartz kindle
#

because in your case, if you omit an argument, the next argument becomes the previous

lusty dew
#

if the input was not a number

quartz kindle
#

so you need to check if args[0] is one or the other

lusty dew
#

Yea

#

That is what the variable parse is doing

#

isNaN(num)

#

if(parse){args[0] = 1}

quartz kindle
#

yes

lusty dew
#

But that doesn't work

quartz kindle
#

because then you lose the user

#

because user is in args[0]

lusty dew
#

Huh?

#

But I thought the code is checking if it is not a number and if it isn't replacing what args[0] is?

quartz kindle
#

yes, but why is it not a number?

#

because its a user

lusty dew
#

Huh?

quartz kindle
#

command number user

lusty dew
#

It isn't a specific user

quartz kindle
#

args[0] = number
args[1] = user

#

if you remove number

#

args[0] = user

lusty dew
#

Yea I know

#

I am trying to find a way to either replace what args[0] is if it isn't a number or add in the default value in front of the array

#

I understand it isn't a number bc it is a user

quartz kindle
#

you're not doing anything wrong

#

you are replacing it correctly

#

but if you need args[1] anywhere else in the code, you need to move it from args[0] before you replace it

lusty dew
#

Oh wait

#

Yea

#

Also I think I found the problem

#

LOL

#

num is set as args[0]

#

and I am using that here:

await message.channel.messages.fetch({limit: num})
#

That is one of the problems

quartz kindle
#

well, you can also do it like that, move everything off args

#

and use num instead everywhere

lusty dew
#

Wait what?

quartz kindle
#

@slim heart afaik it should be a buffer/binary, since it can send files and such

lusty dew
#

Btw I don't think I need to use args[1] for the "user" flag

#

            if(message.content.endsWith("-users")){
                const delMessage = await message.channel.messages.fetch({limit: num}).then(msgs => {
                    return msgs.filter(m => !m.author.bot)
                });
                await message.channel.bulkDelete([...delMessage.keys()])
                await message.channel.send("I have deleted " + num)
            }

This works perfectly fine no?

#

even if they do:

-bpurge 100 -users
#

it will still delete 100 user messages correct?

#

Yea that works fine

quartz kindle
#

yes should work

lusty dew
#

My issue is just if they don't want to supply a number of messages to delete

quartz kindle
#

but then you need to think about consistency

#

as your command will work if you do -bpurge 100 uoheofuhqouhqfoq qoufhoquwhf ouqhwfouq -users

#

but not if you do bpurge 100 -users ouehfowuefw

lusty dew
#

Yea

#

Didn't think about that

#

Hm

#

Is there a way to fix it?

quartz kindle
#

dont use endsWIth?

slim heart
#

@quartz kindle I think it just sends a buffer with it as the value?

lusty dew
#

Well yea

#

But like

#

how else would I do it?

#

Just use args[1]?

slim heart
#

not necessarily the entire thing but again idk

quartz kindle
#

i think the formdata is sent as a buffer yes, since there isnt any way of stringifying it

#

but you can enumerate it and extract data from it and build an object or query strings

slim heart
#

mk

#

ty

quartz kindle
#

@lusty dew sure

#

unless you have arguments that need spaces

#

like -bpurge 100 user name with spaces

lusty dew
#

Hm

#

I plan on just using flags

#

or allow them to use a a specific persons mention

quartz kindle
#

using a delimiter/identifier and flags is imo the best option

#

then you can just split on those delimiters

#

command -option1 value1 -option2 value two .split("-")

#

then it becomes easy to select everything in between two delimiters and recognize it as an option and value

slim heart
#

you mean an argsv parser?

lusty dew
#

Hm

#

So wait

quartz kindle
#

something like that

lusty dew
#

Basically like:

const options = args[1].split("-")
#

?*

#

Or

#

just

#

args.split("-")

quartz kindle
#

no, because your args is probably the message content split on spaces

#

that would be a replacement for args

#

splitting the message content on delimiters instead of spaces

#

but thats only really needed if you have more complex arguments

#

if all your arguments are simple words and such, you dont really need it

slim heart
lusty dew
#

Okay

#

This is confusing me sorry

#

LOL

quartz kindle
#

then stick with args

slim heart
lusty dew
#

No not the package

slim heart
#

i mean it works

lusty dew
#

haven't looked at ut yet

#

I meant what you were saying Tim

quartz kindle
#

i also use -- delimited arguments like that package, but i just made it myself

#

also, there are many phones that automatically convert -- to emdash

#

which will screw that up

lusty dew
#

Yea

#

It happens to me quite a bit

slim heart
#

pr yargs ezpz

quartz kindle
#

i like not having tons of deps lul

lusty dew
#

Okay well yargs looks easy how you’re using it

#

If I may ask what is 'setting' in that example @slim heart

#

Is that what you’re applying the 'key' and value too?

slim heart
#

well its just another argument example

#

meaning you can use _ to parse your command name and the rest of your arguments while still having argv args

lusty dew
#

so key could be --users?

viral spade
#

Is it possible that with the discordjs sharding manager two shards have the same guild at the same time, even if only for a short moment?

hushed berry
#

@viral spade thats not really how discord sharding works

#

so, no

#

not unless its logging into the same shard twice

#

or running different shard counts

viral spade
#

ok and when the autosharding program creates a new shard becasue of rising serversize, will the servers be newly distributed and some servers shift from one shard to the other?

lavish shuttle
#

What version of d.js are you using?

hushed berry
#

@viral spade no, thats not how sharding works

#

a server will always map to the same shard

#

servers can never move between shards

viral spade
#

so the new shard will start with 1 server?

hushed berry
#

No

#

Here, let me try and explain it

#

basically, this is the formula that determines which shard a guild maps to

#

(guild_id >> 22) % shard_count

#

This formula will always produce the same shard id

#

when a shard logs in, any guilds that map to that shard via that formula will be assigned to it

#

There's no load balancing involved, guilds cant move between shards

#

etc etc

sinful lotus
#

if you try to spawn 2 shards on a bot with 1 guild

#

one shard will have no guilds at all

#

there will be no duplicate guild on another shard

outer tulip
#

I have a question, which command can i use to see how many servers my bot is in?

sinful lotus
#

if discord.js client.guilds.size

outer tulip
#

ok thanks

mossy vine
#

so im working on a fighting system, where i want to determine how many times the player/enemy attacked since the last tick (determined by a speed value) (every tick is 3 seconds) but im getting outputs alternating between 0 and 3 or -1 and 4, and i have no idea how i would do it properly (it should be 3 consistently, because speed is 1000 and every tick is 3000 ms)

im essentially determining number of attacks since last tick as (lastTick - lastAttacked) / speed and lastAttacked as lastTick + Math.floor(times) * speed

drowsy sentinel
#

Couldn't you just use an interval (3 sec) and every time it's called it would output and reset the accumulated attacks given by player/enemy?

mossy vine
#

i am using an interval

#

lemme show the code i have rn

#
function determineAttacks(lastTick, lastAttacked, speed) {
    console.log(lastTick, lastAttacked, speed)
    times = (lastTick - lastAttacked) / speed
    console.log(times)
    return [Math.floor(times), lastTick + Math.floor(times) * speed]
}

module.exports.fightManager = async (message, enemy, player) => {
    let lastTick = Date.now()
    enemy.lastAttacked = Date.now()
    player.lastAttacked = Date.now()
    const m = await message.channel.send('', construct(enemy, player))
    const v = setInterval(_ => {

        console.log(enemy, player)
        m.edit('', construct(enemy, player))
        atks = determineAttacks(lastTick, player.lastAttacked, player.speed)
        let [dmg, lastAttacked] = atks
        player.lastAttacked = lastAttacked
        lastTick = Date.now()
    }, 3000)
}```
drowsy sentinel
#

So we're essentially just measuring timestamps?

mossy vine
#

basically

drowsy sentinel
#

I'd recommend using moment, to which you can use .fromNow and .diff

mossy vine
#

lemme check it out

late hill
#

It would make sense for the first run to be 0 as lastTick and lastAttack will be equal/very similar

#

You're only editing them after determining the attacks

mossy vine
#

yes

#

but afterwards it should be consistently 3

#

not alternating between -1 and 4

late hill
#

It does seem right so it's probably just the timestamps that aren't exactly reliable
Have you tried debugging it, putting some breakpoints to see what exactly is going on

mossy vine
#

yes, i have a ton of console.logs but i have no idea why the end result is not what i expect

late hill
#

Ok so

#

I've tested a bunch of stuff

#

For testing purposes I didn't use message at all

#

The results I get are 0 3 0 3 ...

mossy vine
#

wha

#

well thats something but still not perfect

late hill
#

I'm thinking your 4 and -1 is because awaiting the message increases the time slightly

#

Which offsets a bunch of stuff

mossy vine
#

yeah and rounding causes it to be 4 and -1

late hill
#

Yes

mossy vine
#

but why isnt it 3 consistently?

late hill
#

I can explain that too

#

Sec

#

You're editing lastAttacked to lastTick + the time it attacked

#

Which makes it so that the next run

#

lastTick is ~equal to lastAttacked

#

Meaning it becomes 0

#

Basically the issue is just the order of which you're saving stuff

mossy vine
#

oh

#

so what would be the correct order?

late hill
#

That's a good question

mossy vine
#

ouch

late hill
#

Ok so

#

I think it makes more sense for your determineAttacks to check between lastTick and the current time

#

will present you with a constant -3

#

Because the order is just wrong in the calculation if you're doing it that way

mossy vine
#

would that work even if speed is larger than 3000?

late hill
#

hmm

#

lemme just try

#

No 😂

mossy vine
#

yeah thats why im calculating from lastAttacked

late hill
#

That would mean that you should compare lastAttack with the current date

#

Instead of the lastTick in my above example

#

and lastAttack would have to be updated only if there was an actual attack

mossy vine
#

oh yea

quartz kindle
#

Is the interval always gonna be 3000?

late hill
#

Yeh I got it to work with speeds above 3000

#

Basically you just have to pass player.lastAttacked instead of lastTick

#

And it works

mossy vine
#

yes tim, always 3000

#

and thanks wesley

#

ill try it out

quartz kindle
#

Cant you just 3000/player.speed then?

mossy vine
#

uh good question

late hill
#
function determineAttacks(lastAttacked, currentTime, speed) {
    console.log(lastAttacked, currentTime, speed);
    times = (currentTime - lastAttacked) / speed;
    console.log(Math.floor(times));
    return [Math.floor(times), lastAttacked + Math.floor(times) * speed];
}

module.exports.fightManager = async (message, enemy, player) => {
    let lastTick = Date.now();
    enemy.lastAttacked = Date.now();
    player.lastAttacked = Date.now();
    //const m = await message.channel.send('', construct(enemy, player));
    const v = setInterval(_ => {

        console.log(enemy, player);
        //m.edit('', construct(enemy, player));
        //atks = determineAttacks(lastTick, player.lastAttacked, player.speed);
        atks = determineAttacks(player.lastAttacked, Date.now(), player.speed);
        let [dmg, lastAttacked] = atks;
        player.lastAttacked = lastAttacked;
        lastTick = Date.now();
    }, 3000);
};

//run test
module.exports.fightManager(undefined, {}, {speed: 4000});```
#

This will give 0 1 1 1 0 ... as attacks

#

Which is correct

#

Calculating the attacks there should be per time unit

mossy vine
#

yeah, thats exactly how it should be

late hill
#

As for the delay with the message

#

You could just ignore the promise and not await it

#

Or send the message after setting the interval

mossy vine
#

im not awaiting the one thats in the interval tho

late hill
#

If you remove my commented line awaiting the message, it means the time between lastAttacked and now won't be exactly the time of the interval anymore

#

Instead it'll be the time of the interval + the awaited time

quartz kindle
#

A ticks system should not be date based, because date is inconsistent

#

Unless you work with low level languages and cpu ticks or somethong

late hill
#

That's a fair point

#

The interval delay is a consistent hard coded value so you should be able to achieve the same thing without using any dates at all

quartz kindle
#

Exactly

#

Just use the 3000 tick for everything

late hill
#

Instead of comparing times, you just assume that your 3000 tick has passed

quartz kindle
#

LastAttacked = lastAttacked + 3000

#

Attacks = 3000/speed

#

Etc

mossy vine
#

lastAttacked has nothing to do with the tick interval tho

quartz kindle
#

Then why do yoi set it on every interval?

#

You can define it from a date outside of the interval, then increment it by ticks

mossy vine
#

lastAttacked should be the timestamp the last attack occured on. if speed is 4000, then lastAttacked should still be 0 after 1 tick

quartz kindle
#

If it should be 0 then its not a timestamp

mossy vine
#

this is why you dont cut out a few words from a sentence without reading through the entire thing
it should be the last ticks timestamp

quartz kindle
#

a timestamp is never 0 unless your date is 1970

#

You mean a time difference

mossy vine
#

yeah i know, i fucked up my logic there

quartz kindle
#

check if the message content is your bot id, and if it is, send your prefix

quartz kindle
#

@mossy vine ```js
function determineAttacks(lastTick, lastAttacked, speed) {
let times = (lastTick - lastAttacked) / speed;
return [Math.floor(times), lastAttacked + Math.floor(times) * speed]
}

async function test(message, enemy, player) {
let d = Date.now();
let tick = 3000;
let lastTick = d;
//enemy.lastAttacked = d;
player.lastAttacked = d;
//const m = await message.channel.send('', construct(enemy, player))
let v = setInterval(_ => {
//m.edit('', construct(enemy, player))
lastTick += tick;
let atks = determineAttacks(lastTick, player.lastAttacked, player.speed);
let [dmg, lastAttacked] = atks;
player.lastAttacked = lastAttacked;
console.log(dmg,lastTick,lastAttacked)
}, tick)
}```

#

i tested it and gives consistent timestamps

#

with a speed of 4000

pure creek
#

If I’m using the master branch of discord.js rather than the npm release will the dbl object still be able to take the client object as a parameter or will I have to handle member/server count submission manually? Djs master updated to using a userstore so I imagine there’d be some differences in how that’s handled under the hood

quartz kindle
#

dbl doesnt care about users

#

it takes the guilds object, which is the same in master

#

so yes, it should work

pure creek
#

Sounds good, thanks

slim heart
#

Well guild object isn’t the same it’s now a GuildStore

pure creek
#

Ooh

slim heart
#

However the property of client.guilds is still a collection

#

So client.guilds.size is still the same thing and that’s what djs uses so ye

pure creek
#

Ok I’ll give it a go, thanks guys

weak parrot
#

Okay so I'm trying to make a website using Express JS. Currently trying to make it so I can just link CSS files from within my EJS files. Looked online however so far nothing has worked.

File path/structure
`
Website

I've tried:
Absolute and normal paths, with and without the /public in the CSS href path (since EJS should render that out).

amber fractal
#

Dont you just link it normally?

weak parrot
#

I already followed everything on there still cannot load the file

#

Cause apperently as long as you tell EJS where the files are you should be able to just link them

#

But it's not working for me

#

Yeah even at home it's not finding it so it's not my school network blocking it either

gentle blade
mossy vine
#

what language are you using

amber fractal
#

I dont use ejs much, but I'll see if I can get something working for you Timo

weak parrot
#

Thanks I appreciate it

amber fractal
#

I got it to work one sec

#

Wait you already have <link href="/CSS/styles.css" rel="stylesheet" type="text/css">

weak parrot
#

🤔

amber fractal
#

Weird it works for me

weak parrot
#

Welp idfk then

#

Could you DM me the whole thing you have working as a zip just to make sure it's not some dumb thing?

amber fractal
#

I just uploaded it to github lmao

quartz kindle
#

do you have express configured to serve static files from /CSS ?

amber fractal
#

I would've just put it in to a zip, but Im at school and discord is blocked on the chromebooks so I wouldnt be able to upload it

weak parrot
#

As far as I'm aware yes I have Tim

amber fractal
#

app.use(express.static(__dirname + '/public')) should work

#

(What you have)

weak parrot
#

Oh well currently just using regular html with live servers. I'll look more into it when I get home

amber fractal
#

I dont think it would matter, but you could try to use path instead of concatenating with +, but I really dont think it'd make a difference

ivory pebble
#

I'm doing some image manipulation stuff where I'm drawing two circles using canvas but for some reason it only draws one circle instead of two:

      const a = await Canvas.loadImage(message.author.displayAvatarURL);
      ctx.beginPath();
      ctx.arc(415+radius2, 59+radius2, radius2, 0, Math.PI * 2, true);
      ctx.closePath();
      ctx.drawImage(a, 415, 59, radius2*2, radius2*2);

      const avatar2 = await Canvas.loadImage(user.user.displayAvatarURL);
      ctx.beginPath();
      ctx.arc(509+radius, 377+radius, radius, 0, Math.PI * 2, true);
      ctx.closePath();
      ctx.clip();
      ctx.restore();
      ctx.drawImage(avatar2, 509, 377, radius*2, radius*2);```
I've been trying to solve this problem for days now
Result of the command: https://cdn.discordapp.com/attachments/566054411378491393/626045219942563900/punish.png
#

I basically want both to be circles

west spoke
#

You just need to add a filter to the image

amber fractal
#

Yeah the canvas api is... uh... Bad

#

I hate using canvas

mossy vine
#

@quartz kindle @late hill thank you guys so much, its working perfectly

quartz kindle
#

@ivory pebble any reason why you're using ctx.restore() there?

valid frigate
#

im looking at topics on clustering a node process, what would I have to modify on my bot to make clustering possible (via pm2 for example)

#

doesn't have to be specific, just a general idea

quartz kindle
#

pm2 clustering requires your process to be stateless (mostly)

#

meaning, it cant contain cached/saved/identifiable data without a way to share it across instances

#

clustering via node-cluster is the same as having a master process that spawns child processes

#

you can run a different set of code if the current instance is the master

valid frigate
#

yeah i was mainly concerned about making the app stateless

#

since a lot of libs cache messages

#

does this matter?

quartz kindle
#

for a discord bot, the main problem is figuring out which instance is which process

#

because of sharding

#

if instance 3 doesnt know which instance it is, it wont know which shards to assign itself

valid frigate
#

hmm yeah

quartz kindle
#

the way i did it was to use the pm2 package to gather info about the processes in the cluster

valid frigate
#

i saw that in your repo

#

apparently pm2 has an npm packagemmulu

quartz kindle
#

it has many lul

valid frigate
#

o I would guess

#

but yeah

quartz kindle
#

like pm2/io which lets you send commands from a pm2 command line into a running process

valid frigate
#

damn ok

#

last time i tried clustering, my bot sent the same message twice lmao

ivory pebble
#

@quartz kindle even if I remove it nothing happens

quartz kindle
#

@valid frigate sharding overlap? 2 processes logging in with the same shard id

#

@ivory pebble what if you remove the clip?

ivory pebble
#

All of em become squares

quartz kindle
#

so the problem is with the first image, not the second

#

what if you add the clip to the first image?

valid frigate
#

@quartz kindle so if im correct on this, i just have to make sure that when spawning a new process that its client doesn't occupy guilds that are already being served

ivory pebble
#

The second image doesn't even appear

#

its so bizarre

quartz kindle
#

@ivory pebble save(); clip(); draw(); restore();

#

@valid frigate make sure that its shard id is not already logged in elsewhere

#

shard ids take care of organizing guilds for you

ivory pebble
#

in the second or first image

quartz kindle
#

in both

ivory pebble
#

ok

valid frigate
#

hmm?

#

so just ignore logging in if the shard is already logged in

#

and move on to shard x, etc

quartz kindle
#

if you have a way to detect that, then yes

valid frigate
#

what would be your preferred method?

quartz kindle
#

like asking other processes which shard id they are currently on

valid frigate
#

since it does seem hard

#

ah ok

quartz kindle
#

i did it the easy way

#

get process id and how many shards per process

#

for example, if shardsPerProcess = 2; and total processes = 2; then process0 = shard 0,1 and process1 = shard 2,3

valid frigate
#

oh ok

ivory pebble
#

Thank you so much Tim!

#

It works!

quartz kindle
#

👍

valid frigate
#

ok cool yeah let me try that out

quartz kindle
#

alternatively (and probably the easy way) would be to have an external process/script controlling that

#

which goes back to the master/children system that everyone uses lol

#

discord is really made for a master/children setup

#

but i decided to be stubborn xD

valid frigate
#

hooh

vagrant bison
#

Will you give me a script that will create a server invitation? in discord.js

#

~ i am using google translate

mossy vine
#

no

grim aspen
vagrant bison
#

thank you

stray garnet
#

question for that. How can i do that when my Bot dont have Permissions to create an Invite that it says sth like No Create available

amber fractal
#

You dont

#

If it doesnt have perms, there's a reason

#

Also, creating invites without the permission of the owner is not allowed.

stray garnet
#

Oh

quartz kindle
#

hes asking how to detect that it cant, and provide a message accordingly

stray garnet
#

Yes exactly

quartz kindle
#

if i understood correctly

stray garnet
#

but how

quartz kindle
#

the easy way is to try to do it, and catch an error

#

the best way is to check for permissions

zinc lichen
#

my bot not in server ?

#

-bots

gilded plankBOT
stray garnet
zinc lichen
#

not in server

stray garnet
#

Whats the Bot ID?

zinc lichen
#

593000879876079616

#

@slow plover

stray garnet
#

weird

#

@slow plover

#

hm

quartz kindle
#

send a dm to the mod that approved it

stray garnet
zinc lichen
stray garnet
#

how would i get the size of streamers?

earnest phoenix
#

what

loud salmon
#

@earnest phoenix obviously he wants the size of the bytes when people are streaming

earnest phoenix
#

1024 mmLol

loud salmon
#

wait no

#

he might be talking about the weight of streamers

#

that would involve scraping wikipedia mmulu

#

or the actual size of the word streamers

wheat jolt
#
db.query(`UPDATE minillama SET ${Object.keys(form).indexOf(question) + 1} = '${r.first().content}' WHERE userID = '${msg.author.id}'`)
#

does anyone know wtf I am doing wrong

hushed berry
#

use prepared statements 👀

loud salmon
#

what lang and what database engine @wheat jolt

#

also yea

#

preparedstatements unless getting your sql injected is a plan of yours

hushed berry
#

you're vunerable to SQL injection

#

😂

loud salmon
#

@hushed berry inject me with ur sql

earnest phoenix
#

just use an orm 🙃

valid frigate
#

ok so i need some help with clustering a little bit

#

basically i'm not sure how to prevent a sharded client from logging in to a shard that already has a connection

#

and if it's relevant the lib i'm using is eris

devout chasm
#

you mostly do that manually i would say

#

atleast i would do that

#

so like

unique nimbus
#

😩

devout chasm
#

just don't let it log in

valid frigate
#

ok cool

devout chasm
#

what exactly are you trying to do

valid frigate
#

uh to summarize

#

i'm using the node cluster module to spawn, say 2 workers of my main file

#

which spawns a client with 2 shards

#

the whole thing doesn't make sense to me but that's the general idea lmao

devout chasm
#

hm i see

#

ye well i don't really like that way of "clustering"

#

so i've never used that

#

so can't help that much

valid frigate
#

do you prefer single process?

devout chasm
#

i prefer clustering with containers

valid frigate
#

like docker

#

o

devout chasm
#

kinda

#

but not really

#

i'm referring to kubernetes, but that's prolly too much

valid frigate
#

oh kubernetes

devout chasm
#

well that would be proper clustering

valid frigate
#

i guess the same concept still stands

#

i mean i guess after this my question is how do i communicate between processes

devout chasm
#

yeah that's hard to do with that kinda setup

earnest phoenix
#

ugh

scarlet phoenix
#

Just use/make an api imo

quartz kindle
#

@valid frigate are you still trying to do it on pm2? or are you using node-cluster now?

valid frigate
#

i'm not even sure lmao

#

although probably pm2

#

it's got clustering built in

quartz kindle
#

for pm2 you need either to get info from the process list, or communicate between processes, which can be done either through the pm2 module, or through an external library such as message brokers or pub/sub databases

#

something like rabbitMQ would also work

valid frigate
#

mm ok

junior gale
#

Hi, I tried to make a DirectMessage, but I cant, I wanna do that my bot send a dm to the tagged person in X command like:

command @junior gale | arg

BOT: Sends arg to the tagged person (@junior gale)

cobalt umbra
#

@junior gale what library

junior gale
#

I tried to:


if (message.author.id !== 'id') return


    const user = message.mentions.users.first();
      const member = message.guild.member(user);

 const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
    
let a = args.join(" ").split("|")


 let msg = a[0];

if(!mensaje) return message.channel.send(`Escriba un mensaje para enviartelo por privados.`);




message.author.send('${msg}');```
#

I use .js

cobalt umbra
#

meh no experience with it and I dislike it

junior gale
#

I searched at all the guides I know but nothing xd

amber fractal
#

You cant have your bot dm people from another user's command

junior gale
#

wdym

amber fractal
#

A dm command

#

It's not allowed

junior gale
#

oh

#

But, I can use if (message.author.id !== 'id') return

#

No?

copper cradle
#

ofc

#

@junior gale use ===

#

never use ==

#

use strict comparators

#

they check for equality

slender thistle
#

Depends tbh

copper cradle
#

while this fucker == checks for a common type

#

ik

#

but I mean

#

most ppl here will never use ==

#

(I'll include myself)

sudden geyser
#

== 🤢

broken shale
#

== isn't that strict on types

#

I prefer ==

dusky mist
#

@copper cradle if u need an id is ==

broken shale
#

BOTH == and === works

slender thistle
#

=== is strict type

quiet dagger
#

@copper cradle there may be a case where you want to use == :)

modern elm
#

first off

#

he used !==

#

sooo

quiet dagger
#

It's like you say something is bad before you even consider it's usage

#

He used if (command == 'xx') @modern elm

broken shale
#

!= or !== is the same concept, just one is strict

modern elm
#

But, I can use if (message.author.id !== 'id') return

#

he used that

#

and was then admonished for using ==

#

when he didnt even

slender thistle
#

See the top line in that codeblock

quiet dagger
#

Yes he used pure ==

slender thistle
#

Is it really that important

modern elm
#

an awkward silence commences as he realized he was wrong

#

he slowly leaves the conversation

slender thistle
#

Let's not

modern elm
#

?

quiet dagger
#

It is important to stop others teaching others retarded stuff :)

broken shale
#

theres a missing }

#

also if you want strict, easiest way is 'use strict' mmLol

quiet dagger
#

By the way, === is always slower than == so there where you don't need it, don't use it

eternal mesa
#

@quiet dagger why would === be slower?

#

That doesn’t make sense to me at all

quiet dagger
#

Because it is

eternal mesa
quiet dagger
#

It does the same as == plus one operation more

#

So lets say == does n operations

#

=== does n+1

#

n < n+1

eternal mesa
#

== sometimes has to do type conversions

#

=== does not

#

And where are you getting that info from?

quiet dagger
#

=== has to compare types

late hill
#

If I read your code as a developer, and I see that you used == instead of === I would assume that it's possible the 2 values aren't of the same type.

#

If they will always be the same type, you should use ===

#

As that makes it clear.

eternal mesa
#

@quiet dagger yeah but == has to convert both to a common type

#

Also in == I assume it also check if they are the same type to break out of the evaluation faster

#

So what you said doesn’t really make sense to me

#

Tim is a smart guy

#

He can answer this

quartz kindle
#

== and === are roughly the same if the type is equal, but == is slower if the type is not equal

#

but == is still faster than converting types and then using ===

#

(according to some articles and benchmarks)

#

it also depends on browser/node/v8 versions

eternal mesa
#

I think we were looking at the same benchmarks 😉

quartz kindle
#

;)

#

i prefer using === for consistency

eternal mesa
#

I think most people use ===

late hill
#

I think it's also just safe to assume that the difference performance wise will be that miniscule that unless you're working for google, facebook, ... rly shouldn't be something for you to worry about.

eternal mesa
#

That too ^

late hill
#

Focusing on readability/consistency should be higher on your list of concerns megu

quartz kindle
#

type comparisons on a for loop, looping over millions of items

#

every microsecond counts

amber fractal
#

I usually just use == because I rarely care about types. I don't like typed langs for a reason mmLol

earnest phoenix
#

@earnest phoenix that thing u asked

#

yes

#

you could probs make a http post

#

doing like

#

and how i didnt do ever before ._.

#

ok so like

#

the api endpoint is https://discordapp.com/api/auth/login

#

Yes

inner jewel
#

great way to get your account banned

earnest phoenix
#

ik

#

Just trying sth out

#

if it works ill be happ

#

if not ill yeet my pc

copper cradle
#

stop fighting

#

just use ===

inner jewel
#

vim file.js
:% s/===/==/g

copper cradle
#

eueeuwuwueuy

earnest phoenix
#

@earnest phoenix?

#

u ther

#

my bad wasnt sure if to keep going

#

oi

#

when its bannable lol

#

is it bannable from here?

#

with request

#

pls thanks

#

fill the parameters for email and password

#

and post

#

HOW

#

and get response

#

i never did before

#

idk how

inner jewel
#

no one here is going to help you break the discord tos

earnest phoenix
#

oof

inner jewel
earnest phoenix
#

you also have a sextillion resources online telling you how to do a post request

#

Shit

#

ok then thanks

amber fractal
#

Uh wrong channel? Or

valid frigate
#

this is basically an ad but ok good job bud

sudden geyser
#

the ad has sneak 100

quartz kindle
#

its not the first time

potent ivy
#

just showing off tbh

#

thought its okay 👀

unique nimbus
#

wait why is it a discordapp gif url

amber fractal
#

weird flex but ok

earnest phoenix
#

wait why is it a discordapp gif url
probably uploading it to some other channel and then returning the url of it lol

amber geyser
amber fractal
#

can you try npm --v and node -v and tell me what they show?

amber geyser
#

@amber fractal

inner jewel
#

ouch

#

node 4

#

current node is 12

amber fractal
#

your npm version is very out of date, also how did you install node?

#

yeah

amber geyser
#

how to update?

#

@amber fractal

quartz kindle
#

use nvm

#

but node 10.16 is good enough

amber fractal
#

is nvm node version manager? just curious

#

never heard of it before mmLol

#

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs is what I did

inner jewel
#

ew piping stuff to shell

quartz kindle
#

yes, nvm is node version manager

amber fractal
#

¯_(ツ)_/¯

inner jewel
lusty dew
#
                message.channel.bulkDelete([...delMessage.keys()], true)
                    .then(messages => {
                        message.channel.send(`:check: Deleted ${messages.size} messages`)
                    })
#

Any reason why this would return 0 instead of the actual number of messages deleted?

eternal mesa
#

What lib

lusty dew
#

Discord.js

#

And if it is important

#

I am using master version

eternal mesa
#

What is delMessage

#

And is it actually deleting the messages

lusty dew
#

Yes it deletes em

#

and triggers the messageDeleteBulk event which shows the proper number of deleted messages

eternal mesa
#

That’s awfully strange

lusty dew
#

yea

sudden geyser
#

I've had the same issue, but rare/sometimes. I'm assuming delMessage is a collection of messages

lusty dew
#
        async run(message, args){
            args[0] = isNaN(parseInt(args[0])) ? 1 : parseInt(args[0]);
            if(args[1] === "-users"){
                const delMessage = await message.channel.messages.fetch({limit: args[0]}).then(msgs => {
                    return msgs.filter(m => !m.author.bot)
                });
                message.channel.bulkDelete([...delMessage.keys()], true)
                    .then(messages => {
                        message.channel.send(`:check: Deleted ${messages.size} messages`)
                    })
            }
sudden geyser
#

limit is a string, not number

lusty dew
#

No?

sudden geyser
#

oh you re-assigned it nvm

lusty dew
#

yes and even if limit was a string

#

it wouldn't fetch anything and delete it

#

it'd error

valid frigate
#

in the example it's spawning 2 shards/client

finite fable
#

Does anyone have any automated testing for their bots?

lusty dew
#

Wdym

tranquil drum
#

like automated unit tests?

#

in your deployment pipeline?

finite fable
#

Yeah, unit tests are a start

lusty dew
#

Just make a separate bot to test things?

tranquil drum
#

you could implement interfaces to test discord facing code as well

finite fable
#

I've seen other projects like REST api's that will actually spin up the HTTP server and throw stuff at it to see if it works.

tranquil drum
#

that's pretty hardcore

lusty dew
#

I’ve seen people use applications to make post requests and such to test their apis

finite fable
#

I've looked at some projects on github that mock the discord api but itooks like none of them finished.

#

I could roll my own but I was wondering if someone had a framework or something already done.

tranquil drum
#

i mean you could implement your library's interfaces to mimic receiving data from discord

#

i guess that doesn't test your library's code though

finite fable
#

Ok cool, well I'll keep thinking about it. I was just wondering if anyone had anything already.

tranquil drum
#

lol im saying implement whatever library you're using just to mimic receiving data

#

not set up a whole discord api implementation

#

like figure out which functions are called when it receives data from discord and just call those yourself

finite fable
#

You could do that. Most bots probably only use a handful of the apis features.

#

Different topic. Does anyone know how long it takes to get a bot approved to get on the bot list?

tranquil drum
#

~a week i think

#

from personal experience it was 4 days maybe

slender thistle
#

hotasfaq 2

covert turtleBOT
#
Frequently Asked Questions 📜

Click the link to get more information on the question:
2) How long is approval?

unreal hollow
#

how do I send a text message to my discord chat channel when a member joins my server ?

#

i'm using discord py

slim heart
#

Is there a remote mongodb viewer in website form similar to what chateau is to rethink?

unreal junco
#

language - discord.js

#

code:

#
  if(!message.member.hasPermission("MANAGE_SERVER")) return message.channel.send("![cross](https://cdn.discordapp.com/emojis/623401791819874324.webp?size=128 "cross")You do not have access to use this command!");
unreal hollow
#

?

unreal junco
#

it doesnt respond

#

when the user doesnt have perms

#

and it says that error

unreal hollow
#

try instead of "channel.send" add "channel.sendMessage "
i have a similar code to that and it works like this

mossy vine
#

wtf no

#

sendMessage is deprecated as shit

#

and has nothing to do wtih the error

unreal hollow
#

idk

#

i have the same code the only change is sendMessage

mossy vine
#

if you dont know dont try to help maybe?

#

sendMessage is deprecated

#

dont use it

#

its MANAGE_GUILD not MANAGE_SERVER

unreal junco
#

when did that get changed?

mossy vine
#

when did what get changed

unreal junco
#

it used to be manage server

mossy vine
#

i think it was always MANAGE_GUILD

unreal junco
#

no

mossy vine
#

servers have always been called guilds in the api

unreal junco
#

cause last time i coded was back in april

#

in d.js

mossy vine
#

well

#

did changing it to MANAGE_GUILD solve your issue?

unreal junco
#

yes

mossy vine
#

cool

unreal junco
#

i just looked at the old bot i did

#

and it said MANAGE_SERVER

#

so it would of changed to MANAGE_GUILD

mossy vine
#

weird

unreal junco
#

in an update

twilit rapids
#

It's always been MANAGE_GUILD in both Discord API and Discord.js

unreal junco
#

u sure?

twilit rapids
#

Yes

unreal junco
#

even look at tsc videos

#

old*

mossy vine
#

lol tsc

unreal junco
#

old tutorial

#

and the other old videos

#

what tsc was first thing came to mind

sullen yacht
unreal hollow
#

yes

sullen yacht
#

Okay, well there is a on_member_join(): event that you can use.

#

And then you can define the channel using utils.get

#

And then you can send a message/embed to the defined channel

unreal hollow
#

ok i'll try

pure creek
#

how does dbl determine whether a bot is online? My bot status shows ???

unreal hollow
#

yeah i'm searching in that site now

sullen yacht
#

👍

unreal hollow
#

thanks

sullen yacht
#

Np, mention me if you need more help

unreal hollow
#

:)

gritty oar
#

How can I check if someone voted my bot in dbl?

unreal hollow
#

@sullen yacht just 1 question what is the bitrate ??

sullen yacht
#

Bitrate is for voice channels im pretty sure

unreal hollow
#

ok

#

and the "name" is the channel name ?

sullen yacht
#

On what? utils.get?

unreal hollow
#

yes

sullen yacht
#

Yeah

unreal hollow
#

ok

sullen yacht
#

name="channel_name"

unreal hollow
#

ok

stray garnet
#

How to filter the Size of Streaming Pepole?

sinful lotus
#

supply a filter function that checks if people is streaming

#

then check .size of it

unreal hollow
#
@bot.event
async def on_member_join(member):        
    channel = discord.utils.get(guild.text_channels, name='test-1')
    await member.channel.send(
        f'Welcome to coding hell,{member.name}!')  

@sullen yacht i tried this code but it didn't work it says

name 'guild' is not defined
mossy vine
#

because guild is not defined 😩

sullen yacht
#

add guild = member.guild

#

or change guild to member.guild

stray garnet
#

but what the type? @sinful lotus i mean: stream or streaming?

mossy vine
#

@stray garnet read docs

stray garnet
#

k

unreal hollow
#

ok i'll try

sinful lotus
#

it should be on docs

#

cant really spoon feed you directly on what since Im reading

stray garnet
#

outputs me fricking 0

sinful lotus
#

did you look what status contains?

unreal hollow
#

it still didn't work it says

AttributeError: 'Member' object has no attribute 'channel'
stray garnet
#

@sinful lotus wym

sinful lotus
#

also you dont need status

stray garnet
#

wait its game?

amber fractal
stray garnet
#

oh

amber fractal
#

Yea, streaming is a status

stray garnet
sinful lotus
#

it is status

#

maybe undocumented?

inner jewel
#

streaming is an activity type

amber fractal
inner jewel
#

not a status

amber fractal
#

Status is just a status

#

Streaming is part of the activity

sullen yacht
#

@unreal hollow show me your current on_member_join(): event

stray garnet
#

Welp...

unreal hollow
#
@bot.event
async def on_member_join(member):
    await member.create_dm()
    await member.dm_channel.send(
        f'Hello {member.name}, welcome')        
    channel = discord.utils.get(guild.text_channels, name='test-1')
    await member.channel.send(
        f'Welcome to coding hell,{member.name}!')    
sullen yacht
#

Is member.send not a thing? I haven't done dms before

#

give me a minute

unreal hollow
#

no i want to send it in a text channel

sullen yacht
#

Okay, well you need to define guild

#

because you're using guild.text_channels

unreal hollow
#

how ?

sullen yacht
#

well you could either:

  • change guild.text_channels to member.guild.text_channels
    or
  • add guild = member.guild
unreal hollow
#

i tried both and they didn't work

#

I'm using discord py rewrite btw

sullen yacht
#

Try this, without the dm thing.

@bot.event
async def on_member_join(member):       
    channel = discord.utils.get(member.guild.text_channels, name='test-1')
    await channel.send(f'Welcome to coding hell,{member.name}!')```
#

And also i think the reason that it wouldn't send is because you had member.channel.send() but you don't need member. as you defined channel

#

so it's just channel.send

unreal hollow
#

ok

sullen yacht
#

I have to go, but that should work. If it doesn't, mention me or somebody else will probably help

sinful lotus
#

oh tere

unreal hollow
#

@sullen yacht yes it works now thank you

stray garnet
#

exports.run = async (neko,message,args) => {
 
  const filter = (reaction, user) => ['🇦', '🇧', '🇨'].includes(reaction.emoji.name) && user.id === message.author.id;
  
  let embed = new RichEmbed()
  .setAuthor("Advanced Testing Commands")
  
  message.channel.send(embed).then(async msg => {
        await msg.react('🇦')
        await msg.react('🇧')
        await msg.react('🇨')
        await msg.react('❌')
    
        msg.awaitReactions(filter, {
            max: 1,
            time: 30000,
            errors: ['time']
        }).then(collected => {
    
    const reaction = collected.first();
    
       switch(reaction.emoji.name) {
         case '🇦':
           let embed2 = new RichEmbed()
           .setAuthor("succes")
           msg.edit(embed2)
           break;
           
         case '🇧':
           let embed3 = new RichEmbed()
           .setAuthor("succes.")
           msg.edit(embed3)
           break;
           
         case '🇨':
           let embed4 = new RichEmbed()
           .setAuthor("again succes")
           msg.edit(embed4)
           break;
           
         case '❌':
           msg.delete()
           break;
    }
  })
})
}

module.exports.help = {
  name: "test2",
  aliases: []
}```

when i react to ❌ it dont deletes the message
grim aspen
#

Why do you have message and msg?

#

Oh wait nvm

stray garnet
#

yea..

#

help pls

grim aspen
#

Could it be that your bot doesn’t have permission to manage messages?

stray garnet
#

it has Administrator in my test server

hollow saddle
#

Why are you combining .then and async/await

#

It should be one or the other

grim aspen
inner jewel
#

there are legitimate use cases for mixing await with .then

#

eg fetch

#

await fetch(x).then(r => r.json())
vs
await (await fetch(x)).json()

sudden geyser
#

@stray garnet your filter doesn't seem to include the ❌ emoji

#

Also there seem to be spaces between the switch case. When I ran "'🇨'".length, it returned 4. You should check that.

quartz kindle
#

thats normal because these characters require a supplemental character

sudden geyser
#

so letters take 2 but the normal x will take 1 think

quartz kindle
#

Anyways, the Unicode codepoint range goes from U+0000 to U+10FFFF which is over 1 million symbols, and these are divided into groups called planes. Each plane is about 65000 characters (16^4). The first plane is the Basic Multilingual Plane (U+0000 through U+FFFF) and contains all the common symbols we use everyday and then some. The rest of the planes require more than 4 hexadecimal digits and are called supplementary planes or astral planes. I have no idea if there’s a good reason for the name “astral plane.” Sometimes, I think people come up with these names just to add excitement to their lives.

stray garnet
#

@sudden geyser oops thx

quartz kindle
#

"💩" === "\u{1F4A9}". Unfortunately, this is also true: "💩" === "\uD83D\uDCA9". What is this nonsense? All astral codepoints can also be represented by “surrogate pairs”, and this is used for backwards compatibility reasons. This is why "💩".length === 2. There’s a formula to calculate surrogates from astral codepoints, and vice versa.

#

also, "👩‍❤️‍💋‍👩".length === 11

#

lmao

mossy vine
#

bruh

earnest phoenix
#
Please use code blocks for their purpose!

Kindly asking
Plemso```
mossy vine
#

i know this is going to be just as off-topic as the message above this, but why are you using them for something that isnt their "purpose" lmfao

earnest phoenix
#

Because code blocks look sexy af

mystic geode
#

Hy

sullen yacht
#

No problem @unreal hollow

unreal hollow
#

:)

stray garnet
#

how can i do that when i react to the message that the reactions from me get cleared?


exports.run = async (neko,message,args) => {
 
  const filter = (reaction, user) => ['🇦', '🇧', '🇨', '❌'].includes(reaction.emoji.name) && user.id === message.author.id;
  
  let embed = new RichEmbed()
  .setAuthor("Advanced Testing Commands")
  
  message.channel.send(embed).then(async msg => {
        await msg.react('🇦')
        await msg.react('🇧')
        await msg.react('🇨')
        await msg.react('❌')
    
        msg.awaitReactions(filter, {
            max: 1,
            time: 30000,
            errors: ['time']
        }).then(collected => {
    
    const reaction = collected.first();
    
       switch(reaction.emoji.name) {
         case '🇦':
           let embed2 = new RichEmbed()
           .setAuthor("succes")
           msg.edit(embed2)
           break;
           
         case '🇧':
           let embed3 = new RichEmbed()
           .setAuthor("succes.")
           msg.edit(embed3)
           break;
           
         case '🇨':
           let embed4 = new RichEmbed()
           .setAuthor("again succes")
           msg.edit(embed4)
           break;
           
         case '❌':
           msg.delete()
           break;
    }
  })
})
}

module.exports.help = {
  name: "test2",
  aliases: []
}```
copper cradle
#

why would you make a new embed

#

just do embed.setAuthor("success") and then edit msg with embed

west spoke
#

oh my god

#

is that

#

are they

#

creating a new embed for each one

earnest phoenix
#

boolin

quartz kindle
#

it doesnt matter if you create a new one, in the end the message will be sending a new one anyway

#

and hes probably using them as placeholders to later add more data to them

#

sure editing an existing embed will save a few bytes of ram, but not that big of a deal

valid frigate
#

what's the most reliable way to get the information about all shards on all clusters using ipc? right now i'm storing an array of shard data in the master process and the workers send messages which updates on the master process, then broadcasts new shard array to all workers