#development

1 messages · Page 852 of 1

tight plinth
#

interesting

opal copper
#

test this @robust moth : ```js
const online = bot.guilds.get(message.guild.id).members.cache.filter(m => m.presence.status != 'offline').size

tight plinth
#

not every member is cached

opal copper
#

replace bot by your client variable

robust moth
#

@opal copper ok

opal copper
#

@tight plinth maybe it's because he's using the v12, many things changed

tight plinth
#

I'm on v12

opal copper
#

oh

#

so that not it

hallow sandal
#

Never mind, I got the bot to work.

tight plinth
#

lol

#

quick question with discordjs v12 : how to get current shard id

#

and

#

how can I intergrate discordjs sharding manager with dbl webhook system

#

coz 1 shard is ok, but if I lau^nch a second one it tries to create another webhook with the same rort, which causes a bot crash

opal copper
#

if you already have a sharding manager, dbl.post() will post your shardCount

tight plinth
#

?

gentle saddle
#

can anyone help me

tight plinth
#

but client.shards in undefined for me

gentle saddle
#

then there is an error in your code

fleet chasm
#

v12 correct

tight plinth
#

v12 ye

opal copper
#

if client.shards is undefined, that meen you don't have a sharding manager

fleet chasm
gentle saddle
#

anyone know how to like make a help command with reactions that changes the help when you react to a reaction

tight plinth
#

client.shard is defined tho

opal copper
#

wha

#

try to use dbl.post()

tight plinth
#

just dbl.post()

#

?

opal copper
#

2sec i'm verifing if it's this

tight plinth
#

no

#

that will not wolve anything

fleet chasm
#

wolve

tight plinth
#

the problem is that creating another shard creates 2 times the dbl webhook and crash one of the shards

#

and the bot refuses to start

opal copper
#
    dbl.on('posted', () => {
      console.log('Informations Posted !');
    })
#

try this

tight plinth
#

sec

#

it launches once per shard

#

and it crashes if its been aleready launched one time (aka if there is 2shards or more)

#

I just want something to avid the crash

opal copper
#

what the error is saying ?

tight plinth
#

and if I initialize dbl in index.js, how can I "export" it to bot.js

#

sec

elder vine
#

what now?

tight plinth
#

port aleready in use

#

(node:25159) UnhandledPromiseRejectionWarning: Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.

#

and this too

elder vine
#

Oh

opal copper
#

that meen Shard 0 is stop on lauching

#

but why

tight plinth
#

woops

#

it was not the right errror

#

this one is the good one

elder vine
#

Well, you would need the dbl thing where the bot.on("ready") is for when all the shards has launched? or am I wrong?

tight plinth
#

just this

elder vine
#

You're connecting to the port twice then?

tight plinth
#

it seems

elder vine
#

Do you have two shards running?

tight plinth
#
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./bot.js', { token: require('./config.json').tokens.bot, totalShards:2 });

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

index.js

#

yes

#

for now I reverted to 1 to maintain my bot online

elder vine
#

But shouldn't you connect to dbl in the ready event when all shards have been launched?

tight plinth
#

I'm searching how to do that

zenith terrace
#

is that all you need to do for sharding?

#

or is there more

tight plinth
#

renaming ur og index.js to bot.js

#

and this in a new index.js

#

and thats it

zenith terrace
#

so rename my index file to bot.js, make a new index.js then write whats above

tight plinth
#

and do some changes to :
-get total users
-get total servers

marble juniper
#

you will need to eval across all shards to get the guild count or user count and other stuff

#

and you get an array with the responses

tight plinth
#

await client.shard.broadcastEval('what you want to eval')

marble juniper
#

(with the output of each eval)

earnest phoenix
#

anyone know how to use client.guilds to list guilds my bot is now, just upgraded to discord.js V12.1.1 and I regret it

tight plinth
#

@earnest phoenix client.guilds --> client.guilds.cache

earnest phoenix
#

oh

#

thanks!

tight plinth
#

same method as v11, just add .cache

earnest phoenix
#

oof

elder vine
#

better stay with v11 :P jk

marble juniper
#

v12 does include parsing emojis

#

(from a string)

tight plinth
#

the best solution I can find is to throw in a trash dbl webhook

#

but I dont want to

marble juniper
#

so if I got that right your problem is after launching the shards that you get an error that a port is already in use

wet iron
#

i need help

#

i get this error

#

SyntaxError: Unexpected end of input
←[90m    at wrapSafe (internal/modules/cjs/loader.js:1072:16)←[39m
←[90m    at Module._compile (internal/modules/cjs/loader.js:1122:27)←[39m
←[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:1
0)←[39m
←[90m    at Module.load (internal/modules/cjs/loader.js:1002:32)←[39m
←[90m    at Function.Module._load (internal/modules/cjs/loader.js:901:14)←[39m
←[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_ma
in.js:74:12)←[39m
←[90m    at internal/main/run_main_module.js:18:47←[39m

#

in console

#

when i try to run my program

mossy vine
#

you fucked up your {} pairs

small plume
#

Well it means you arent doing the syntax correctly and its missing like a }) etc

mossy vine
#

have fun debugging that one

small plume
#

Are you using VSCode by chance @wet iron ?

wet iron
#

no

#

im using Atom

small plume
wet iron
#
const Discord = require('discord.js');
const bot = new Discord.Client();
const token = "token";
const PREFIX = "! ";

const fs = require('fs');
bot.commands = new Discord.Collection();


const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
    const command = require(`./commands/${file}`);

    bot.commands.set(command.name, command);
}

bot.on('ready', () => {
    console.log("The bot is active and ready to go!");
    if (bot.guilds.cache.size < 2) {
      bot.user.setActivity(`${bot.guilds.cache.size} server blyat!`, { type: 'WATCHING'});
    }else {
    bot.user.setActivity(`${bot.guilds.cache.size} servers blyat!`, { type: 'WATCHING' });
  }
});

bot.on('message', message => {
    let args = message.content.substring(PREFIX.length).split(" ");

    bot.on('messageReactionAdd', (reaction, user) => {
      if (reaction.emoji.name !== '⭐') return;

      let starmsg = message;
      let channel = bot.channel.guild.cache.find(c => c.name === 'starboard')

      let starEmbed = new Discord.MessageEmbed()
      .setAuthor(message.author.tag)
      .setColor("#FFFC00")
      .addField(":star:", starmsg);

      let limit = 4;
      if (channel && reaction.emoji.name == '⭐' && reaction.count >= limit) {
        bot.channels.cache.find(channel => channel.name === 'starboard').send(starEmbed)
      }

    switch (args[0]) {

        case "ping":
            bot.commands.get('ping').execute(message, args);

        break;

        case "8ball":
            bot.commands.get('8ball').execute(message, args);

        break;

        case "flip":
            bot.commands.get('flip').execute(message, args);
        break;

        case "roulette":
            bot.commands.get('roulette').execute(message,args);
    }

};
small plume
#

Youre not closing your message event

tight plinth
#

solved my problem by removing dbl webhooks

small plume
#

At the end put

        }
    });
})```
warm marsh
#

