#development

1 messages ยท Page 1444 of 1

gilded olive
#

like literally

#

the prefix is an empty ""?

earnest phoenix
#

So if you say "help" the bot will answer with their help message ?

gilded olive
#

idk about that my guy

carmine summit
#

you should atleast make a help command with a prefix

outer zenith
#

it has to be a default prefix

#

have*

#

even if u have custom

#

prefix

carmine summit
#

The bot is gonna get declined if there is no help command

outer zenith
#

help me?

carmine summit
#

No

#

just. no

gilded olive
#

yea nah thats gonna get declined

earnest phoenix
#

Yep

carmine summit
#

you wanna have a help command with a prefix

#

no

gilded olive
#

prefix with help.

#

because

#

if Anyone

#

ever says

#

"help me"

#

that will trigger the bot

#

not what you want, not what users want

carmine summit
#

if you do that the bot will start responding to someone who don;t need the bot's help

gilded olive
#

^

carmine summit
#

its annoying if you do that

gilded olive
#

bad.

#

that's a bad plan

carmine summit
#

bad plan

earnest phoenix
#

A really bad plan

carmine summit
#

imagine saying help me for a certain subject, then getting respond from a bot with the help page

#

its annoying af

earnest phoenix
#

Althougth the bot gets aproved that people who uses the bot gonna present reports about that feature (?

#

My english is not perfect sorry if there is any grammar issues

carmine summit
#

prefixes are made so that the bot will ignore the messages without a prefix, because it means that the message is not for the bot to process

gilded olive
#

your bot is really going to be listening to every message for "Help me"

#

dude come on

#

just put a prefix

#

that's bad

#

bad

#

bad

#

bad

#

no

carmine summit
#

FIRST OF ALL, YOU DON'T DO A COMMAND CASE-SENSITIVE

earnest phoenix
#

Ya

carmine summit
#

SECOND, YOU SHOULD ADD A PREFIX SO THE BOT WILL NOT RESPOND TO EVERY MESSAGE

sudden geyser
#

is your caps key stuck

gilded olive
#

if you want a chatbot

earnest phoenix
#

i believe

gilded olive
#

set a dedicated channel for that

#

config*

earnest phoenix
gilded olive
#

triggered

#

ok you know how clever only responds to people in a certain channel or any others

#

that is what you will want

carmine summit
#

fOR EXAMPLE I NEED HELP WITH A MATH PROBLEM. i AM GOING TO SAY hELP mE. tHE BOT WILL RESPOND AND THAT'S NOT WHAT i WANTED

gilded olive
#

ayo relax

carmine summit
#

tf?

earnest phoenix
#

Use a command for that chatbot, cause the bot will repond to every message

gilded olive
#

if its in a dedicated channel it can respond to every message

#

thats a simple check if the channel is not <id> return None

carmine summit
#

yes that can also work

earnest phoenix
#

or limit the bot's channels

carmine summit
#

limiting the bot to a certain channel

#

name

gilded olive
#

that sounds like still avoiding a prefix

earnest phoenix
#

Yep

carmine summit
#

if (message.channel.name.toLowerCase() !== "chatbot") return;

#

there

#

any channel that is not renamed to chatbot the bot will not respond

earnest phoenix
#

what about the ;

#

that return is going to return all below that line

carmine summit
#

ya happy now?

earnest phoenix
#

Yes

carmine summit
#

and also take note that if it is the next line

#

it wont go through

#

it needs to be the same line

#

for it to return

earnest phoenix
#

Oh ya

#

Sorry lol

carmine summit
#

Why it return false? Thonk ```
function checkDied(userId) {
let ins = games.find((g) => g.userId == userId);
console.log("Function: checkDied" + ins.userId);
let head = [...ins.game.snake[0]];
let body = [...ins.game.snake];
body.shift();
if (
body.some((a) => head.every((v, i) => v === a[i])) &&
ins.game.heading != "stop"
) {
console.log("Overlap");
let index = games.indexOf(ins);
games.splice(index, 1);
return true;
}
head.forEach((x) => {
if (x < defaultX && x > 0) return false
console.log("Border");
let index = games.indexOf(ins);
games.splice(index, 1);
return true;
});
return false;
}

```let checks = checkDied(123456);
console.log(checks);
earnest phoenix
#

@earnest phoenix edited invalid user

#

Xd

#

Lol

#

It should return true

#

Ah

carmine summit
#

smh the return false made it faster than the return true

earnest phoenix
#

If you told him to return false it gonna return false

#

Oh

trim saddle
#

why are there like 900 ways to say false in js

earnest phoenix
#

It's below the return true

#

So the final result is false

carmine summit
#

wot?

earnest phoenix
#

Oh wait

#
  • syntax error *
#

It should return true and not ahead to the return false

#

Wut

carmine summit
#

mi confused

earnest phoenix
#

Me too

#

Oof

carmine summit
#

@earnest phoenix

#

I summon you

earnest phoenix
#

you summon me

carmine summit
earnest phoenix
#

I mean it should return and not execute that return false;

carmine summit
#

you help me

earnest phoenix
#

@carmine summit what is it supposed to be

carmine summit
#

its supposed to return true

#

but instead it returned false

earnest phoenix
#

then the condition in the if statement returned false so it didn't execute and return true

hollow sedge
carmine summit
earnest phoenix
#

is that an arrow function inside a single statement arrow function i see

carmine summit
#

wdym?

earnest phoenix
#

try running the condition inside the if statement

#

and tell me what it outputs

carmine summit
#

huh?

earnest phoenix
#

What time is it in America?

carmine summit
#

@earnest phoenix Border

earnest phoenix
#

Ask google for the america's time

carmine summit
#

thats what it outputs

earnest phoenix
#

@gilded plank

#

@carmine summit i meant the stuff inside the parenthesis of the if statement not the curly brackets

sudden geyser
gilded olive
#

damn im 1 hour ahead of you

earnest phoenix
#

It's 03:14 AM here.

gilded olive
earnest phoenix
gilded olive
#

why not

earnest phoenix
#

Damn I'm 10:45 hours ahead of you @sudden geyser

sudden geyser
#

sometimes you want to program yet there's not enough time in the day

#

days should be x2 longer

gilded olive
#

ah yes

#

could finish these tutorials 2x quicker

sudden geyser
#

speed ๐Ÿง 

earnest phoenix
sudden geyser
#

it also means we get to spend twice as much time in this cursed year

earnest phoenix
earnest phoenix
#

Oh

earnest phoenix
gilded olive
#

once i submit the assignments im good to go

#

i went to one once, and the whole time the teahcer was just explaining what would be a on a google forms

#

like google exists

earnest phoenix
#

Lol

sudden geyser
#

over here we show up every other day from 8 to 12 (sometimes 11)

#

then continue from 1 to 3 at home

carmine summit
#
function checkDied(userId) {
  let ins = games.find((g) => g.userId == userId);
  console.log("Function: checkDied" + ins.userId);
  let head = [...ins.game.snake[0]];
  let body = [...ins.game.snake];
  body.shift();
  if (
    body.some((a) => head.every((v, i) => v === a[i])) &&
    ins.game.heading != "stop"
  ) {
    console.log("Overlap");
    let index = games.indexOf(ins);
    games.splice(index, 1);
    return true;
  }
  head.forEach((x) => {
    if (x < defaultX && x > 0) return;
    console.log("Border");
    let index = games.indexOf(ins);
    games.splice(index, 1);
    return true;
  });
  return false;
  console.log(ins.userId);
}
```updated it but it still returns false
earnest phoenix
#

Did you try "else" after that if?

#

head.forEach takes a function that is getting ended by the return keyword

#

the parent function is not ended

earnest phoenix
carmine summit
#

um

#

so I store head.forEach()

#

using let

#

and then if it is true

#

return true

#

im a genius

#

wait no I don't get it

pure lion
#

Someone need help?

carmine summit
#

@earnest phoenix help

pure lion
#

Oh good let me explain

#

@carmine summit what do you need an explanation of

carmine summit
#

why it returns false instead of true

pure lion
#

In the codeblock above?

carmine summit
pure lion
#

@carmine summit 123456 is invalid as a user ID, it's usually a string and a user ID assuming that's what g.userId's comparing to

carmine summit
#

no

#

I use it as reference

pure lion
#

Well that's why it's returning false

carmine summit
#

No I mean

#

I'm using it as for reference

#

in the actual code its userId

pure lion
#

Then use a real game and show me what happens when you die

carmine summit
#

not a string of number that is hardcoded

pure lion
#

Yes I know

carmine summit
#

an error pops

pure lion
#

Show

carmine summit
#

generateGui is the next function

pure lion
#

ins is a user ID

carmine summit
#

after the checkDied

pure lion
#

Ah nvm

#

Maybe it can't find the game the user ID is a part of

#

Console log ins

carmine summit
#

and the object is deleted

#

the object is deleted

#
    games.splice(index, 1);```
pure lion
#

At let ins, console log ins

carmine summit
#

ins is undefined

#

because i deleted it

#

when it hit the border

pure lion
#

Also you can just do delete games.indexOf(ins);

carmine summit
#

o k

#

and ins is an object yes

#

inside an array

#

which is games

pure lion
carmine summit
#
[
  {
    userId: '487511010886942720',
    messageId: '786844287794413588',
    channelId: '780708958829936663',
    pause: false,
    game: { heading: 'left', snakeLength: 5, food: [Array], snake: [Array] },
    map: [
       "map."
    ]
  }
]
pure lion
#

ins[0].userId

#

Also why use an array and not a map?

carmine summit
#

because

  1. Yes
  2. I don't know how those work
pure lion
#

It's simple

#

But you have working code so that's fine

carmine summit
#

yeahhhhhhhhh

#

So.. Any idea why is it returning false?

pure lion
#

Did it work?

carmine summit
#

wdym did it work?

pure lion
carmine summit
#

no

#

because ins is not an array

#

ins is an object

pure lion
#

It is

carmine summit
#

games is an array

pure lion
#

Boomer

carmine summit
#

games is an array.

pure lion
#

As you can see, it's an array

carmine summit
#

what you saw is not ins

#

I sent the wrong

#

What you saw is games

pure lion
#

Then send me ins

carmine summit
#

this is ins

pure lion
#

then there should be no issue

carmine summit
#

there is

#

wait lemme show you

pure lion
#

console log Object.keys(ins)

carmine summit
#
function checkDied(userId) {
  let ins = games.find((g) => g.userId == userId);
  console.log("Function: checkDied" + ins.userId);
  let head = [...ins.game.snake[0]];
  let body = [...ins.game.snake];
  body.shift();
  if (
    body.some((a) => head.every((v, i) => v === a[i])) &&
    ins.game.heading != "stop"
  ) {
    console.log("Overlap");
    let index = games.indexOf(ins);
    games.splice(index, 1);
    return true;
  }
  head.forEach((x) => {
    if (x < defaultX && x > 0) return false;
    console.log("Border");
    let index = games.indexOf(ins);
    games.splice(index, 1);
    return true;
  });
  return false;
}
    let checks = checkDied(ins.userId);
    console.log(checks);
    if (checks) return console.log("Died");
pure lion
#

Ah

#

@carmine summit did you do the Object.keys thing?

carmine summit
#

yes

pure lion
#

And it logged?

carmine summit
#

yes

pure lion
#

Show

carmine summit
#

["userId", "channeId", "messageId", "pause", "game", "map"]

pure lion
#

Ok so the user ID is passing

#

Autjsifhs

pale vessel
#

what is the problem

pure lion
#

Idiocy most probably

carmine summit
#

returning false instead of true

pure lion
#

It should return true

carmine summit
#

it should...

#

but why is it not returning true?

#

I need a rest

pure lion
#

Maybe your overlap logic is wrong

earnest phoenix
#

hey

carmine summit
#

hey

#

I still need your help

earnest phoenix
#

bye

#

buzy

#

hey someone knows how to turn it back to on?..

#

make a support ticket

obtuse jolt
#

Does anybody know what this error could be caused by other than the connection being refused

#

It just randomly started happening recently

fallow lichen
#

I would like to make everything typed after the command to be only 1 string and split it by myself, is that possible (python)? Or do someone have an easy way to get c=gol um n>=10 into a first argument that would be c=gol um and another one that would be n>=10

carmine summit
#

@earnest phoenix

ionic ermine
#

Is it a prohibited command to delete all channels on the server and quickly create new channels in their place?

knotty obsidian
#

Why can't I use ContextException?

#
Error:(68, 23) java: exception net.dv8tion.jda.api.exceptions.ContextException is never thrown in body of corresponding try statement
try {
  event.getGuild().unban(event.getMessage().getContentRaw().substring(8)).queue();
} catch(ContextException e) { //This line gives me the error
  return;
}

java

And how do I check if the ban is valid...

earnest phoenix
#

@obtuse jolt That happens if you pass anything other than a function to the second parameter on binding an event

#

how can i add emoji in my bot command

sacred palm
earnest phoenix
sacred palm
earnest phoenix
#

escape it

#

with a backslash

sacred palm
#

post emoji., right click, copy link, paste it and copy numeric id before .gif / .png

earnest phoenix
#

or... escape it

sacred palm
#

what that means ?

earnest phoenix
#

dbl -> \:dbl: -> !dbl

#

this also works for unicode

sacred palm
#

ah

#

i understand

#

nice

earnest phoenix
#

@gilded olive hey yo Iโ€™m starting to learn to code...

delicate shore
#

I want user to. provide a api key

#

for eg
const s = require('s')
const api = new s.api("")

earnest phoenix
#

Uhh, then require it?

tight plinth
#

if i wanna add multiple roles to a user, do i have to parse an array of role ids in the member.roles.add function? just wanna make sure

earnest phoenix
#
class API {
constructor(key) {
if (key === null || typeof key === "undefined") throw new TypeError("An API key is required.");
this._key = key;
}

// Whatever here
}

module.exports = {
api: API
};```
earnest phoenix
tight plinth
#

ok

#

second question: i have an aray with roles id, and i wanna remove the IDs that are not role IDs. I tried this, but it doesn't work. I forgot how to work with forEach sad

earnest phoenix
#

Need to update bot to v12?

tight plinth
#

yes

earnest phoenix
tight plinth
#

mk

#

that worked, thanks ^^

carmine summit
#

@earnest phoenix help

earnest phoenix
#

i told you already to make a support ticket

#

i did

#

so... wait

#

but they doesnt help

earnest phoenix
#

5 days?

#

however long it takes

#

be patient

#

ok thank u

#

help me

#

i dont know what problem i am doing

#

what u trying to do?

#

in this website

#

my text is automatticaly under lined

#

pls inspect and check what i am doing wrong

#

set the text decoration to none

#

@earnest phoenix will it remove font style too ?

#

i do ctrl u

earnest phoenix
#

I dont want to remove font style..

#

<input type="checkbox" id="click">

#

try remove that

#

huh

slender thistle
#

You're using Glitch so I don't see how you can't just edit it and try

earnest phoenix
#

s

#

it's underlined because it's an anchor element

#

setting text decoration to none removes default text decoration

earnest phoenix
#

ok

earnest phoenix
#

but where did i ask

#

you have translators if you don't understand english

#

@earnest phoenix i set it to none still its ul

#

did you set it on your anchor element or on your div

#

i know just basics about html and css

#

ok?

#

can u pls visit and inspect what i am doing wrong

#

i told you what you need to do

#

i did that

#

well you didn't if it doesn't work

#

inspect n see

#

no

tawdry knot
#

Where can i test my bor here?

earnest phoenix
#

you can't

tawdry knot
#

Ok

earnest phoenix
#

@earnest phoenix pls help

#

๐Ÿ˜ฆ

#

i told you what you need to do

#

i did that

#

i told you

#

lol

#

but you dont trust me

#

you didn't do it if it doesn't work

#

otherwise if you did it properly, it would work

#

text-decoration: none;

#

that's not set on an anchor element

#

that's a nav element

#

...okay?

slender thistle
#

Hey, fuck you Python!

earnest phoenix
#

that css is still not being applied to an anchor element, your element nesting does not matter

#

Yes fuck you python

slender thistle
#
  File "sorting_algorithms.py", line 20, in shell_sort
    for i in range(gap, n):
TypeError: 'float' object cannot be interpreted as an integer
    n = len(arr)
    gap = int(n / 2)
    while gap > 0:
        for i in range(gap, n):
earnest phoenix
#

if you don't understand what an anchor element is, in just 680 milliseconds you get 269 million results about it

drifting wedge
#

whats this error? discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientOSError: [Errno 32] Broken pipe py

cinder patio
#

there are problems with the plumbing

pale vessel
#

get a plumber to fix the broken pipes

slender thistle
#

Python is a fucking joke

#
    n = int(len(arr))
    gap = int(n / 2)
    while gap > 0:
        for i in range(gap, n):
    n = len(arr)
    gap = n / 2
    while gap > 0:
        for i in range(int(gap), int(n)):
#

What's the damn difference here

#

why does one work and the other doesn't KEKW

#

Oh dear lord

earnest phoenix
#

float vs int

#

division returns a float ig

slender thistle
#

Nah, the cause was gap /= 2 at the end of the loop which turned gap into float

earnest phoenix
#

oh

#

lol

slender thistle
#
[78, 70, 19, 50, 35, 96, 87, 55, 81, 78]

that looks very sorted

harsh lake
#

Hello! I am very new to discord.js

In VSC,how can we rename a file?

I mean, it shows untitled 1

I wanna rename it to index.js

#

HLP

lusty quest
#

right click the file and then choose rename

earnest phoenix
#

.addField(`Users`, `${users}`, true)

#

Not accurate

#

My bot have 45k users but is showing only 72

#

they're not in cache

#

What

#

what what

#

But this work

#

Past

#

i know it works

quartz kindle
#

discord changed it

earnest phoenix
#

Why today is not work

earnest phoenix
#

What is solution wtw

quartz kindle
#

anyway those 45k users were not all of your users

#

only onlines

earnest phoenix
#

This showing online users?

quartz kindle
#

before the change:
client.users.cache -> online users

after the change:
client.users.cache -> only voice channel users

after the change with "presences" enabled in your dev portal:
client.users.cache -> online users

earnest phoenix
#

``` console.log(Ready on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users);

#

Same here showing wrong users

quartz kindle
#

before and after the change:
guild.memberCount -> ALL members, including offlines

earnest phoenix
#

{client.guilds.memberCount}

#

Right?

quartz kindle
#

no

earnest phoenix
#

size*

quartz kindle
#

client.guilds.cache.reduce((total, guild) => total + guild.memberCount, 0)

earnest phoenix
#

Including this $

#

?

#

${client.guilds.cache.reduce((a, b) => a + b.memberCount, 0).toLocaleString()}

#

Try this

crimson vapor
#

Hello Tim

earnest phoenix
#

๐Ÿ‘

carmine summit
#

@quartz kindle

quartz kindle
#

the returns inside the forEach are not doing anything

#

they return the x => {} function

#

not the outer function

quaint peak
#

how would i made a print command in py?

#

like

#

.print("hi")

#

then it would send hi

crimson vapor
#

like print to console

#

pring(String) iirc

gilded olive
#

print a command?

#

on_command_completion @quaint peak

crimson vapor
#

oh

#

like a !say?

gilded olive
#

well then it'd have to take an arg acceping a string

#
@bot.command()
async def say(ctx, msg: str = None):
  await ctx.message.delete()
  await ctx.send(msg)```
#

that's it

slender thistle
#

Why would you use a default value here

crimson vapor
#

@quartz kindle should I use writeFile() with a callback or writeFileSync()?

earnest phoenix
crimson vapor
#

thats a scroll bar

#

just make the site longer

pale vessel
#

LOL

#

what kind of question is that

earnest phoenix
#

@crimson vapor i am making it longer but when height of device changes, text start to hide behind nav bar

#

you didnt structure your website correctly then

crimson vapor
#

idk that much about css but I think you use margin-bottom

earnest phoenix
#

@earnest phoenix i already told you i am begginer in css and html

#

ok

pale vessel
#

i love this thing

earnest phoenix
#

um

crimson vapor
#

what the fuck is that

pale vessel
#

browserling

crimson vapor
#

for my use case?

earnest phoenix
pale vessel
#

if you have a code that you want to run while it's writing, use writeFile()

quartz kindle
#

using writeFile will let your code continue to run while the file is writing, but it wont allow you to write to the same file at the same time, so you have to manage that possibility

#

using writeFileSync will stop your entire process until its done writing

sacred palm
#

hi... can anyone please help me integrate those 2 webhook edit and create with a fetch ?

webhook.edit({
    name: 'Some-username',
    avatar: 'https://i.imgur.com/wSTFkRM.png',
    channel: '222197033908436994',
})
    .then(webhook => console.log(`Edited webhook ${webhook}`))
    .catch(console.error);

channel.createWebhook('Some-username', {
    avatar: 'https://i.imgur.com/wSTFkRM.png',
})
    .then(webhook => console.log(`Created webhook ${webhook}`))
    .catch(console.error);

quartz kindle
#

wut

crimson vapor
#
      fs.writeFile(this._tmpFilePath, data, (err) => {
        if (err) throw 'An error occured when writing to the DB:\n' + err;
        fs.renameSync(this._tmpFilePath, this._path);
      });``` this should work fine right
#

is there any way for me to run code at the same time?

pale vessel
#

hmmm mixing sync

crimson vapor
#

bruh

#

fine ill change

#

I can use sync on the constructor tho

#

because no reason to not

earnest phoenix
#

i use position tag and now everything is ok KEKW

hasty mulch
#

Is there a way to do a line break in Discord?

earnest phoenix
#

newline character

#

use the literal, \n

hasty mulch
earnest phoenix
#

depends in which section of the embed

hasty mulch
#

Field values

earnest phoenix
#

yup, it'll work

hasty mulch
#

Kk

earnest phoenix
#

i am doing something wrong ? <div href="/"; class="logo">

#

href isnt working

drifting wedge
#

what can i use for graphs?

pale vessel
#

what the fuck

drifting wedge
#

what are u trying to do?

earnest phoenix
#

divs can't have hrefs

#

and that's also invalid html

pale vessel
#

remove that semicolon

#

and change it to anchor tag

#

and close the tag

earnest phoenix
#

hey

#

I'm making an emote manager bot idk why

gilded olive
#

not hard

earnest phoenix
#

image is not interpreted as setImage. what should I do.

#
(node:7748) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
embed.image.url: Could not interpret "{'type': 'Buffer', 'data': [137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 3, 232, 0, 0, 0, 200, 8, 6, 0, 0, 0, 123, 231, 203, 79, 0, 0, 0, 6, 98, 75, 71, 68, 0, 255, 0, 255, 0, 255, 160, 189, 167, 147, 0, 0, 32, 0, 73, 68, 65, 84, 120, 156, 236, 157, 117, 116, 20, 215, 251, 184, 159, 221, 200, 198, 221, 221, 61, 193, 157, 64, 113, 43, 208, 226, 214, 22, 40, 214, 210......
earnest phoenix
#
getPalette(kullanฤฑcฤฑ.user.displayAvatarURL({
    dynamic: false,
    size: 1024,
    format: 'png'
})).then((palette) => {
    const embed = new MessageEmbed()
        .setColor(autimatic)
        .setAuthor('Palette', bot.user.displayAvatarURL({
            dynamic: true,
            format: 'png',
            size: 512
        }))
        .setImage(palette)
        .setTimestamp()
        .setFooter(`${message.author.tag} | ยฉ ${bot.user.username}`, message.author.avatarURL({
            dynamic: true
        }))
    message.channel.send(embed)
});
earnest phoenix
earnest phoenix
#

not that im aware of

summer torrent
#

@earnest phoenix what is palette

earnest phoenix
#

@earnest phoenix that's JSON not a Buffer or URL

earnest phoenix
#
async function getPalette(kisi) {
    let rgbParams = await ColorThief.getPalette(kullanฤฑcฤฑ.user.displayAvatarURL({
        dynamic: false,
        size: 1024,
        format: 'png'
    }), 10);
    let ColorCanvasConstruct = canvas.createCanvas(100 * rgbParams.length, 200);
    let ctx = ColorCanvasConstruct.getContext("2d");

    function hexComponent(H) {
        let hex = H.toString(16);
        return hex.length === 1 ? "0" + hex : hex;
    }

    function rgbHexComponent(r, g, b) {
        return "#" + hexComponent(r) + hexComponent(g) + hexComponent(b);
    }

    ctx.font = "20px NotoSans-Regular";
    let goFurther = 0;
    for (let i = 0; i < rgbParams.length; i++) {
        ctx.fillStyle = rgbHexComponent(rgbParams[i][0], rgbParams[i][1], rgbParams[i][2]);
        ctx.fillRect(goFurther, 0, 100, 200);
        let saveStyle = ctx.fillStyle;
        if (tinycolor(rgbHexComponent(rgbParams[i][0], rgbParams[i][1], rgbParams[i][2])).isDark() === true) {
            ctx.fillStyle = "white";
        } else {
            ctx.fillStyle = "black";
        }
        ctx.textAlign = "center";
        ctx.fillText(saveStyle, goFurther + 50, 30, 100, 30);
        goFurther += 100;
    }

    return ctx.canvas.toBuffer();
}
summer torrent
earnest phoenix
#

@earnest phoenix you need to add the image as a message attachment then use the attachment URL in setImage

#
getPalette(kullanฤฑcฤฑ.user.displayAvatarURL({
    dynamic: false,
    size: 1024,
    format: 'png'
})).then(palette => message.channel.send({
    files: [{
        attachment: palette,
        name: "dosya.png"
    }]
}));
#

?

#

saw this on the guide:

#
const file = new Discord.MessageAttachment('../assets/discordjs.png');

const exampleEmbed = {
    title: 'Some title',
    image: {
        url: 'attachment://discordjs.png',
    },
};

channel.send({ files: [file], embed: exampleEmbed });
earnest phoenix
crimson vapor
#

one two three
try it and see

earnest phoenix
crimson vapor
#
throw "one two three"```
earnest phoenix
#

thx thx

crimson vapor
#

doesn't work

earnest phoenix
#

@earnest phoenix

crimson vapor
#

I think I did something wrong

#

keep getting error: one two three

earnest phoenix
crimson vapor
#

lol

earnest phoenix
#

how do you set the footer text for an Embed object in discord.js

#

this is my embed as of now:

#
embed: {
                title: cmd.name,
                description: cmd.description,
                fields: [
                    {
                        name: "Args",
                        value: cmd.args.replace(/</g, "**<").replace(/>/g, ">**")
                    },
                    {
                        name: "Aliases",
                        value: cmd.aliases || "None"
                    }
                ]
            }
#

please forgive the absolutely horrible spacing it's discord's fault

sudden geyser
earnest phoenix
#

thanks

carmine summit
#

@earnest phoenix You still owe me an explaination

earnest phoenix
#

no i dont

carmine summit
#

How do I fix it?

carmine summit
carmine summit
quartz kindle
#

you dont

#

not with a forEach

earnest phoenix
#

what is the difference between module.exports and exports?
my command handler works with module.exports but not with exports smh

dreamy gulch
#

@earnest phoenix because commando uses Commonjs

earnest phoenix
#

why do people use forEach in the first place

#

it's so slow and it brings more cons than pros

quartz kindle
carmine summit
#

So what's the best solution to this?

earnest phoenix
carmine summit
#

for()?

earnest phoenix
#
for (let filename of fs.readdirSync("./commands")) {
    let data = require(`./commands/${filename}`);
    bot.commands.set(data.name, data);
    console.log(data);
}
dreamy gulch
#

ok so you use Common js also

earnest phoenix
#

my command files:

module.exports = {
    name: "",
    description: "",
    args: "",
    devOnly: false,
    aliases: null
    async execute(bot, message, args, command) {
        
    }
}
dreamy gulch
#

not ES modules

quartz kindle
#

its the same as doing this ```js
let me = {} // module.exports
let e = me // exports

e = "abc" // e becomes abc, me is still {}

earnest phoenix
#

?

quartz kindle
#

but if you do exports.something = something, then it will work

carmine summit
quartz kindle
#

yes

earnest phoenix
#

so you can't set exports to be object directly but you can set individual properties for it

quartz kindle
#

yes because its a reference

earnest phoenix
#

oh

quartz kindle
#

the actual value that is exported is module.exports

#

exports is a reference to it

earnest phoenix
#

ok

quartz kindle
#

so if you add properties to exports, they will be reflected in module.exports as well

#

but if you assign a value to exports, you are replacing the reference with a different value without affecting module.exports

earnest phoenix
#

thank you timmy

carmine summit
#

Timmy should really get a custom role

#

I have the answer to my problem I've been dealing with 8hours ago just right under my nose.

drifting wedge
#

yo @green kestrel im making graphs for my bot, can u send me a pic of yours so i can compare?

earnest phoenix
#

do i need to add class to anchor tag to use css ?

#

@earnest phoenix ^

#

yes

#

anything that you want to style with css needs to have an id / class / style attribute

#

ok

#

style should be avoided though it makes your code look like garbage

green kestrel
#

feel free to poach html

drifting wedge
#

nah

#

just style

green kestrel
#

btw you know the easter egg is on that page too

earnest phoenix
#

@earnest phoenix did i am doing something wrong ?
HTML - <a class="lo" href="/"><div class="logo"> <%- title %> </div></a>
CSS - nav lo .logo{ color: white; font-size: 35px; font-weight: 600; }

drifting wedge
#

or 3 mb?

green kestrel
#

3.5 gigs

earnest phoenix
#

gigs

drifting wedge
#

o ok lmao

green kestrel
#

split between 8 processes of about 450mb each

drifting wedge
#

how did u split the proccesses?

earnest phoenix
#

why do you guys hate inline styles so much
what if i want to set a specific style for one element only

and ID would be pointless for that

green kestrel
#

sure

drifting wedge
#

i can

#

ive been doing a lot of front end too

green kestrel
#

@earnest phoenix thats a valid use for an inline style tbh

drifting wedge
#

so feel free to ping me if u need help

earnest phoenix
#

@earnest phoenix where to put dot ?

#

take a guess

green kestrel
#

it can be hard to see what has priority with inline styles though

earnest phoenix
#

@earnest phoenix there maybe nav .lo .logo{

#

yup

#

oh

#

lemme see

green kestrel
#

@earnest phoenix this is wrong: nav lo .logo{ you want: a.lo div.logo {

earnest phoenix
#

huh

green kestrel
#

.lo .logo is also valid, but not as specific

drifting wedge
#

@green kestrel from something we talked a bit ago, would you say programming is a like good job?

green kestrel
#

i didnt see that its in a <nav> element though

drifting wedge
#

like progeramming related?

earnest phoenix
#

follow proper async/await pattern

green kestrel
#

@drifting wedge shift-F5, and then do the konami code on that graph page

earnest phoenix
#

when i add href to anchor tag underline appears why ???

feral aspen
#

I have a question as I am new to MongoDB. If I want to create a new way into storing data, do I just make a whole other type of model with a different name?

earnest phoenix
green kestrel
#

and yes, programming as a job is fun for me

#

and it pays ok

feral aspen
earnest phoenix
#

can you do Collection[int] to get specific elements from a Collection by using their IDs or do I have to turn it to an array first

drifting wedge
#

how did u do stats page?

#

is it live?

drifting wedge
#

honestly programming is like top 5

hollow sedge
green kestrel
#

the max is 800

earnest phoenix
green kestrel
#

100 .... per cpu core

hollow sedge
#

ohh

earnest phoenix
#

that's setting on the logo

#

not on the anchor

green kestrel
#

its using 17 atm

#

which tbh is still high, the usual is 1% per cluster

drifting wedge
#

uhhhh @green kestrel u got an issue

quartz kindle
#

lmao

drifting wedge
#

i did my hackerman stuff

green kestrel
#

youve photoshopped that, im looking at it right now kek

green kestrel
#

edit element?

drifting wedge
#

i did ctrl shift i

#

and then edited it

hollow sedge
#

thats a realy cool page though

drifting wedge
#

and now its melting the server

earnest phoenix
#

@earnest phoenix so.. what about this ? a { text-decoration: none; }

hollow sedge
#

theres a ton of info there

drifting wedge
#

because inspect element is serverside definitely

earnest phoenix
#

ok lemme se

#

and is the correct approach

quartz kindle
#

Brain does your bot really need to cache users and shit?

pale vessel
#

client side

drifting wedge
solemn elk
#

Code :

    @commands.command()
    async def ticket(self, ctx):
        name = f"ticket-{ctx.author.discriminator}"
        guild = ctx.message.guild
        await guild.create_text_channel(f'#{name}')
        channel = self.client.get_channel(name)

        await ctx.send(channel.id)

Error :

Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'
green kestrel
#

@drifting wedge sometimes that can climb up to 800%... it doesnt affect the bot performance

#

theres a library bug, which makes the library threads spin on reconnect to a shard

green kestrel
#

so it basically 'uses up the idle cpu time' with a busy loop

solemn elk
#

no not the channel the command was executed in

earnest phoenix
#

@earnest phoenix ah tysm.. its working

solemn elk
#

the channel that got created

green kestrel
#

restarting the cluster clears the stuck thread

drifting wedge
green kestrel
#

but i dont do that unless theres some other reason

drifting wedge
#

i think

#

maybe u can with name

green kestrel
#

as i dont like to disrupt peoples games

drifting wedge
#

u can

#

name u can

solemn elk
#

hmm

drifting wedge
hollow sedge
green kestrel
#

about 8 mins, but i dont ever do a full reboot unless i change the shard or cluster count

drifting wedge
#

@green kestrel u should show how many active games

green kestrel
#

i usually just reboot single clusters, that alone takes about 30 secs

hollow sedge
#

also doesnt create_text_channel return the channel?

drifting wedge
#

like how did u split up

green kestrel
#

i do show how many active games, theres a graph for it

hollow sedge
# solemn elk so?

so obviously get_channel is going to return None because it did not find a channel

#

so you cannot get an id from a NoneType

solemn elk
#

ooh

green kestrel
#

@drifting wedge separate processes... each process has 4 shards on it, and is a cluster, and identifies for shard ids that are that cluster id mod max clusters

solemn elk
#

so what should it be

drifting wedge
#

how do u run like specific shards on certain proccesses?

#

^ my main quest

#

question

green kestrel
quartz kindle
green kestrel
#

if you look at the shard ids under each cluster, theyre all modulus of 8

earnest phoenix
hollow sedge
#
@commands.command()
async def ticket(self, ctx):
    name = f"ticket-{ctx.author.discriminator}"
    guild = ctx.message.guild
    channel = await guild.create_text_channel(f'#{name}')
    await ctx.send(channel.id)

@solemn elk i think this would work

earnest phoenix
#

doesn't that get a key that has the specific name

green kestrel
#

all 8 clusters share a common mysql database where they store information that is relavent to all of them, e.g. if i want to do a total user count or total game count

earnest phoenix
#

and not get the key based the index

quartz kindle
#

it gets the value assigned to that key

drifting wedge
#

i run my bot twice

drifting wedge
#

the first time, with shards 1-50

#

2nd time 51-100

quartz kindle
#

Collections are not sorted, they have no numeric indexes, no numbers

earnest phoenix
#

oof

quartz kindle
#

either you get the value from they key, or you need to convert everything to an array

hollow sedge
green kestrel
earnest phoenix
#

ok

green kestrel
#

each cluster independently updates its rows there

#

then i can use an external cron job to update server counts for uptimerobot, bot lists, etc

drifting wedge
#

like my question is how do u run only certain shards

green kestrel
drifting wedge
#

like how can u say: in this instance, run only these shards

green kestrel
#

depends on your library i guess? in aegis, i had to code in support for that into the library

#

it only had support for all shards under one process at first

drifting wedge
#

urs is aegis?

#

is it js based?

green kestrel
#

which at the scales im moving into now is bad

#

yes

#

no C++ based

quartz kindle
#

its c++ lol

drifting wedge
#

o ok

#

nice

green kestrel
#

the source is on github

drifting wedge
#

u should release ur version

green kestrel
#

including all the infrastructure that spawns 8 cluster processes

gilded olive
green kestrel
#

the shell scripts at the root level start it up, initially i run start.sh or put start.sh into the crontab in a @reboot line

quartz kindle
gilded olive
#

also guild is just ctx.guild

green kestrel
#

after that it bootstraps itself, and is pretty much managed by a web interface that watches processes and queries that status table

pale vessel
gilded olive
#

you also don't have to get the channel again

green kestrel
#

yes, master branch of aegis supports clustering

slender thistle
#

riht

gilded olive
#

create_text_channel returns the channel object

#

so use that

slender thistle
#

I'm blind

pale vessel
#

Hey blind

green kestrel
#

basically as simple as this

#
               aegis::core aegis_bot(aegis::create_bot_t()
                        .io_context(_io)
                        .file_logging(true)
                        .log_level(spdlog::level::trace)
                        .token(token)
                        .force_shard_count(dev ? 2 : from_string<uint32_t>(Bot::GetConfig("shardcount"), std::dec))
                        .intents(intents)
                        .clustering(clusterid, maxclusters)
                        .log_name(fmt::format("aegis-{}.log", clusterid))
                );```
gilded olive
#
@commands.command()
async def ticket(self, ctx):
    name = f"ticket-{ctx.author.discriminator}"
    guild = ctx.guild
    channel = await guild.create_text_channel(f'#{name}')
    await ctx.send(channel.id)```
green kestrel
#

what its doing is... if its in dev mode, always 2 shards 1 cluster

gilded olive
#

there, I also don't see what's that it supposed to do

green kestrel
#

if its in live mode, take shard count from a config file, cluster count from a command line parameter

gilded olive
#

you aren't passing any overwrites to the channel

#

so everyone will be able to see that ticket channel

hollow sedge
green kestrel
#

the aegis::create_bot_t::clustering() method configures the bot instance as a cluster, identifying for a subset of all shards

gilded olive
#

@solemn elk if you're looking into a ticket system permissions is key.

from discord.permissions import PermissionOverwrite


@commands.command()
async def ticket(self, ctx):
    name = f"ticket-{ctx.author.discriminator}"
    guild = ctx.guild
    overrides = {
                    guild.owner: PermissionOverwrite(send_messages=True),
                    guild.me: PermissionOverwrite(send_messages=True),
                    guild.default_role: PermissionOverwrite(send_messages=False, read_messages=True)
                }
    channel = await guild.create_text_channel(f'#{name}', overwrites=overrides)
    await channel.send("Ticket message here")```
#

that's the basic idea

#

of course you can config it to get a certain role object etc

#

because I assume you don't want everyone to see that ticket channel

hollow sedge
#

god

#

discord py has so much stuff built in

gilded olive
#

exactly why I love it

sick sluice
hollow sedge
#

you should probably use codeblocks for that

#

actually it doesnt matter

sick sluice
hollow sedge
hollow sedge
gilded olive
hollow sedge
#

especially with the recent updates

gilded olive
#

just put the code blocks in embeds

#

they look much better in there

hollow sedge
#

true

sick sluice
#

okay ty

crimson vapor
#

how can I make sure writeFile() is executed before it returns?

#
  _write(data) {
    if (data === undefined) throw 'Tried to write to DB without any data';
    if (!['object', 'array'].includes(typeof data)) throw 'collection name must be of type object or array';
    try {
      if (this._caching) this._data = data;
      data = JSON.stringify(data);
      fs.writeFile(this._tmpFilePath, data, 'utf8', (err) => {
        if (err) throw 'An error occured when writing to the DB:\n' + err;
        fs.rename(this._tmpFilePath, this._path, (err) => {
          if (err) console.log(err);
          return true;
          // if (err) throw 'An error occured when writing to the DB:\n' + err;
        });
      });
    } catch (err) {
      throw 'An error occured when writing to the DB:\n' + err;
    }
  }```
earnest phoenix
#

promisify it

#

and then async/await

crimson vapor
#

alr lemme try that

solemn latch
#

Couldn't you just use writefilysync

earnest phoenix
#

that too

#

i forgot that exists

crimson vapor
#

doesn't that stop the code until it is run?

earnest phoenix
#

yeah, isn't that what you essentially want to do

crimson vapor
#

can't you run await/await functions without stoping the process?

earnest phoenix
#

hm?

crimson vapor
#

I thought wrtiteFileSync stopped the process to write the file

#

like

earnest phoenix
#

it doesn't

crimson vapor
#

hmmm

earnest phoenix
#

ok

#

nobody cares

drifting wedge
#

can anyone help me? i want to run a specific set of shards dpy?

#

?

crimson vapor
#

idle

#

ofc

drifting wedge
#

why?

crimson vapor
#

@green kestrel

drifting wedge
#

@green kestrel

earnest phoenix
#

lol

crimson vapor
#

who did it

earnest phoenix
#

they really liked showing their 2 whole braincells

modern sable
#

i was waiting for him to finish typing in order to check if hes going to throw more death wishes lmao

drifting wedge
#

like he killed 1 person

crimson vapor
#

oh

drifting wedge
#

imma wait and see if he kills another

crimson vapor
#

LOL

drifting wedge
#

then ill arrest him!

solemn latch
#

Did discord py get a new version pogey

drifting wedge
#

wat!?

#

great! another version to not update to!

green kestrel
#

Apple py?

#

Or cherry Py?

earnest phoenix
#

pi

drifting wedge
green kestrel
#

No that's raspberries

earnest phoenix
#

ah yes sorry my bad ๐Ÿ˜”

drifting wedge
#

can anyone help me? i want to run a specific set of shards dpy?

#

like how would i do it?

dusky sundial
#

I may or may not have googled "Apple Py" because I totally didn't realize the pun

solemn latch
#

If your using the auto sharper just set the ShardCount=number

drifting wedge
#

uhh like for example

#

i want to have 50 shards

#

i want to run 10 shards per instance

#

but dont want overlap ofc

green kestrel
#

@drifting wedge doesn't it depend if discord.py supports such an arrangement

earnest phoenix
drifting wedge
#

if not i can add it in

green kestrel
#

Just change to c++ because c++ is win

drifting wedge
#

but like what would i do to do this

solemn latch
#

Yeah I think you'll need to make your own sharder if you want to have internal sharding.

green kestrel
dusky sundial
#

Apple would definitely make some programming language that costs $15/month to use

earnest phoenix
#

cygwin threw a whole ass fit for me yesterday and i'm tired of cpp please :(

solemn latch
#

Apple has a programming language and you need a mac to use it

drifting wedge
#

use normal client/bot and set the shard_count to 10 and the shard ids to differant ids for each instance

green kestrel
#

@earnest phoenix cygwin is death

#

Cygwin is like using a cigar to dig a hole

gilded olive
#

I am pretty sure discord.py will handle your shards for you

green kestrel
#

...in cement

crimson vapor
#

I just spent 10 minutes trying to find out why a function argument was undefined and it turns out I didn't even add it to the function

#

fuck

solemn latch
#

It will, but I dont think it supports internal sharding @gilded olive

drifting wedge
#

but i want dif proccesses

dusky sundial
#

Rubber ducking will always save your day

solemn latch
#

Which he is describing.

drifting wedge
#

per couple shards

#

i think u can

gilded olive
#

doc searching itme

#

brb

drifting wedge
#

u can define total shards

#

then run certain ones

green kestrel
#

@drifting wedge how many servers you got

#

It's not worth clustering like I do until restarts take a long time

drifting wedge
earnest phoenix
#

hi

drifting wedge
#

im at 500 servers and already running into erros that i need sharding

solemn latch
#

Again, not what he is asking for.

gilded olive
#

oh

drifting wedge
#

like its already slowing down

green kestrel
#

Coding a cluster system is a lot of fun though

drifting wedge
#

massively

green kestrel
#

Wether or not you need it

gilded olive
#

ya i dont think it support internal ones fr @solemn latch

green kestrel
#

@gilded olive he wants clusters of shards e.g. process A shards 0-4, process B shards 5-8

gilded olive
#

o

green kestrel
#

Shards split equally across processes

#

But not one shard per process

gilded olive
#

that's done by discord.py already tho? I am like 50% sure

#

you can ask in their official server gg/dpy

drifting wedge
#

im aiming rn at 100-150 servers per shard

#

i have the memory

#

and i have the power to run it

green kestrel
#

IIRC dpy runs all shards in one process or one shard per process no in between

drifting wedge
#

so shouldnt be an issue

green kestrel
#

Same as djs

drifting wedge
#
commands.Bot(..., shard_count=10, shard_id=1) will run shard 1```
#

there we go

#

with python, how can i like: have a file, and that file makes a couple files run

green kestrel
#

Do it with shell scripts

drifting wedge
#

wait no lmao

#

im stupid af

green kestrel
drifting wedge
#

thats stupid

#

whats the point of clustering

green kestrel
#

Just copy it lol

drifting wedge
#

if i have 1 file to run it

green kestrel
#

They're simple

drifting wedge
#

the whole point is to run them separately

green kestrel
#

The one file is a simple entry point

solemn latch
#

Has anyone had their table dropped because your username yet brain lol

drifting wedge
#

ye

green kestrel
#

You can rejig that across different machines if you want

drifting wedge
#

but how would i stop / run / restart one of them

upper elm
#

is there any way to add optional parameters to a js function?

drifting wedge
#

u can require them

#

and do var == none

upper elm
#

alr

drifting wedge
#

or underfined

#

so like if you dont set it

#

its = to whatever

green kestrel
#

In my case I simply kill -9 one of the cluster processes and it restarts

drifting wedge
#

not just none

upper elm
#

it doesn't cause errors or anything yeah

#

ok thanks

green kestrel
#

ps aux | grep ./bot

#

Pick a process

drifting wedge
#

wat language are you talking in

green kestrel
#

The web interface is a wrapper around that

#

That's just a shell command

drifting wedge
#

uhh prob will just do mongo lmao

#

on click: set mongo to RESTART botfile-1

green kestrel
#

Does dpy have something like pm2

drifting wedge
#

python does

solemn latch
#

Pm2

drifting wedge
#

pm2 is python

green kestrel
#

You could use that for starting clusters

drifting wedge
#

wait

#

no

#

ye

#

thats what i sue

#

use

#

prob will use subproccess

#

and run console

#

can i even?

green kestrel
#

Pm2 can only start node.js process can't it

drifting wedge
#

no

#

i use is for my boy

#

bot

#

discordpy

#

works great

solemn latch
#

It works with py too.

drifting wedge
#

interpreter python

solemn latch
#

Aka slow code KEKW

drifting wedge
#

lmao

#

uhh can i run root commands with mongo?

#

like i run a loop

#

check mongo every 5 mins

#

and see if it says to restart bot

#

if it does, run pm2 restart/stop/run bot(id)

twilit geode
#

whenever installing seequilize from the guide from https://discordjs.guide/sequelize/#a-simple-tag-system I get the following error

const sequelize = new Sequelize('database', 'user', 'password', {
                  ^

ReferenceError: Sequelize is not defined
    at Object.<anonymous> (/home/runner/Aperture-Bot/index.js:15:19)
#

code its mad at

const sequelize = new Sequelize('database', 'user', 'password', {
    host: 'localhost',
    dialect: 'sqlite',
    logging: false,
    // SQLite only
    storage: 'database.sqlite',
});
solemn latch
#

Do you have Sequelize defined anywhere?

#

You need to require it

twilit geode
#

what would the require command be

solemn latch
#

Its in the code example on the page you linked to

twilit geode
#

im so dum

#

ty lol

#

i thought that was just part of their skeleton code lol, i didnt look very hard at it

earnest phoenix
#

how to use mongo db in express and ejs and nodejs using website ?

drifting wedge
#

mongoose

earnest phoenix
#

mongoooose

#

@drifting wedge you can help me in using mongo db ?

drifting wedge
#

i do pymongo

#

not mongoose

earnest phoenix
#

um

#

ok

drifting wedge
#

@green kestrel sorry for ping again lmao, can i yoink ur restart icon?

#

like the ๐Ÿ” looking icon

hollow sedge
#

arent those just from font awesome or something

drifting wedge
#

i looked there already

hollow sedge
#

oh

drifting wedge
#

oh

#

found it

#

was looking for wrong term

#

its refresh

hollow sedge
#

yeah i just found it too by doing a google search instead of using their search

long marsh
long marsh
drifting wedge
#

oh thanks

#

how do i use fontawsome lmao?

hollow sedge
#

you just need to create a kit

#

and then use the script link in your web page

obtuse jolt
#

something on my vps keeps using port 6379 and causing my bot to error but when I kill it, it just restarts

#

i didnt even know my bot was using port 6379

#

wtf is using that port

long marsh
#

#general message -> Just curious if anyone had any thoughts here .. didn't want to ask directly here though.

#

Not asking for secrets, just curious on expectations.

hollow sedge
#

try netstat -l

drifting wedge
#

guys my bot is running on port 100000000

#

pls help