At both events.

elder vine
#

You have an event inside the event?

wet iron
#

thx!

tight plinth
#

and I found how to get current shard id : client.options.shards[0]

small plume
#

But yeah you have an event inside an event which isnt the well best thing cause they wont work

#

move your reaction event out

warm marsh
#

It will work. But its very in-efficient due to it adding a new listener every single time a message is received.

#

Which will in turn call the event multiple times.

elder vine
tight plinth
#

@earnest phoenix dont forget to add cooldown

#

idk how to use mongodb, cant hlp

#

but

#

I can suggest you a system that works even after bot restart

#

timestamps

#

with Date

#

it still works after th bot restart, it doesnt stop

compact tundra
#

he does discord.js have like a connection time out for the bot i noticed that my bot
consistently goes offline 6 hours after no one interacts with the bot

elder vine
#

Are you hosting on glitch or something?

#

Your bot might error out and decide to shutdown.

compact tundra
#

no it’s weird

#

it still connects with a database

#

and i can still get stats

#

only discord no longer gives any events

elder vine
#

Hmm

earnest phoenix
#

how do i do one line embeds?

small plume
#

just dont new line it?

earnest phoenix
#

I'm trying not to have it be multiple lines in the code

zenith terrace
small plume
#

Overall its better to just have multiple lines to read it better

zenith terrace
#

^

earnest phoenix
#

yeah, I am using a function which doesn't let me do taht

#

that*

modest maple
knotty steeple
#

what

small plume
#

Functions do let you do multiple lines?

knotty steeple
#

how

small plume
#

Huh

zenith terrace
#

What..

#

Every embed is multiple lines

#

<_<

small plume
#

Post your code, better for us to understand

earnest phoenix
#
if(cmd.conf.ownerOnly && message.author.id !== client.config.owner.id){
             return this.client.channels.cache.get(this.client.config.support.unauthStuff).send(message.content)
        }
zenith terrace
#

cmd.conf?

earnest phoenix
#

yeah

zenith terrace
#

that doesnt help with the embed

#

the code

earnest phoenix
#

I didnt want to go into every command and define the ownerID, so i just made a simple var to let me do it

zenith terrace
#

You were talking about embeds..not this

#

this isnt an embed

earnest phoenix
#

I know, every time I try and do a multiple line embed it crashes my bot

#
.setAuthor('')
                .setColor(data.config.embed.color)
                .setFooter('')
                .setDescription(text);
knotty steeple
#

and then maybe post what error u get

earnest phoenix
#

when I try and start it, it pops up with "text is not defined"

small plume
#

post your full code?

#

cause nothing your showing would be crashing your bot

#

or show a valid error

knotty steeple
#

well probably because you didnt define text

#

lmao

earnest phoenix
#

wait, I see now, I had a problem with my actual commands

#

sorry for wasting y'alls time FacePalm

wispy bloom
#

Yes

#

I am so sorry man

north garnet
#

How to run the code i messed up

small plume
#

We dont know if you dont supply anything ¯_(ツ)_/¯

modest maple
#

read^^

true ravine
#

How do you mention roles in djs v12?

#

In v11 I just concatenated the role object with my message but now that isn't a thing

zenith terrace
#

I do the <@&ID>

#

In a message

amber fractal
#

Should work, using .toString() should still work as well

#

Could however be cache issues.

true ravine
#

Oh okay thanks guys

earnest phoenix
#

how often should the bots post server count/shard count to the API?

elder vine
#

You can post on ready event, and guildCreate event.

#

Or if you have a large bot with many joins you could post every 10 or 100 or even 1000 bot joins.

amber fractal
#

Or you could just post on the default 30 minute interval the libs provide mmulu

earnest phoenix
#

oh I was posting every hour

#

is 3 servers per minute probably too much for the guild ready event? lol

#

my bot kinda hit trending

modest maple
#

ah yes another corona bot

mystic violet
#

could anyone help me with an eval to log all the bots in my server? ive tried

console.log("started")
message.guild.members.cache.map(m => {
  if(m.user.bot) console.log(`Bot | ${m.id} ${m.user.tag}`)
})```
#

the eval doesnt even run

#

for some reason

amber fractal
#

Is your eval command setup correctly?

mystic violet
#

Yeah

#

it works

amber fractal
#

disregard that lol

mystic violet
#

the code doesnt

#

but the eval command does

amber fractal
#

It worked for me

mystic violet
#

weird

amber fractal
#

Well I changed some stuff for it to work with the version before cache

mystic violet
#

it worked

#

lol

slow elk
#

Anyone here who knows how to work with NodeJS on Ubuntu?

#

Please ping me if you reply, I have this server muted usually

amber fractal
#

I would recommend node version manager

knotty steeple
#

@slow elk search for nvm node

slow elk
#

That's the thing

#

We tried installing v13 on the system, and process.version keeps returning v10.16.3

We tried NVM, NPM and reinstalling it several times.,

knotty steeple
#

how exactly are u using nvm

#

you know you have to install the version then actually set it as the default

#

right

slow elk
#

No I didn't know that

#

We're trying something rn as suggestion from the discord.js community

knotty steeple
#

just use nvm

slow elk
#

We're gonna use that

ivory hare
#

@twilit rapids just a quick question, is it still required to send a physical certification application?
And if yes, is the noted address still the correct one?

modest maple
#

cert apps are closed

#

if you still want to apply it has to be physical

ionic anchor
#

Hey I dont understand how to make an app linked with my discord account like some bot's websites

knotty steeple
#

@ionic anchor learn oauth2

ionic anchor
#

Oh okay thanks

knotty steeple
#

shouldnt it just be * 500

#

+500?

pale vessel
#

maybe Math.floor(Math.random() * 500) + 500?

amber fractal
#

~~((Math.random() * (max - min) + 1) + min) is the formula for inclusive max and min generation (~~ is just shorthand for Math.floor() but it does some bitwise stuff and floor() is safer for very large numbers, but I've never had an issue)

north garnet
#

Can someone teach me how to make my bot online

regal saddle
#

What language you using?

amber fractal
#

With code

dusty onyx
#

they’ve been recommended a few pages but chose to ignore them

velvet ember
#

can you have multiple awaitReactions on a message? (discord.js)

zenith terrace
#

I believe just one

split hazel
#

How would I debug a NodeJS Heap Dump? I'm trying to see what's causing a memory leak. Also please don't send me a link to some forum that explains how, they don't and only really tell you how to notice you have a memory leak, or if you don't. For example, how would I see which objects/classes use the most memory? For example GuildMembers - 53M or something like that.

cinder patio
#

you can do that with the chrome dev tools

split hazel
#

I've tried that 50x

#

I don't know how to read memory

#

All i see is some nonsense text, that's it

cinder patio
#

I don't think there'll be an easier way

#

The numbers on the right are the bytes it takes up, though I am not sure what "shallow size" and "retained size" means

#

Though it's for java, still probably the same meaning

earnest phoenix
#

How do I take the args from a message and then put it in the bots message?

robust moth
split hazel
#

Thanks for the explanation @cinder patio i'll give it another go, knowing where to somewhat look mmLol

earnest phoenix
#

which version are you on, mr.who

robust moth
#

@earnest phoenix 12.1.1

earnest phoenix
#

the roles property in v12 is now this object https://discord.js.org/#/docs/main/stable/class/RoleManager

prime glacier
#

can someone tell me a thing

earnest phoenix
#

a thing

grizzled raven
#

where did the place you get your repo.git url go?

prime glacier
#

can i install Discord.js version11

grizzled raven
#

or am i just smartn't

#

nvm found it

hidden bone
#

I'm using python 3.8 and I'm trying to access my bot's voting page, but I don't understand how you're supposed to authorize it and it keeps on giving me 401 error

#

help?

elder vine
#

Yes @prime glacier

modest maple
#

@hidden bone what?

grizzled raven
#

if you want to clone a github repo, can you only clone the master?

elder vine
#

npm install discord.js@(version_name)

modest maple
#

@grizzled raven no you can clone other branches iirc

grizzled raven
#

but all the urls are the same

earnest phoenix
#

401 means wrong token, @hidden bone

grizzled raven
#

clone with url for both master and a branch are the same, so wouldnt it just clone master?

hidden bone
#

wait but it says unauthorized for me and I have the token, but i dont know how im supposed to authorize it

wide ridge
#

does each shard log in to its own instance of the dblapi? I would assume so, correct me if I'm wrong please!

#

so in my code, there's nothing I really need to change when sharding for dblapi is there (no need to do any extra checks?)

    const dbl = new DBL(topggtoken, { webhookPort: process.env.PORT, webhookAuth: process.env.WEBHOOKAUTH },  client);
modest maple
#

@hidden bone what is your code?

grizzled raven
#

nvm i can just change the default branch i guess

rapid surge
earnest phoenix
#

set the thumbnail url

rapid surge
#

thx

cinder patio
#

@grizzled raven clone the repo then do git checkout branchName

hidden bone
#

i don't know what im supposed to do with the authy

slender thistle
earnest phoenix
#

your token is supposed to go in the Authorization header

modest maple
#

yeah

#

dont use urlib

#

or requests

#

use aiohttp

hidden bone
#

then wht do i do?

modest maple
#

Aiohttp

#

also

#

why not use the dbl lib

slender thistle
#

aiohttp is asynchronous

modest maple
#

or shiv have u not added an ability to do that with the lib 👀

slender thistle
#

All possible functionality is there

modest maple
#

then use the py dbl lib

hidden bone
#

ok ill try that thks (:

prime glacier
#

@elder vine How to type version number

elder vine
#

like 11.0.0

prime glacier
#

ok

#

discord.js@11.0.0

charred cargo
#

anybody know any good Bot names

prime glacier
#

@charred cargo music?

charred cargo
#

No music commands

prime glacier
#

@charred cargo dm

charred cargo
#

ok

grizzled raven
#

@cinder patio i got it dont worry

copper cradle
#

I hate the name aiohttp, like, I hate pronouncing it

modest maple
#

why do you try to in the first place?

copper cradle
#

what

#

ah

#

bc idk

#

it looks out of place

#

and sounds out of place

grizzled raven
#

can you not set vars in switch blocks?

pale vessel
#

why not

grizzled raven
#

like

#
case 12: 
let hello = 3
break;

case 4:
let hello = 2
break;
#

apparently you cant do that?

copper cradle
#

wdym

#

they're in the switch scope

#

therefore you can't do that

earnest phoenix
#

you can

#

you just can't have the same name

tame shuttle
#

Can't you make a new scope in each case

earnest phoenix
#

because switch statements are different from ifs and instead they're pointers in memory the code jumps to

tame shuttle
#
case 12:
{
  let hello = 2;
  break;
}```
earnest phoenix
#

if you want to use the same variable name define it outside of the switch statement

#

that could probably work too

pale vessel
#

that does work

#

i do that

earnest phoenix
#

Is there a way for me to make a command that when someone votes on my bot he alerts in a specific chat?

pale vessel
#

it won't be a command

zenith terrace
#

That be an event

earnest phoenix
#

How craft this event?

zenith terrace
#

Idk

earnest phoenix
#

?

#

How do i get the canvas middle?

#

isnt that like

#

3rd grade maths

modest maple
#

@earnest phoenix its best not to think about it

earnest phoenix
#

lol

#

literally (a/2, b/2) and there's your middle point

wide ridge
#

How much memory is usually required when Sharding? I'm assuming resetting the shards once they fall below a certain memory amount is a sustainable solution? I have 8GB of RAM in my vps

earnest phoenix
#

and im supposed to know that?

#

@earnest phoenix

#

why would i know thats how u get that

#

yes

wide ridge
#

basic math?

#

lol

earnest phoenix
#

yeah ok i didnt know im supposed to use that on canvas

#

because that's what you learn in maths when you're 9

#

yeah ok i didnt know im supposed to use that on canvas
@earnest phoenix .

#

what else would it be

#

Again, idk

#

it's a rectangle

#

bruh

#

brain exercises

#

why would i know the canvas on discord.js would use that

wide ridge
#

api documentation

earnest phoenix
#

canvas isn't a part of djs

#

and any image is a rectangle

#

im using d.js

#

idc i never used it lmao

wide ridge
earnest phoenix
#

btw i tried that and it didnt work

quartz kindle
#

well, now you know. canvas is a graphics drawing api which uses coordinates to draw on a screen

#

so everything you want to draw on it, must be drawn using exact coordinates

wide ridge
#

Tim I have a question if you don't mind? Regarding sharding and dblapi

crimson vapor
#

Honestly, the way canvas does the drawings makes it hard to understand in my opinion

earnest phoenix
#
ctx.drawImage(avatar, 256, 256);  ``` ?
#

@crimson vapor THANK YOU

wide ridge
#

does dblapi automatically post server count from all shards onto your bot page on top.gg?

quartz kindle
#

all canvas objects, such as images and rectangles, start at the corner

crimson vapor
#

if you didnt take geometry or something similar, its harder to understand at least

earnest phoenix
quartz kindle
#

to center a rectangle inside another rectangle, you need to set the starting point to the canvas center, minus the size of the rectangle you're drawing

earnest phoenix
#
const canvas = Canvas.createCanvas(512, 512);```
#
ctx.drawImage(avatar, 256, 256);  
#

did i do it right? or is there anything else?

crimson vapor
#

well

earnest phoenix
#

cause it didnt work

quartz kindle
#

if the canvas size is 200x200 and you want to draw a 10x10 square in the center of it, you need to draw it at 95x95, so then the square will go from 95 to 105 width, and 95 to 105 height

crimson vapor
#

no

#

yeah tim is correct

#

well he always is though

earnest phoenix
#

wait but tell me the math again

#

what math do i need to do

crimson vapor
#

how big is the avatar?

earnest phoenix
#

my canvas is 512, 512

#

it fits trust

crimson vapor
#

no, I need the x by y

wide ridge
#

lollll

quartz kindle
#

x = canvas width / 2 - image width / 2
y = canvas height / 2 - image height / 2

earnest phoenix
#

i used snekfetch to get it

#

the displayavatarurl

#

its hard to get it

#

how do i know the image width and height ?

crimson vapor
#

displayavatarurl of what?

earnest phoenix
#

yes

#

i just want it to be in the middle

#

i dont know its hard

crimson vapor
#

yes doesnt answer my question

earnest phoenix
#

displayavatar

#

url

crimson vapor
#

so a user's avatar?

earnest phoenix
#

yes

crimson vapor
#

v11 or v12?

earnest phoenix
#

can i just load it in google and check or it wont be good ?
v11

crimson vapor
#

you should be able to do that yes

earnest phoenix
#

i couldnt load mine

#

the size parameter of the avatar url

#

540 540 i think

quartz kindle
#

ctx.drawImage allows you to resize the image before drawing

#

by adding two more parameters

earnest phoenix
#

the avatar is also guaranteed to be in the size of a power of 2 so you can scale in 1:1 freely

#

i dont get it its so weird

quartz kindle
#

if you do ctx.drawImage(image,50,50,200,200)

#

the image will be resized to 200x200 and drawn starting from coordinate 50x50 until 250x250

earnest phoenix
#

ok

#

i was told the middle is canvas / 2

#

mine is 512, 512

#

so its 256, 256

quartz kindle
#

yes

earnest phoenix
#

and its gonna be in the middle?

quartz kindle
#

256x256 is the center point. but images are drawn from the corner, not from the center

earnest phoenix
#

the image wont even be drawn anywhere

#

there is no picture

#

only background

quartz kindle
#

if you put the image at 256x256 and the image size is 100x100, then the image will be drawn from point 256 to point 356

#

so it wont be centered

#

the corner of the image will be at the center

earnest phoenix
#

is there a way to just make it in middle, no draw

quartz kindle
#

thats why you have to factor in the image size

earnest phoenix
#

is there a way to just make it in middle, no draw
?

#

so i just use 256,256

quartz kindle
#

i told you how

#

x = canvas width / 2 - image width / 2
y = canvas height / 2 - image height / 2

earnest phoenix
#

so if the image is 540, 540
and the canvas is 512, 512
x = 256 - 270 = -14 ?
y = 256 - 270 = -14 ?

#

how tho

quartz kindle
#

yes, that is correct

earnest phoenix
#

really?

quartz kindle
#

yes

#

the image is bigger than the canvas

#

so for it to be centered, it will start outside the canvas

earnest phoenix
#

so i just use -14 -14? thats it ?

quartz kindle
#

yes

earnest phoenix
#

its not centered

#
ctx.drawImage(avatar, -14, -14);```
#

did i do somthing wrong?

quartz kindle
#

then the image size is wrong

earnest phoenix
#

i cant get the avatar image size

#

do you know what size it is ? discord js v11

quartz kindle
#

then define your own size for it. as i told you, you can resize the image

earnest phoenix
#

so can i just do -14 -14 540 540

#

so image is 540x540

quartz kindle
#

sure

#

the image will be 14 pixels cropped all sides

earnest phoenix
#

still not centered

quartz kindle
#

show the result

earnest phoenix
#

can i send the link or the pic itself?

quartz kindle
#

the pic

earnest phoenix
#

lmao

#
ctx.drawImage(avatar, -14, -14, 540, 540);  ```
quartz kindle
#

you want to center the circle?

earnest phoenix
#

yes

#

under the rip

quartz kindle
#

the image looks centered

#

but you have something else cutting it

#

into a circle

#

so the circle cropping is in the wrong position, not the image

earnest phoenix
#

can i send my code?

quartz kindle
#

yes

earnest phoenix
#
if(command === "rip") {
  
    const canvas = Canvas.createCanvas(512, 512);
    const ctx = canvas.getContext('2d');

    const background = await Canvas.loadImage('https://cdn.discordapp.com/attachments/695319481609879585/695635311950037023/png-rip-5.png');
    ctx.drawImage(background, 0, 0, canvas.width, canvas.height);

    ctx.strokeStyle = '#74037b';
    ctx.strokeRect(0, 0, canvas.width, canvas.height);
  
    ctx.beginPath();
    ctx.arc(125, 125, 100, 0, Math.PI * 2, true);
    ctx.closePath();
    ctx.clip();

    const { body: buffer } = await snekfetch.get(message.author.displayAvatarURL);
  const avatar = await Canvas.loadImage(buffer);
    ctx.drawImage(avatar, -14, -14, 540, 540);  

    const attachment = new Discord.Attachment(canvas.toBuffer(), 'rip.png');

    message.channel.send(attachment);
}```
quartz kindle
#

ctx.arc(125, 125, 100, 0, Math.PI * 2, true);
ctx.closePath();
ctx.clip();

#

you're clipping at 125x125

#

with radius 100 pixels

earnest phoenix
#

idk whats that tbh

quartz kindle
#

clipping = cutting

earnest phoenix
#

ok so should i remove it

quartz kindle
#

that will remove the circle cut and show the full image

earnest phoenix
#

will it show it like i wanted tho ?

quartz kindle
#

how do you want to show it?

earnest phoenix
#

in the middle

quartz kindle
#

with the circle?

earnest phoenix
#

under the rip

#

the circle under rip in middle

quartz kindle
#

then move this to the middle

#

ctx.arc(125, 125, 100, 0, Math.PI * 2, true);

#

change 125 to center

#

256

earnest phoenix
#

oh

#

so 256 256 100 0

quartz kindle
#

yes

#

100 is the size of the circle

#

in case you want to resize it

earnest phoenix
#

and 256 256 tells where the middle is

#

correct?

quartz kindle
#

yes

earnest phoenix
#

look in dms

#

the result

quartz kindle
#

yes

earnest phoenix
#

i want it to show the picture

#

not that tiny

quartz kindle
#

you set the picture as 540x540

uneven egret
#

hello

earnest phoenix
#

is 1000 good ?

quartz kindle
#

thats even worse

#

will make it even bigger

earnest phoenix
#

so whats better?

uneven egret
#

how are you

earnest phoenix
#

oh i need less

quartz kindle
#

if your circle size is 100, that means the width is 200, 100 on each side

#

so if you set your image to 200x200, it will fit the circle perfectly

earnest phoenix
#

i used xy again but with 250

#

its perfect
i just need it under the rip

#
ctx.drawImage(avatar, 131, 131, 250, 250);```
#

send u the result

quartz kindle
#

first value is X (left/right) second value is Y (up/down)

#

if you increase the second value, it will go further down

#

you need to increase it in both the image and in the circle

earnest phoenix
#

sounds complicated

#
if(command === "rip") {
  
    const canvas = Canvas.createCanvas(512, 512);
    const ctx = canvas.getContext('2d');

    const background = await Canvas.loadImage('https://cdn.discordapp.com/attachments/695319481609879585/695635311950037023/png-rip-5.png');
    ctx.drawImage(background, 0, 0, canvas.width, canvas.height);

    ctx.strokeStyle = '#74037b';
    ctx.strokeRect(0, 0, canvas.width, canvas.height);
  
    ctx.beginPath();
    ctx.arc(256, 256, 100, 0, Math.PI * 2, true);
    ctx.closePath();
    ctx.clip();

    const { body: buffer } = await snekfetch.get(message.author.displayAvatarURL);
  const avatar = await Canvas.loadImage(buffer);
    ctx.drawImage(avatar, 131, 131, 250, 250);    

    const attachment = new Discord.Attachment(canvas.toBuffer(), 'rip.png');

    message.channel.send(attachment);
}```
quartz kindle
#

its just geometry lul

earnest phoenix
#

thats what i got until now

#

what do i need to change to make it go a little down

quartz kindle
#

increasing the second 131 will make the image go down. (but not the circle)
increasing the second 256 in ctx.arc will make the circle go down

earnest phoenix
#

so i need them both to increase same number

#

with the same number*

quartz kindle
#

yes

earnest phoenix
#

im going to try a ten

#

tysm

#

@quartz kindle

#

you helped me so much i understand now

#

you are so patient, appreicated

quartz kindle
#

👍

twin iron
#

first time i got this error, my script dont take over 250MB/300MB so i dont know i have it, someone already get it ?

crimson vapor
#

well what do you host on?

twin iron
#

it's been more over 1 year i am on it, never got problems

#

maybe it's the fault of my node version (10.X) ?

crimson vapor
#

how much ram do you get?

twin iron
#

3GB, and it's the only on script running

crimson vapor
#

not sure then

unique nimbus
#

I use Contabo

#

for hosting

#

8GB RAM
200GB Storage

twin iron
#

ah yeah i see the price thats good

abstract spruce
#

when you put your bot in top.gg what dose bot library mean?

sudden geyser
#

The wrapper for the Discord API you're using.

#

Not you, LeeBear.

slender wagon
#

${message.author.joinedAt} is there a way the bot can show the date when the user has joined

sudden geyser
#

Ergy call that on the guild member.

crimson vapor
#

"boot"?

abstract spruce
#

i used botghoust so what would that be

slender wagon
#

please do not spam at everyone

sudden geyser
#

A user doesn't have that property.

slender wagon
#

oh okay

sudden geyser
#

LeeBear botghost is not allowed on DBL.

twin iron
#

@slender wagon convert the timestamp to readable hour ( i think its timestamp, i dont remember ) ( https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=joinedAt )

crimson vapor
#

english only @earnest phoenix please

earnest phoenix
#

stop being annoying

crimson vapor
#

no need to ping more than one person

sudden geyser
#

I don't

pale vessel
#

oh my god he's pinging everyone

slender wagon
#

@twin iron thank you

crimson vapor
#

with what?

slender wagon
#

please stop spamming try to get your stuff together

crimson vapor
#

I do not understand what you need help with

slender wagon
#

he doesn't speak english properly

crimson vapor
#

ik

slender wagon
#

don't spam others in dm

knotty steeple
#

ur gonna have to wait for a long time for someone arabic then

crimson vapor
#

No

knotty steeple
#

its not racist lmao

twin iron
#

omg

slender wagon
#

;D

crimson vapor
#

arabic is just uncommon

knotty steeple
#

its just there arent much that speak it

twin iron
#

it's an english server pls try to respect that without call it racism

knotty steeple
#

^

pale vessel
#

there must be an Arabic discord bot server somewhere

crimson vapor
twin iron
#

omg stop this victimization

slender wagon
#

have fun

twin iron
knotty steeple
crimson vapor
twin iron
#

I know that the Arabs find it difficult to assimilate but try to make an effort @earnest phoenix

crimson vapor
twin iron
#

so make it 🥴

quartz kindle
#

a bot is not an easy thing to do, it requies programming

pale vessel
#

skills

quartz kindle
#

do you know any programming/coding language @earnest phoenix ?

slender wagon
#

and good english uwu most of the time

quartz kindle
#

you need to know programming to make a bot

pale vessel
#

cry he wouldn't understand

slender wagon
#

lmao yeah

earnest phoenix
#

lol

quartz kindle
#

if you dont know programming, you have to learn programming, go to a programming school

slender wagon
#

he can't copy and paste it

knotty steeple
#

programming school

#

yes

slender wagon
#

i'm in one uwu

pale vessel
#

never had one of those

quartz kindle
#

yes, im using primitive english

knotty steeple
#

<- self taught js stupid here

earnest phoenix
#

it's easier to translate and understand than programming course

pale vessel
#

same sammy

slender wagon
#

self taught is better sometimes

pale vessel
#

i feel more comfortable doing this

knotty steeple
slender wagon
#

guys the time has come

earnest phoenix
#

i used codecademy to start out with some langs then just went on with selfteaching

pale vessel
#

that's nice

crimson vapor
#

I just test shit and learn by it

crude bronze
#

anyone here code in python?

crimson vapor
#

what?

knotty steeple
#

hey when u mention someone dont delete it

#

makes it worse

#

or

#

more annoying

slender wagon
#

can i downgrade discord.js by just pushing the numbers down for example from v. 12 to 11.4.1

pale vessel
#

yes

slender wagon
#

alright ty

crimson vapor
#

you can remove it and npm i discord.js@11.4.1

pale vessel
#

noo

slender wagon
#

oh that works too?

copper cradle
#

just do npm remove discord.js
and then npm i discord.js@11.4.1

knotty steeple
#

i need d.jsvm

#

discord.js version manager

#

nvm but d.js

copper cradle
#

jvm

slender wagon
#

ohh okay

knotty steeple
#

no

pale vessel
#

bye

crude bronze
#

anyone here code in discord.py and know how to make it so your bot will only post nsfw content in nsfw channels?

slender wagon
#

cuz on glitch i just had to change the numbers then it showed me the tab discord.js update available which means it worked in there

crimson vapor
#

bro anything more random and ima ping a mod

knotty steeple
#

@crude bronze just use an if statement

pale vessel
#

yes, check if the channel is nsfw

#

everything should be in the docs

twin iron
#

@crude bronze you have to make a condition for check if the channel is nsfw

knotty steeple
#

i dont really know how python works so dont follow this exactly but you can just put an if for msg.channel.nsfw

crude bronze
#

i've looked and i don't know how i would use it

knotty steeple
#

except replace msg with that u use

#

if its like ctx or whatever idfk

twin iron
#

msg is the parameter

#

of your event

crude bronze
#

okay

earnest phoenix
#

So.. if your bot gets to the point of people running commands like constantly, what's the best way to update it without causing too many restarts/disruption to users using it?

knotty steeple
#

depends on what you have to do

crimson vapor
#

you have to restart at low usage and only restart when you must

knotty steeple
#

if its just add a command you can use a load command

#

to

#

..load commands

#

or whatever

earnest phoenix
#

keep the old instance running until the new updated instance is ready

#

Ohhhhhh

#

that's a good idea

#

when the new instance is ready, start accepting commands on it and kill the old instance

#

because I used a separate bot to make large updates on, test them with, and then when I know it's finished I upload it all to the main one

knotty steeple
#

only test on prod

earnest phoenix
#

what's "prod"

knotty steeple
#

production

crimson vapor
#

production I assume

wide ruin
earnest phoenix
#

yeah

knotty steeple
#

its supposed to do that

wide ruin
#

like why does it change?

twin iron
#

@wide ruin when you run it from google, a new token is generate every time

knotty steeple
#

the token made there is just based on time plus other stuff

twin iron
#

but if you do from discord app, it dont change

wide ruin
#

no the bot token

twin iron
#

wtf

wide ruin
#

not my auth one or whatever

knotty steeple
#

but the one you use isnt invalid unless u click regen

wide ruin
#

they all work

earnest phoenix
#

@earnest phoenix if it doesn't take too much of your time, can you quickly explain how I'd efficiently do that

twin iron
#

the first time i see that

knotty steeple
#

yea its supposed to be like that

#

unless u click regen they work

#

thats how its supposed to be

wide ruin
#

they should not change though

#

the bot one itself

earnest phoenix
#

check if there are any processes running with the same name, if there are it means an old instance exists.

don't start processing anything on your new instance until everything is ready (bot receives READY event, you're connected to a database etc etc)

once it's ready you can kill that old process and start accepting commands on your new one

knotty steeple
#

oh

#

smart

earnest phoenix
#

hm.

#

Alright I'll try it

clear wraith
#

Can someone help me figure out why my bot is offline?

#

I am trying to get it to come back online, but it's not working.

knotty steeple
#

cuz u didnt put it online /s

clear wraith
#

Any suggestions on what i should do?

crimson vapor
#

make sure you arent rate limited

#

make sure you arent getting errors

twin iron
#

check your mails too

clear wraith
crimson vapor
#

make sure you are using a token

#

is the bot responding?

clear wraith
#

No

twin iron
#

so is not online

#

do you have a ready event ?

crimson vapor
#

you need to run the bot

clear wraith
knotty steeple
#

are you actually logging in the bot

clear wraith
#

Logging the bot??

knotty steeple
#

logging

twin iron
#

no on your computer

knotty steeple
#

in

#

<Client>.login

#

bro

sudden geyser
#

@clear wraith that's just your ready event.

#

are you logging in with what sammy said (client.login)

clear wraith
#

I don't have a (client.login)

knotty steeple
#

put it in your main file

sudden geyser
#

yeah does anything get logged. we need to see your mail file with the token excluded

#

make sure the token you're passing is your actual token

clear wraith
knotty steeple
#

yes that

#

do u get an error

clear wraith
#

Yes

#

wait...

#

I need to put this in my readyfile?:

knotty steeple
#

no

#

do you

#

get any errors

clear wraith
#

let me check

sudden geyser
#

in your .env file, is there key for TOKEN2 and does it look like the bot token? Make sure it's not the client's secret token.

clear wraith
knotty steeple
#

what does your env file look like

#

dont actually show ur token

neon belfry
#

Hey what kinda hosting can I use? Any free bot hosting software/websites

sudden geyser
#

there are free sites, but it's recommended you get paid hosting

knotty steeple
#

glitch but ur not supposed to actually host stuff like bots on it

#

if you want a paid host check the pins

neon belfry
#

Nvm

#

Im too poor for that xD

knotty steeple
#

define poor

neon belfry
#

Ill just get my friend to do it he is helping me anyways

clear wraith
mossy vine
#

you can get a vps good enough for a basic bot for 2.5dollars per month

clear wraith
#

that is what is in my env fle

sudden geyser
#

replace TOKEN2 for TOKEN

mossy vine
#

you do realize that its TOKEN and not TOKEN2

knotty steeple
#

then why do you use TOKEN2

clear wraith
#

Can I remove TOKEN2 if im using TOKEN?

knotty steeple
#

yes

earnest phoenix
#

who did you copypaste this from

knotty steeple
#

lul

slender wagon
#

why would there be a 2 after the token ;D

gritty bolt
#

I'm trying to make a bot that DMs lists of people when classes are going to start. I am having some issues, here is the code.

const discord = require("discord.js");
const bot = new discord.Client();
var mod = null
var embed = new Discord.RichEmbed()
    .setDescription("Class Reminder")
    .setColor("#0000FF")
    .addField(mod, "texthere");
let coreUserList = [
    "",
    "",
    "",
    ""
]
function send() {
    
}
function core() {
    let date = new Date()
    if (date.getDay() === 1) {
        setInterval(monday, 60000)
        }
}
function monday() {
    let date = new Date()
    if (date.getHours() === 7 && date.getMinutes() === 40) {
        var mod = "Mod 1"
    coreUserList.forEach(send)
    }
}```
knotty steeple
#

well first of all

#

the send function is empty

#

second of all

#

coreUserList.forEach(send)

gritty bolt
#

thats what im trying to figure out

#

what to put in the function

#

to send a message to all the the ids that will be in the coreUserList

knotty steeple
#

also put a function in forEach

copper cradle
#

@clear wraith where did you copy that code from

knotty steeple
#

i => send(i)

#

where i would be the id

#

and in the send function just have it use that id to send

gritty bolt
#

how do I make i the id?

#

theres a list

knotty steeple
#

ur in the forEach function

#

so

gritty bolt
#

so this?

copper cradle
#

forEach(u => u.send())

gritty bolt
#
coreUserList.forEach(i => send(i))```
copper cradle
#

no

#

send is not defined

#

learn basic js

#

and then make a bot

knotty steeple
#

oH HeCk

#

i forgot

#

mmyes

gritty bolt
#

idk what to put in my send function though still

copper cradle
#

👏 learn 👏 basic 👏 js 👏

#

👏 then 👏 make 👏 a 👏 bot 👏

earnest phoenix
#

If you don't know what to put in a function you should reevaluate your knowledge of programming peepoWeird

gritty bolt
#

i dont think you get what i mean

grizzled raven
#

i dont think you get what your code means mmLol

gritty bolt
#

or im not communicating what i mean

grizzled raven
#

send isnt a function

gritty bolt
#

im making a function above it

grizzled raven
#

oh wait true

gritty bolt
#
function send() {
    
}```
#

its empty

#

for now

knotty steeple
#

whats the structure of a embed field

#

if u get what that means

gritty bolt
#

like a discord embed?

knotty steeple
#

yes

gritty bolt
#

oh are you looking

#

at my null value

#

for the first value of my field

lucid pasture
#

hey @gritty bolt what i would do to make it easier, is test to see if you can do a message reply that will @ everyone

knotty steeple
#

no im not

#

i just asked

#

but whatever

#

i found it

#
fields: [
{
    "name": "thing1",
    "value": "yeet"
},
{
    "name": "thing2",
    "value": "yeetus"
}
]
#

something like this works

gritty bolt
#

ok

#

@lucid pasture i can do that

#

i just literally have never tried using a single array before in js

lucid pasture
#

here let me give you a template

#

bot.on('message' , msg=>{
if(msg.content == 'whatever'){
msg.reply('whatever @ everyone');
}

})

gritty bolt
#

thats fine

lucid pasture
#

thats what i would use

#

and fill in the whatevers with the stuff you want to say

gritty bolt
#

the point of the arrays was to DM people when they have certain classes

#

otherwise i would've done that

lucid pasture
#

yes, but i think doing the @ everyone would be easier

gritty bolt
#

yeah it would

#

but i was trying to do something i hadn't before and it seems to be like

#

really not working

lucid pasture
#

if it shows no errors but its not working, try copy pasting the enire script, make a new file, paste it there, delete the old file, and then move the new file to the folder

gritty bolt
#

no i just dont know how to do it

lucid pasture
#

it should be pretty basic, do you know anything about programming or are you just starting

gritty bolt
#

i havent done it in a bit

#

so im really rusty

#

on anything new

#

im also being really stupid today so idk

#

also i just realized that i never started the bot

#

🤦‍♂️

jagged patio
#

hi i just wanna ask is there any markdown to add images in website description?

lucid pasture
#

is there what

jagged patio
#

markdown to add images on website bot description

lucid pasture
#

i would ask someone who is a admin or something

pale vessel
#

learn markdown

#

or use html

gritty bolt
#

does anyone have any resources that could help with what i was trying to do

#

send a message to each id in an array?

pale vessel
#

resolve the id to a user and send a message to them

gritty bolt
#

i have all the user ids

#

in the array

#

how do I send a message to each of them at the same time

pale vessel
#

they're just ids

#

you need to turn it to a user object

gritty bolt
#

how

pale vessel
#

are the users in the same guild?

gritty bolt
#

yes

pale vessel
#

then you can use guild member manager to find them

#

what version of discord.js are you on right now?

gritty bolt
#

the latest

pale vessel
#

that's good

#

you can check the docs

gritty bolt
#

i still dont get how do I preform an action though for each id

#

when i use the guild member manager how do I do it for each id

pale vessel
#

you use a loop

#

loop through the array of ids and resolve them to a user

#

you can use #fetch if the member isn't cached

gritty bolt
#

is there a link on mdn or somewhere else that could help?

pale vessel
#

otherwise #resolve would do (or get)

#

it's all in the docs

gritty bolt
#

ok

#

so I can use resolveID?

pale vessel
#

sure

#

use resolve instead

#

you already have the ids

gritty bolt
#

so what will that get me though

#

can I not just do id.send()?

pale vessel
#

a member object that you can send to

gritty bolt
#

or find them

pale vessel
#

that's not how it works

gritty bolt
#

can I use guild.member?

pale vessel
#

sure

#

I'm not sure if that works in v12

knotty steeple
#

how do ternary operators work again

#

condition ? true : false

#

is it this

pale vessel
#

yes

knotty steeple
#

cool

marble juniper
#

yes

pale vessel
#

that won't help you sbss

#

you don't have a user object

#

guild#member wouldn't work

pallid marsh
#

hey, is there a way to check if a user has a permission by the permissions int you get from the api

#

?

delicate zephyr
#

yes

sudden geyser
#

I'm making a message and reaction collector for my bot, and I'm wondering if it would be smarter to add a listener every time I create a new message collector, then remove it. Or, should I keep it all under one listener and add something like a monitor to check the message in the single message event?

pallid marsh
#

how?

pale vessel
#

docs

delicate zephyr
#

(permission_int & permission) == permission
for example
(permission_int & 8) == 8

#

bitfields are fun

pallid marsh
#

didnt get it

#

like

#

ye i see the docs

#

ill try

delicate zephyr
#

what lib

#

just curious

pallid marsh
#

no i look at the docs of discord

#

im building a dashboard

delicate zephyr
#

oh

#

yea

pallid marsh
#

0x00000020

delicate zephyr
#

have fun with bit fields

knotty steeple
#

how do i set the little image for the author

#

uh

pallid marsh
#

thats the value of lets say manage server

knotty steeple
#

whats it called

delicate zephyr
#

yea

pale vessel
#

displayAvatar

delicate zephyr
#

(permission_int & 0x20) == 0x20

pallid marsh
#

so how do i check if it has the perm by the int i get from discord's api

delicate zephyr
#

like that

#

it'll return a bool

pallid marsh
#

ok

#

ill try thx

clear wraith
#

From my brother....

knotty steeple
#

actually how do i get the client user

pale vessel
#

read docs

knotty steeple
#

is it just <Client>.user

pale vessel
#

yes

knotty steeple
#

o k

#

im being dumb then

marble juniper
#

read the docs

#

first

#

before asking

knotty steeple
#

i dont even have chrome open

marble juniper
#

it may be already answered there

compact tundra
#

i literally have no idea how to invite this bot to an server

delicate zephyr
#

scroll down

#

you'll see the permissions thing

#

select a permission

#

and it creates a invite link

compact tundra
#

there isn’t a down

gritty bolt
#
bot.on("ready", () => {
    let guild = bot.guilds.get("id")
     const coreClassList = [
        "", 
        "", 
        "" ,
        "",
        ""
    ];
coreClassList.forEach(guild.members.fetch(i))```
#

all the blank spaces and ids are actual ids

#

am i doing the last line correctly?

marble juniper
#

no

#

look at this

gritty bolt
#

thanks

pale vessel
#

for in is better or just traditional loop

earnest phoenix
knotty steeple
#

wym traditional

#

normal for function?

earnest phoenix
#

What is databass name

knotty steeple
#

vs js for(const thing in something) {}

#

@pale vessel

#

what code are u planning to copy paste @earnest phoenix

pale vessel
#

traditional = for (let i = 0...

knotty steeple
#

yes

#

hm

earnest phoenix
#

Python

pale vessel
#

it's faster

knotty steeple
#

dont know about those

#

i know for each is slower

#

but thats all

earnest phoenix
#

What's the max upload for a hot?

#

bot*

knotty steeple
#

probably just a user without nitro

earnest phoenix
#

damn

#

what's a good api for text uploads

pale vessel
#

funny how it could use custom emojis

earnest phoenix
#

like pastebin but no cost

#

🐒

pale vessel
#

hastebin

earnest phoenix
#

Free api uploads?

knotty steeple
#

hastebin

#

yea

#

forgot how tho

#

you can just post the text content somewhere

earnest phoenix
#

I need an api tho

#

that my bot can get to

#

Can you tell me what I am updating file name

#

@knotty steeple

knotty steeple
#

no i cant

earnest phoenix
#

Ok

knotty steeple
#

@earnest phoenix POST to http://hastebin.com/documents

#

it should work

earnest phoenix
#

Kk

#

I hate it to make an SQL Database for my Bot

#

and i hate peanut butter but it still exists

crimson vapor
#

just use mongo

digital canopy
#

hi guys

#

do you know why I get this error? (TypeError: msg.client.channels.get is not a function)

mossy vine
#

what library and version

digital canopy
#

pff

knotty steeple
#

cuz its not a function

mossy vine
#

sam

#

stop

knotty steeple
#

why dont u just do client.channels.get

#

or do u have to add cache

#

wew