#development

1 messages · Page 221 of 1

sharp geyser
#

1 file?

#

I do everything in one line

pine willow
#

_ _

quartz kindle
#

:^)

pine willow
#

Imagine 3k line Code into 1 line

quartz kindle
#

literally every minified lib ever

warm imp
sharp geyser
#

I can make py like it

#

I will just make my own parser

pine willow
warm imp
#

No

sharp geyser
#

yes

pine willow
#

Oh hell no

warm imp
#
├── index.js
└── package.json```
#

So like that I don't know how to do it

quartz kindle
#

delete ping, delete commands, delete .env

#

keep package.json and index.js

#

delete everything inside your index.js

pine willow
#

Why do you need .env at all

warm imp
#

Right?

pine willow
warm imp
sharp geyser
#

just dont publish to a public github repo

#

and you can put it in your index.js if you want

warm imp
#

What even goes in the index.js

sharp geyser
#

code

quartz kindle
#

here is a basic discord.js code for listening to text messages and a basic !ping command:

const { Client, GatewayIntentBits } = require("discord.js");
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] });

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('messageCreate', async message => {
  if(message.content === "!ping") {
    message.channel.send("pong");
  }
});

client.login(TOKEN);
warm imp
quartz kindle
#

you will need to go into your discord application, in discord's website, and enable the Message Content intent for your bot

warm imp
#

For the bottom i put my token token?

quartz kindle
#

yes, you can put your token directly into the login function

pine willow
#
client.on('message', message => {
  if (message.content === '!ping') {  
    message.channel.send(`🏓Latency is ${Date.now() - message.createdTimestamp}ms. API Latency is ${Math.round(client.ws.ping)}ms`);
  }
});

For ms

warm imp
#

Wow

#

Coding is cool but hard

pine willow
#

But not needed for you

#

Start with simple !ping

quartz kindle
pine willow
#

I know

pine willow
#

You don't want 6,63963992ms right?

warm imp
#

Probably not

pine willow
#

You only want 6ms

warm imp
#

Mine would be like 100 right? If i am PC hosting

pine willow
#

But thats Extremly fast

#

Normally yes

pine willow
#

Just ask

warm imp
#

For {} what do those do

#

Is that the scope

#

Same with ()

#

And []

quartz kindle
#

[] is an array, you use it to create lists of items, for example const numbers = [1, 2, 3, 4]

sharp geyser
#

{} is the initiation of a scope

#

[] array

#

() is used for parameters in a function/loops or in conditionals

#

like if statements

#

at least thats the most common usage

quartz kindle
#

also math expressions

sharp geyser
#

yea I was going to say that

quartz kindle
#

(1 + 2) * 3

sharp geyser
#

but wasnt sure if that wasneeded yet

quartz kindle
#

huehuehue

sharp geyser
#

Didnt want to load him too much knowledge at once

quartz kindle
#

also {} for objects

warm imp
#

Wdym objects

quartz kindle
#
const myobject = {
  a: 10,
  b: 20
}
sharp geyser
#

classes, numbers, bools /j

quartz kindle
#

an object is like a list of items, but each item on the list has a label

#

and you can get the value of the item by its label

sharp geyser
#

think of it like a grocery store checkout.
Everything in your basket has a name, but it also has a price

quartz kindle
#

for example const ten = myobject.a

sharp geyser
#
const basket = {
  hotDogs: 1.99,
  toiletpaper: 6.99,
  water: 1.99
}
#

to continue my analogy

#

you can also do something called "destructuring"

warm imp
#

If yoy don't add those will there be a error?

sharp geyser
#
const { hotDogs } = {
  hotDogs: 1.99,
  toiletpaper: 6.99,
  water: 1.99
}
console.log(hotDogs) // 1.99
#

the only time you will get an error in an object is if what you are grabbing doesn't exist

warm imp
#

What happens if yoy don't use () [] {}

sharp geyser
#

you will definitely have errors

warm imp
#

Ok

#

How do people make emblems?

#

Like

#

Owner: Blissy

Ping : 72727ms

Servers: 373,737k

Users: 77,272m```
#

But like colorful

quartz kindle
#

like an image?

solemn latch
#

I'm thinking embeds? 👀

quartz kindle
#

Lol flaze

warm imp
#

Like this

#

Oh wait that's not it

#

Hold up

solemn latch
#

-needdev

gilded plankBOT
#

You seem to be asking for something you don't have experience for or something that hasn't been done yet, but really need for your bot/server.
You can hire developers from Fiverr or Freelancer to code the things you need for your bot/server.

solemn latch
#

^ one of those?

quartz kindle
#

thats not a normal embed, is it?

solemn latch
#

Its a modified client I think

warm imp
warm imp
#

Here's another one

quartz kindle
bitter granite
lyric mountain
#

Ermahgerd

warm imp
warm imp
bitter granite
warm imp
#

Oh

warm imp
# warm imp

Do yoy know how people get the boxes at the end?

#

That you can click and it goes to that link

solemn latch
#

you mean buttons?

warm imp
solemn latch
#

discordjs still?

warm imp
pine willow
solemn latch
#

its on the guide iirc

pine willow
#

And Emojis

#

And stuff

solemn latch
sharp geyser
#

Not going to lie the person who taught me how to spam emotes was jh

quartz kindle
#

like centering and stuff

warm imp
#

That helps when I need to do my /bump commands

#

When I figure out all this stuff

pine willow
#

Thats still a Normal embed

quartz kindle
#

looks weird

pine willow
#

Using invis Chars

warm imp
pine willow
#

_ _

#

Invis text

#

Thats how you can make Something like that

warm imp
#

Oh

pine willow
#

But idk if they did that like that

warm imp
#

Yeah

#

I don't know

warm imp
pine willow
#

Yes.

warm imp
#

🙂 whoops went the wrong way lol

pine willow
#

CLONE

bitter granite
#

Did i just hear a CLONE!!

pine willow
#

YES

#

CLONE

solemn latch
#

was there a windows hack/vulnerability?

#

👀

warm imp
#

?

#

Who's HR?

#

Oh wait

bitter granite
#

Bruh discord

#

I replyed

warm imp
#

He's typing Peek

bitter granite
pine willow
#

Uh

#

Gn

warm imp
#

Gn

sharp geyser
#

showing the decline button

#

NDA violation

#

banned and sued

bitter granite
warm imp
#

Is it hard to get your bot on Top.gg

bitter granite
solemn latch
#

Understanding the guidelines makes it really easy

warm imp
#

I just wanna make a bot 🙂 that people would like and I can like mostly

#

If i know I can make a bot I would be happy with that/code

bitter granite
pine willow
#

Just don't make Multi purpose

#

Pls

warm imp
warm imp
pine willow
#

Yes

#

Well the bot that i coded to slap ixz has 250 lines

bitter granite
warm imp
#

Ngl that sentence didn't make any sense

pine willow
solemn latch
#

Clones

warm imp
bitter granite
pine willow
solemn latch
#

I wish we still had datadog

pine willow
#

Botghost

pine willow
warm imp
warm imp
solemn latch
#

It showed all the big overview stats of reviewed bots

solemn latch
#

like decline rates

sharp geyser
warm imp
pine willow
#

6

bitter granite
sharp geyser
#

costed a lot

solemn latch
#

It was really expensive

warm imp
#

Oh

sharp geyser
#

datadog was a huge expense

pine willow
#

Hosting cost?

solemn latch
#

Yeah

bitter granite
solemn latch
#

Not like we hosted it, but it was a lot

pine willow
#

Just ask me lmao

sharp geyser
#

its like 50$ a month iirc

#

and all it did was show some minor data

pine willow
#

Uh

solemn latch
#

Oh our bill was way more than that

sharp geyser
#

oh im sure

#

but base cost is 50$ a month

solemn latch
#

Not sure what it was, but it wasnt their base plan

pine willow
#

Free Service on top

#

(i do that)

#

ADS

sharp geyser
#

I dont think you can self host datadog

warm imp
#

Dang i can't change my name

sharp geyser
#

Sadly

pine willow
bitter granite
pine willow
warm imp
sharp geyser
#

maybe one of these days I will make a datadog clone and give it to woo

warm imp
#

Just use serverstats 💀

#

Jk

sharp geyser
#

not what we are talking bout

#

serverstats wouldnt help

solemn latch
#

I think we would just use an off the shelf thing for time series analytical data. Like timescale.

sharp geyser
#

or you can use my free service

#

I manually analyze the data in real time and make a graph

#

hourly updates

solemn latch
#

Honestly, I doubt we will ever implement something like that these days for public use anyway.

sharp geyser
#

honestly

warm imp
solemn latch
#

The benefit of datadog was the public facing nature

sharp geyser
#

time to make a self bot to scan #mod-logs for all the declined bots

solemn latch
#

Lmao

sharp geyser
#

and make a metric of how many people declined bots

solemn latch
#

You'd need to scan logs too for approvals

bitter granite
sharp geyser
#

who cares about approval

#

I only care about declines

solemn latch
#

I bet our internal development taskforce would handle that if we pushed for it.

sharp geyser
#

not trying to get banned

pine willow
#

I read decline Reasons because i'm bored

bitter granite
sharp geyser
#

honestly

solemn latch
#

Honestly

sharp geyser
#

nah I wont

warm imp
#

Ngl just count 💀

#

Lmao

sharp geyser
#

uh no

solemn latch
#

And tbh, it wouldn't work as well these days anymore. The number of BRs that use custom decline reasons is too high for it to work

earnest phoenix
#

hi

sharp geyser
#

240k+ messages in that channel

pine willow
sharp geyser
#

no ty

bitter granite
solemn latch
#

Because datadog would use the preset decline buttons to determine which was which

#

Or well it was setup that way

pine willow
#

Yes

#

That wae a joke decline

#

Was

warm imp
#

Oh

pine willow
#

Just star it

bitter granite
pine willow
#

Is starboard offline?

#

Bruh

bitter granite
pine willow
#

fs?

bitter granite
pine willow
#

Oh

bitter granite
#

Only mod+ can do it

pine willow
#

Hm :(

warm imp
#

And all those

pine willow
#

Bot Advertisement

bitter granite
bitter granite
pine willow
#

Funfact i can see all the content in that Channel

bitter granite
bitter granite
pine willow
#

Nope

#

Just some Magic trick

bitter granite
pine willow
#

Nothing modded at all

bitter granite
#

Thats normal for discord

pine willow
#

Like i can see all the Stuff from Yesterday etc

bitter granite
pine willow
#

Until you close the Channel

bitter granite
pine willow
#

Wtf

#

Did they change that?

bitter granite
#

Need to be whole client

bitter granite
pine willow
#

Bruh

#

Well i can Close the Browser Tab now

#

That is running 24/7

solemn latch
#

Honestly

sharp geyser
#

honestly

proud plover
#

how do I make my bot have it too?

pale vessel
#

they'll eventually appear as more people use your bot's global commands

warm imp
#

After i make a !ping how do i restart my bot?

quartz kindle
warm imp
#

My !ping still didnt work

#
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] });

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('messageCreate', async message => {
  if(message.content = "!ping") {
    message.channel.send("pong");
  }
});

client.login("Token");```
deft wolf
#

I guess you also need MessageContent intent if your want to read content of the messages

warm imp
quartz kindle
#

^

neon leaf
#

Fuck you beat me to it

#

Smh

warm imp
#

What does === mean vs =

neon leaf
#

= assigns a value, === compares 2 values

warm imp
#

Oh alr

#

It still didnt work

#

I dont know why

quartz kindle
warm imp
#

Yeah

#

My bot is online

quartz kindle
#

and when you type !ping on discord does anything show up in your console?

warm imp
#

No

quartz kindle
#

add a new line before if(message.content = "!ping") { and write console.log(message)

#

like this ```js
client.on('messageCreate', async message => {
console.log(message);
if(message.content === "!ping") {
message.channel.send("pong");
}
});

warm imp
quartz kindle
#

then restart the bot (press ctrl + C, then run node index.js again)

warm imp
#

k

#

I got stuff in my console

quartz kindle
#

show the stuff

warm imp
#
  channelId: '1251190770057220131',
  guildId: '1251190770057220128',
  id: '1251504694623342592',
  createdTimestamp: 1718452371031,
  type: 0,
  system: false,
  content: '',
  author: User {
    id: '932313912110628894',
    bot: false,
    system: false,
    flags: UserFlagsBitField { bitfield: 4194368 },
    username: 'blissy0927',
    globalName: '𝑨𝒍𝒑𝒉𝒂 𝑩𝒍𝒊𝒔𝒔𝒚 :eagle:'           ,
    discriminator: '0',
    avatar: '97c5261c6c6f809ec16dc539baaeeb0d',
    banner: undefined,
    accentColor: undefined,
    avatarDecoration: null
  },
  pinned: false,
  tts: false,
  nonce: '1251504286412570624',
  embeds: [],
  components: [],
  attachments: Collection(0) [Map] {},
  stickers: Collection(0) [Map] {},
  position: null,
  roleSubscriptionData: null,
  resolved: null,
  editedTimestamp: null,
  reactions: ReactionManager { message: [Circular *1] },
  mentions: MessageMentions {
    everyone: false,
    users: Collection(0) [Map] {},
    roles: Collection(0) [Map] {},
    _members: null,
    _channels: null,
    _parsedUsers: null,
    crosspostedChannels: Collection(0) [Map] {},
    repliedUser: null
  },
  webhookId: null,
  groupActivityApplication: null,
  applicationId: null,
  activity: null,
  flags: MessageFlagsBitField { bitfield: 0 },
  reference: null,
  interaction: null,
  poll: null
}```
quartz kindle
# warm imp

did you click the save button at the end of the page?

warm imp
#

Yeah

quartz kindle
#

ah i forgot something

#

on the second line const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] });

#

add GatewatIntentBits.MessageContent

#

like this:

const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
#

you can also space it a bit to make it easier to understand

#
const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent
  ]
});
warm imp
#

Yay it worked

quartz kindle
#

js doesnt care about spaces and newlines, as long as you follow the delimiters for () [] and {}, so you can organzie the code as you prefer

warm imp
#

Alr

#

What else should i do so i can learn?

quartz kindle
#

try some string manipulation

#

for example

#

message.content contains the message you typed on discord

#

you can create rules based on what the message content contains
if(message.content === "something") = exact match
if(message.content.startsWith("something")) = start with
if(message.content.endsWith("something")) = ends with
if(message.content.includes("something")) message contains a word

#

you can also cut, construct and manipulate texts in all kinds of ways

#

message.content.slice(5, 10) = extract the text between the 5th and the 10th character

const newtext = `add some fixed text before ${message.content}`
``` = mix a fixed text with the text typed
warm imp
#

Wow

#

for this one

#

if(message.content.includes("something")) message contains a word

#

djwdawjdawdwjdiwa Blissy

#

If i put Blissy in the something

#

I can put anything in it and it would say what it says?

quartz kindle
#

example

#
if(message.content.includes("Blissy")) {
  // do something when message contains "Blissy"
  message.channel.send("hi Blissy")
}
#

if you want to make the bot repeat what you said, you can message.channel.send(message.content)

warm imp
#
  if(message.content.includes("Blissy")) {
    message.channel.send("Hi Blissy");
  }
});```
#

Its not working

quartz kindle
#

did you restart the bot?

warm imp
#

Yeah

#

It worked

quartz kindle
#

did you type Blissy with uppercase B?

warm imp
#

Fixed it i accidently didnt save 😭

quartz kindle
#

exdee

warm imp
quartz kindle
#

because the bot can also read its own messages

#

and sees that they also contain the word Blissy

warm imp
#

Ohhhh

#

That makes sense

quartz kindle
#

you can add a rule to ignore bots:
if(message.author.bot) { return; }

warm imp
#

Where do i put that?

quartz kindle
#

at the beginning of the messageCreate block

#

before the other ifs

#

code always runs from top to bottom, so the order of your rules can be important dependiong on the situation

warm imp
#

It worked

#

And its not spamming

quartz kindle
#

gj

warm imp
#

Ty

#

For console logs

#

If you want it to read it

#

Do you put it above or below the code

quartz kindle
#

console logs are used to show values in your console, so you can see what is going on in your code

#

the value you want to show has to exists in the location where you put console.log

#

so it has to be after that value was created, and inside the block where that value exists

warm imp
#

Ohhh alr

#

🏓Latency is -97229ms. API Latency is -1ms

#

is that good or bad

quartz kindle
#

its wrong

#

lmao

warm imp
quartz kindle
#

what code did you use to get those values?

#

trolled by automod?

#

huehuehue

warm imp
#

lol

quartz kindle
#

if automod is not letting you paste the code, you can take a print of it and post it as an image lol

warm imp
quartz kindle
#

client.ws.ping is correct, but it takes up to 45 seconds for it to be populated, so it will be -1 for a bit when you just start your bot

warm imp
#

Now it is 31ms

quartz kindle
#

Date.now() - message.createdTimestamp has an issue where it only works if both your pc and discord's servers are in sync with their clocks

#

because Date.now() uses your pc's clock time, and message.createdTimestamp uses discord's clock time

#

and clocks between compouters can be out of sync by several seconds

warm imp
#

True

quartz kindle
#

the only correct way to get the message latency is to try to send it first and measure how long it took to send

civic scroll
quartz kindle
#

then you can either send another message with the result, or edit the first message

warm imp
#

Not the time

quartz kindle
#

alright

quartz kindle
#

the 31ms one is measuring how long it takes for discord's events to reach your bot

warm imp
#

Is that good?

#

31ms

quartz kindle
#

yes its pretty good

warm imp
#

ok

quartz kindle
warm imp
#

is it to early to try to make a embed

quartz kindle
#

nah, you can go ahead

#

embeds can be made in 2 ways

civic scroll
quartz kindle
#

using raw objects, for example ```js
message.channel.send({
embeds: [{
title: "abc",
description: "xyz"
}]
})

#

or using the discord.js EmbedBuilder

civic scroll
#

or the embed builder

#

with said objects

#

recommended the builder if you want to conditionally add stuffs to the embed

warm imp
#

What is it for server guild is it just guild?

quartz kindle
#
const embed = new EmbedBuilder();
embed.setTitle("abc");
embed.setDescription("xyz");
message.channel.send({ embeds: [embed] })
civic scroll
#
const embed = new EmbedBuilder({
    title: "amogus"
})
if (user.sus)
    embed.setDescription("you are sussy")

channel.send(...)
quartz kindle
#

you can do message.guild

#

ie: message.guild.id, message.guild.name, etc...

civic scroll
#

@warm imp do you use vscode

warm imp
#

ohhhh

warm imp
civic scroll
#

because if you do

#

it can suggest you

#

press Ctrl + Space after .

#

eg. type message. then Ctrl + Space

quartz kindle
#

yeah vscode should show you the available options after you type the dot

civic scroll
#

Ctrl + Space again will make it display full definition

warm imp
#

if i type abc it would work or

civic scroll
#

it builds the embed, then you can send it

quartz kindle
#

not related to what you type

warm imp
#

I was reading it wrong whoops

#

I got to go to get a haircut. Ty i'll be on later if to code more

#

Ty for helping me

pine willow
#

i got pinged here?

#

who pinged me

quartz kindle
#

you got compressed here

pine willow
#

bruh

warm imp
#

Do you know how to make a uptime?

#

So like how long your is up for until you restart it and then it restarts the count?

pearl trail
#

process.uptime iirc

#

or client.uptime if u use djs

wooden ember
#

Is there a way to detect when the voice connection of a bot drops so I can make it reconnect asap?

#

my server doesn't have this issue but my pi does and its really annoying to have to reconnect the bot every 30 seconds

warm imp
solemn latch
#

Process uptime is the time your process was started.
IE when you ran node . is process.uptime

client uptime is the time your client is up.
Its when the client.on("ready" ... was last emitted

warm imp
#

Then client is the one I should use then ig

warm imp
deft wolf
#

Yep

#

That's how "uptime" works

warm imp
#

Alright ty

#

I wanna do commands but I don't know them yet lol

warm imp
#
  if(message.author.bot) { return; }
  if(message.content.includes("!server")) {
    message.channel.send("message.guild.name");
  }
});```
deft wolf
#
message.channel.send(message.guild.name)

or

message.channel.send({ content: message.guild.name })

or

message.channel.send(`Server name: ${message.guild.name}`)
warm imp
#

Ty it worked

deft wolf
#

The last option is probably the most frequently used if you want to put some value along with the text

warm imp
#

Alr

#

i wanna make a command but i dont understand it so idk if i should or not yet

deft wolf
#

Commands are the basis of the bot's functioning, to be honest

warm imp
#

I just dont understand the handling

deft wolf
#

It's hard to do anything without them

warm imp
#

And what to do in the index.js after

warm imp
deft wolf
#

How you do it really depends only on you. You could just as easily write everything in one file, but yes, creating a separate folder for commands and handlers is a good, although slightly more advanced option

warm imp
deft wolf
warm imp
#

Yeah thats what i was thinking too

#

For handler folder do i just put ping.js?

#

Because i just made a ping command

#

Just dont know what to do in the handler

#

Um Is it bad if Ctrl + C doesnt turn off my bot?

wooden ember
#

just means you prpbably have another instance running somewhere

#

check top to see if the prosses is still running and kill it from there

#

also what endpoint is this and how do I use it? bot stops playing not cuz my internet is trash for once but for some reason the audio stream I am using dies and this pops up on the debug output.

#

I already have this, as this is what would normally detect audio that has stopped playing but it never gets run.

pine willow
#

// connection unfu

deft wolf
#

[Anty Crash]

sharp geyser
#

Any errors?

#

Also, its likely a bot since only bots have discrims now, iirc users get null on their discrims. (might be wrong)

warm imp
#

I made a slash command how do you make it so it pops up. Someone said node src/ping.js

deft wolf
#

For a command to be available on Discord, you must first register it in the Discord API

warm imp
#

module.exports = {
    data: new SlashCommandBuilder()
        .setName('ping')
        .setDescription('Replies With Bot Latency!'),
    async execute(interaction) {
        await interaction.reply('Ping: ${Math.round(client.ws.ping)}ms!');
    },
};

client.on('interactionCreate', (interaction)); {
    if (interaction.isChatInputCommand ()) return;
    console.log(interacton);
  }```
deft wolf
#

Not really

warm imp
#

Oh

deft wolf
warm imp
#

Can the whole code go in my commands/ping.js

sharp geyser
#

no

warm imp
#

Or should i make a handlers/ping.js

sharp geyser
#

you should not be registering commands in the command file itself

warm imp
wooden ember
#

at this point I think I am just gonna regex the log and use that as any of the normal voice channel disconnect/idle/whatever things never actually run.

wooden ember
#

apparently under the bot object or whatever there is a voice state update thing that does fire so I am trying to make something of that now

wooden ember
#

well only god knows whats wrong at this point. this all works fin on my server but is fucked on my pi and my pc. even after updating everything and compleatly using different hardware still doesn not work.

sharp geyser
#

What exactly is going on

wooden ember
#

next time I can get to turn on my derver I will just coppy the files from it and use that but since they where built from the ones I am trying to get to work now I don't see what the differance is at all

sharp geyser
#

as the screenshot you provided told nothing

wooden ember
#

Basically my bot joins the vc, it starts streaming audio from the mic jack on the pi/server/whatever. It works perfectly for about 40 seconds and then the green ring goes out and then I cant get it to do anything else unless I manually run the leave command and make it join again.

#

it never used to do this and on my actual server pc which I cant use right now it still works. but on my pi it does not.

#

ther is no audio artifacting from my junk internet it just stops playing

sharp geyser
#

Are you using lavalink or is this purely through djs or whatever lib you are using

wooden ember
#

d.js voice

sharp geyser
#

what version

wooden ember
#

used to be this but I updated it all through npm so should all be up to date now.

#

updating made no differance

sharp geyser
#

No internet issues?

#

Make sure your pi is not suffering any

wooden ember
#

My internet is slow yes but its not cutting out

sharp geyser
#

if its slow it could cause some issues depending on how slow it is

#

also if there is anything else running on it using the wifi connection

wooden ember
#

I mean I have 0.5Mb/s up but since the voice connection is 64Kb that still has alot of head room

#

I'm connected via ethernet

sharp geyser
#

ic hm

wooden ember
#

and nobody but me is on the internet rn

sharp geyser
#

yea I have no idea what could be causing it then.

wooden ember
#

lol

sharp geyser
#

Voice is a bit out of my range now adays

wooden ember
#

fair

sharp geyser
#

haven't touched the voice gateway since 2020

#

💀

wooden ember
#

I am just fustrated cuz this used to all work fine

#

but then cuz power got so expensive I ccouldn't run my server 24/7 anymore so I moved it all to the pi

#

and thats when all this started acting up

#

you know what fuck it I am just gonna turn my server on and rip the files off of it.

sharp geyser
#

i'd run servers even if the power bill was high ngl

#

it's so much nicer than a pi

#

😭

wooden ember
#

I know but I live with my parents still and still looking for a job so I would feel bad if I was just using 300 quid a year for pretty much no reason.

#

I just don't like turning it on and off cuz the hdd is struggling and I cba to take the whole thing apart.

quartz kindle
#

if it used to work on old versions but doesnt on new versions, then they broke something and you need to find out the "new" way of doing it

wooden ember
#

bruh this has peen broken on my pi for the last 2 years almost I just never bothered to fix it

#

also I love finding the few comments I have in my code

frosty gale
wooden ember
#

yeah

#

its not exactly the same time but feels close enough

#

just in the prosses of comparing it with the code on my server rn

little cosmos
#

i have a bot and i did make an outside cluster,sharding manager how do i post the status to top gg using that client since it says unsupported client

little cosmos
sharp geyser
#

are you using discord.js?

little cosmos
#

discord js sharding not good

sharp geyser
#

What package...?

little cosmos
#

discord-hybrid-sharding

wooden ember
#

OK so touch wood..... I think I have fixed it. the only real differance I found was on the PI the sample rate was lower. only 1600 instead of 3200. So only thing I can think was the issue is since discord takes a bit to connect there was a bit of a buffer and that just ran out as the data rates where misss mached.

little cosmos
wooden ember
#

don't really see how that would have made much of a differance cuz if one was running at the wrond rate it should have sounded like it was playing at 2x speed or something. idk but after all this its working so idc at this point.

sharp geyser
#

I saw what you said

#

I am looking at the docs for it one moment

#

be patient

little cosmos
sharp geyser
# little cosmos ok sir

Right so

let size = client.cluster
    .broadcastEval(`this.guilds.cache.size`)
    .then(results => {
      return results.reduce((prev, val) => prev + val, 0);
    });

Using discord-hybrid-manager this is how you get all the servers of your bot in every shard
You would then install this package: https://www.npmjs.com/package/@top-gg/sdk and do

const {Api} = require('@top-gg/sdk')

const api = new Api("your top.gg token")

api.postStats({
  serverCount: size,
  shardCount: getshardssomehow
})
#

note you have to post these stats periodically

#

but since you are using discord-hybrid-manager you can't use the autoposter

#

you will have to set an interval yourself

little cosmos
#

am using it like this one minute

little cosmos
sharp geyser
#

post them every hour

little cosmos
#

but like that i can say my bot is in 1m server lol

sharp geyser
#

or every 30m

#

actually you should be able to do it lower if. you want

#

just don't exceed 60 requests / minute

little cosmos
little cosmos
sharp geyser
#

If you do, then you will get your bot banned from top.gg iirc

#

not worth it

#

Unless you don't care

little cosmos
#

THANK U

sharp geyser
#

np

little cosmos
#

1 last question

#

now i have like 40 shards and 4 clusters

#

if i need to access the client i need to do it in the bot file not in the sharding manager

#

like that it will be boosted 40 times right?

#

@sharp geyser

sharp geyser
#

what do you mean

little cosmos
#

since the bot file called 40 times or 4 am not sure in the hybrid pkg but in the discord js it will be called 40 times

little cosmos
sharp geyser
#

What, why is the file being ran 40 times

little cosmos
sharp geyser
#

No way thats what discord-hybrid-manager tells you to do

little cosmos
#

every shard = 1 process

sharp geyser
#

That is incorrect

little cosmos
sharp geyser
#

Remind me again what package are you using

#
sharp geyser
#

yea no

#

That's not how that works

#

or should work

little cosmos
little cosmos
# sharp geyser or should work
const manager = new ClusterManager(`${__dirname}/bot.js`, {
    totalShards: 'auto', // or numeric shard count
    /// Check below for more options
    shardsPerClusters: 2, // 2 shards per process
    // totalClusters: 7,
    mode: 'process', // you can also choose "worker"
    token: 'YOUR_TOKEN',
});```
#

shardsPerClusters: 2, // 2 shards per process

#

i have it like this shardsPerClusters: 10, // 2 shards per process

sharp geyser
little cosmos
#

so i have 4 processes

sharp geyser
#

I mean ig it's starting the cluster on its own process

little cosmos
#

that mean 4 intervals

sharp geyser
#

but not the shards

#

If it was starting each shard on tis own process that would be a BITCH to manage

#

either way

#

do this in your main file

#

not the cluster.js file (or whatever you called it)

little cosmos
sharp geyser
#

as you will be able to call cluster.client.broadcastEval()

little cosmos
#

btw i will find a way to do it using discord api thanks for help

sharp geyser
#

yes you can

#

when you instantiate teh discord client

#

it has you do client.cluster = new ClusterClient()

#

in that same file

#

just auto post your stats in an interval

#

@little cosmos ^

little cosmos
#

the bot file where u const the client called bot.js

#

so bot .js is called 4 times

#

4 child process

sharp geyser
#

I am confused on how the hell you are setting this up

little cosmos
#

an interval inside it will be executed 4 times

sharp geyser
#

I am starting to think your setup is entirely wrong

little cosmos
#

bots above 2k server

#

u cant run a bot over 2k server inside 1 process

sharp geyser
#

Yes but you should still be able to access the cluster

little cosmos
sharp geyser
little cosmos
#

u can make 1 thing

sharp geyser
#

whatever

#

im done trying to help ya

little cosmos
#

XD

#

tahts fine

#

const {Api} = require('@top-gg/sdk')

const api = new Api("your top.gg token")

api.postStats({
serverCount: size,
shardCount: getshardssomehow
})

#

you helped me with this though

#

thanks

sharp geyser
#

Im just telling you now

#

you wont be able to use the discord api to get your server size

#

you HAVE to get that from the client

#

So what you are saying is entirely incorrect, and it IS possible to get this information.

little cosmos
#

i can set a json file and count inside it the times that bot .js file called

#

and set an express server to it

#

that will work

sharp geyser
#

or hear me out, just post the stats on bot ready

little cosmos
#

and it will post it 4 times

sharp geyser
#

Whatever you are doing is incorrect, or you've just never tested any of this before

sharp geyser
#

Big bots are able to post their stats rather easily

little cosmos
#

i will take a pic

sharp geyser
#

It's not that hard

little cosmos
#

1 sic

little cosmos
#

but in the hybrid u cant

sharp geyser
#

Then don't use discord-hybrid-sharding, or don't post your stats

#

but the fact that the docs for discord-hybrid-sharding shows that you CAN get the guild count of your cluster

little cosmos
sharp geyser
#

then it is definitely possible

little cosmos
#

in hybrid it uses just 6

sharp geyser
#

I don't know what to tell ya man

little cosmos
sharp geyser
#

I've said all I could

little cosmos
#

i can get the guilds count but it will be posted 4 times

little cosmos
quartz kindle
#

not from the clients

little cosmos
#

thats my manager object

quartz kindle
#

the manager file

#

index.js

little cosmos
quartz kindle
#

you post manually

little cosmos
#

how?

#
_eventsCount: 2,
  _maxListeners: undefined,
  THREAD: [class Child],
  manager: ClusterManager {
    _events: [Object: null prototype] { clusterCreate: [Function (anonymous)] },
    _eventsCount: 1,
    _maxListeners: undefined,
    respawn: true,
    restarts: { max: 3, interval: 3600000, current: 0 },
    clusterData: {},
    clusterOptions: {},
    file: '/home/container/bot.js',
    totalShards: 40,
    totalClusters: 4,
    shardsPerClusters: 10,
    mode: 'process',
    shardArgs: [],
    execArgv: [],
    shardList: [
       0,  1,  2,  3,  4,  5,  6,  7,  8,  9,
      10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
      20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
      30, 31, 32, 33, 34, 35, 36, 37, 38, 39
    ],
    token: '',
    clusters: Map(2) { 0 => [Cluster], 1 => [Circular *1] },
    shardClusterList: [ [Array], [Array], [Array], [Array] ],
    clusterList: [],
    spawnOptions: { delay: 7000, timeout: -1 },
    queue: Queue { queue: [Array], options: [Object], paused: false },
    promise: PromiseHandler { nonce: Map(0) {} },
    heartbeat: undefined,
    recluster: undefined,
    hooks: ClusterManagerHooks {},
    [Symbol(kCapture)]: false
  },
  id: 1,
  args: [],
  execArgv: [],
  shardList: [
    10, 11, 12, 13, 14,
    15, 16, 17, 18, 19
  ],
  totalShards: 40,```
quartz kindle
# little cosmos how?
manager.fetchClientValues('guilds.cache.size')
  .then(results => console.log(`${results.reduce((prev, val) => prev + val, 0)} total guilds`))
  .catch(console.error);
#

results should be an array, one item for each cluster

still lily
#

what point do you guys reccomend sharding? i'm in about 1600 servers right now and i still only use like .2 gb of ram.

quartz kindle
#

its recommended to start at around 1500

deft wolf
#

Sharding is probably recommended from 1500 servers and required at 2500 if I remember correctly PepoThink

pine willow
#

i'm already using it so i'm prepared

little cosmos
quartz kindle
#

since i couldnt find docs

still lily
#

i didnt even know lol

little cosmos
quartz kindle
little cosmos
#

now were talking

#

XD

little cosmos
pine willow
#

so its REQUIRED to have it in the code?

quartz kindle
little cosmos
quartz kindle
#

login will fail with error "sharding required"

pine willow
pine willow
little cosmos
#

bots like pro bot uses 1t ram

pine willow
#

holy shit

#

well i dont have 1T ram

still lily
#

@little cosmos what would happen if you tried to use internal sharding

quartz kindle
#

lmao

little cosmos
quartz kindle
#

x doubt

deft wolf
pine willow
#

i dont think that a bot needs 1TB RAM

quartz kindle
#

large bots have custom/modded libs

#

they dont use raw discord.js

#

that would be suicidal

little cosmos
#

1 shard uses at least 300mb

little cosmos
quartz kindle
#

because ram usage can be tweaked by configuring caching

#

my bot is in 10k servers and uses 150mb ram

little cosmos
#

i know

#

but at least 1 shard needs 200mb of ram

#

10m server needs at least 7000 shard

#

7000 * 200

quartz kindle
#

it can use as little as 50mb per process

#

with 8+ shards per process

neon leaf
#

omg

#

I finally managed to properly sync my 2 postgres dbs

little cosmos
quartz kindle
#

but a bot using 1tb ram is simply a massive waste of resources and the team behind it sucks

little cosmos
#

/status

#

260 gb for 1.5m

#

how about 10m

still lily
sharp geyser
#

You are only in like 800 servers right?

#

You're just adding more complexity for no reason

little cosmos
pine willow
#

it wasnt that hard....

sharp geyser
#

Well no

little cosmos
sharp geyser
#

but there's literally 0 reason to shard rn

#

sharding too early is pointless

#

as you don't benefit

quartz kindle
#

or they are rich and dont care

little cosmos
#

for discord api

#

named dbb i think

#

a bot with 300k uses only 100mb ram

#

but the bad thing its in c++

pine willow
little cosmos
quartz kindle
#

you can pretty much scale indefinitely if you use webhook interactions and stick with slash commands only

#

it wouldnt be any different from running a website with a few hundred hits per second

little cosmos
past field
#

what normally causes an “unknown interaction” error? never got it before but i randomly did just now

quartz kindle
#

i have my own raw lib

deft wolf
little cosmos
quartz kindle
little cosmos
quartz kindle
#

imo, every big bot should make their own lib

#

its a huge waste of resources running on top of a big ass lib with a ton of features you will never use

#

and a structure that is not optimal for your exact use case

#

imo big bots should be engineered from the ground up for their specific use case

quartz kindle
little cosmos
#

and my bot uses message commands

quartz kindle
#

i dont have it

#

nor do i need it

little cosmos
pine willow
#

but i dont need it

sharp geyser
#

yea no, any bot that is even in 250k servers should start using their own lib imo

#

Once you start seeing growth like that discord.js will hold you back more than it will help

#

If not making your own lib, swap to a more memory efficient language if you really want a library to use

quartz kindle
#

yeah at some point it would be very much worth it to engineer the bot from ground up

#

the difference in hosting costs would be absurd

sharp geyser
#

especially in a new language that's more memory efficient like C++

#

I bet if dyno used C++ it's ram usage would be cut in half

#

if they coded it properly

sharp geyser
#

a lot of what djs does for you is stuff you wont need when you are a larger bot

little cosmos
#

and its in 10m server

sharp geyser
#

yes

#

and they will have to change libs if they plan on operating any longer

quartz kindle
#

eris is abandoned, has been for a few years already

#

most big bots who use eris use a modified version of it

sharp geyser
#

unless they fork eris themselves

quartz kindle
#

or maintain their own forks

sharp geyser
#

and maintain it

#

which at that point

#

make your own fucking lib

#

😭

crystal wigeon
#

Anyone know any gfx guy?

sharp geyser
#

fiverr

crystal wigeon
#

Gae

#

also btw can I make animated stuff on figma?

sharp geyser
#

idk

#

google it

crystal wigeon
#

Too lazy

#

And sleepy rn

#

Btw is dyno ded or something?

#

It’s not working in my server

sharp geyser
#

all shards are operational

little cosmos
#

first cluster and its not ready yet

#

1gb ram

crystal wigeon
#

What’s the problem

sharp geyser
#

what do you expect

sharp geyser
#
tcp             LISTEN           0                50                         [::ffff:127.0.0.1]:35712                                *:*                               
tcp             LISTEN           0                4096                       [::ffff:127.0.0.1]:53121                                *:*                               
tcp             LISTEN           0                50                         [::ffff:127.0.0.1]:34147                                *:*                               
tcp             LISTEN           0                50                         [::ffff:127.0.0.1]:5990                                 *:*                               
tcp             LISTEN           0                4096                       [::ffff:127.0.0.1]:63342                                *:*                               

I have no fucking clue what these ports are for

#

it doesn't tell me the process either

#

so I am not sure

#

figured it out with netstat

#

but idfk what ld-linux-x8 is

#

right so @oak cliff is there anyway to stop automod for certain channels?

#

Because sometimes it blocks actually getting help

oak cliff
#

well then people could post the thing we dont want posted in here heh

#

we need a better phone number regex

sharp geyser
#

indeed

#

because as it stands now it's getting rather annoying to ask for help with anything network or linux related 😭

#

Anyway, this is what I was trying to post

#

I have no idea what any of this is

#

It just randomly popped up in my used ports

#

Okay nvm

#

I found out what it is

#

it's just jetbrains ssh remote server

surreal sage
#

How can I properly do ```ts
type Something = Record<string, string | Record<string, string | Record...

#

context: i18n json

#

well well well...

neon leaf
#

Uh

surreal sage
#

wait

#

type Test = string | { [key: string]: Test };?

neon leaf
#

Do

string | { [x: string]: Test }

surreal sage
#

yaaa

#

imagine using x for key :3

neon leaf
#

Am on phone sir

surreal sage
#

thx though!

quartz kindle
#

i've never seen it happen ever lol

pine willow
sharp geyser
#

@lyric mountain bro

#

have you heard of surrealdb?

lyric mountain
#

nope

sharp geyser
#

its actually kind of sick

#

this is how you'd fetch data between table relations

#

bff.nickname is basically a join

#

but without all the annoying SQL inner join, outer join bullshit

#

it's kind of neat

#

it can also be schemafull or schemaless too

#

or both

lyric mountain
#

it's basically nosql with sql lang then

#

or idk, is it only json?

sharp geyser
#

pretty much

#

you connect to it via WS

#

you send your query and it responds back in json

#

or you can use the rest api

#

like fireship is doing in that screenshot

lament rock
#

SQL join statements arent even that annoying?

sharp geyser
#

It can be in complex relations

#

I've written some pretty annoying join statements since i've learned how to use em

#

mainly because I always get tripped up over INNER/OUTER or RIGHT/LEFT

lament rock
#

SELECT table1.property1, table2.property2 FROM table1 INNER JOIN table2 ON table1.property3 = table2.property3;

sharp geyser
#

My problem is

#

I had times where I was needing data from 2-3 tables all joined in relation

lyric mountain
#

left is always what's left to the JOIN keyword

#

right is what's right

sharp geyser
#

idk

#

I think surreal is rather neat either way

#

it looks promising for what it supposedly offers

lament rock
#

This was a fun query

sharp geyser
#

yea uhm

#

wtf is that

#

😭

lament rock
#

Just to get a playlist's info and its tracks by name

sharp geyser
#

oh wait I was about to ask why you are storing playlist info

#

but its probably custom playlists for users

lament rock
sharp geyser
#

interesting

#

haven't seen many bots do that

lament rock
#

Not all platforms support playlists

#

Plus not all songs are on one platform

sharp geyser
#

true true

#

Also, isn't Amanda pretty big bot?

#

or am I thinking of a diff bot

lament rock
#

Was. She was at 10k before I pulled the plug for personal reasons. She's since restarted but is only at ~100 servers now

#

you're probably thinking of Ayana

sharp geyser
#

Ah ok

#

yea Ayana

sharp geyser
#

idk how much control you have in terms of other kinds of statements you can do like ORDER or COUNT or whatever, but that still seems more convienent than a long INNER JOIN / LEFT JOIN chain

#

its still a fairly new db tbf

lyric mountain
#

what if you need to cross-compare with the same table?

#

I'll use a recent case as example

#
SELECT cd1.id
     , cd1.description AS description_en
     , cd2.description AS description_pt
FROM card_descriptions cd1
INNER JOIN card_descriptions cd2 ON cd1.id = cd2.id AND cd2.locale = 'PT'
WHERE cd1.locale = 'EN'
#

this makes a result like ```
id | description_en | description_pt
blabla1 | | something
blabla2 | translated | somedesc
blabla3 | smth else | abc

sharp geyser
#

Not entirely sure on that one. I myself have just started checking out the docs for it.

#

Im just relaying what i've learned

#

I think its still possible to achieve something like that tho

#

let me check

#

right so

sharp geyser
#

you just have to set a relation

#

RELATE table:id->something->table:id CONTENT {...};
SELECT * FROM table:id->something;
Is the best way I can see how to do it after skimming the docs

lyric mountain
#

that's join with extra steps

sharp geyser
#

yea fair

sharp geyser
#

I like that it's schemaless so when I feel like adding a new field I can simply do so KEKW

sharp geyser
# lyric mountain that's join with extra steps
DEFINE TABLE profile schemafull;
DEFINE FIELD balance ON TABLE profile TYPE number DEFAULT 0;

DEFINE TABLE clan schemafull;
DEFINE FIELD balance ON TABLE profile TYPE number DEFAULT 0;

DEFINE TABLE joined schemafull;
DEFINE FIELD in ON TABLE joined TYPE record<profile>;
DEFINE FIELD out ON TABLE joined TYPE record<clan>;

CREATE profile:1234;
CREATE profile:12345;
CREATE clan:1234;
// We will use graphs to setup relations
// user joins a clan
RELATE profile:1234->joined->clan:1234;
RELATE profile:12345->joined->clan:1234;

// Say we want to fetch all users in a clan
SELECT <-joined<-profile FROM clan;
// Say we wanted to fetch the clan of a user
SELECT ->joined->clan FROM profile:1234;

This is how you'd do relations in SerrealDB if you were to use graphs

lyric mountain
#

that's weird

sharp geyser
#

also to make things unique it gets even weirder

sharp geyser
# lyric mountain that's weird
DEFINE TABLE profile schemafull;
DEFINE INDEX profileUserIndex ON TABLE profile COLUMNS id UNIQUE;
DEFINE FIELD balance ON TABLE profile TYPE number DEFAULT 0;

DEFINE TABLE clan schemafull;
DEFINE INDEX clanIdIndex ON TABLE clan COLUMNS id UNIQUE;
DEFINE FIELD balance ON TABLE profile TYPE number DEFAULT 0;

DEFINE TABLE joined schemafull;
DEFINE FIELD in ON TABLE joined TYPE record<profile>;
DEFINE INDEX joinedProfileIndex ON TABLE joined COLUMNS in UNIQUE;
DEFINE FIELD out ON TABLE joined TYPE record<clan>;

CREATE profile:1234 SET user_id = 1234;
CREATE profile:12345 SET user_id = 1234;
CREATE clan:1234 SET clan_id = 1234;
-- We will use graphs to setup relations
-- user joins a clan
RELATE profile:1234->joined->clan:1234;
RELATE profile:12345->joined->clan:1234;

-- Say we want to fetch all users in a clan
SELECT <-joined<-profile FROM clan;
-- Say we wanted to fetch the clan of a user
SELECT ->joined->clan FROM profile:1234;

This is how you make things unique

#

as far as I know there is no other way as of rn

#

I wonder

#

actually don't even need to specify a separate field for uniqueness

#

you can just use the id field

#

since you can set the id field to whatever you want

little cosmos
sharp geyser
#

I admit I kind of hate the syntax for making fields, kind of dumb you can't do it all in the DEFINE TABLE (as far as I know)

pine willow
grave wharf
#

i break everything

warm imp
#

Do you need a Events folder and a handler folder for your commands you made?

quartz kindle
#

organising code is a matter of personal preference

surreal sage
sharp geyser
#

you expect it to run on power?

surreal sage
#

💔

bitter granite
#

my laptop is hand powered too

sharp geyser
#

my laptop turns on by pressing the button that says power

#

its weird it wont turn on otherwise

crystal wigeon
#

does anyone use contabo?

#

hosting service? i was wondering what machines do they provide. intel or amd? cause i bought a 16gb 6cpu machine and its so slow

deft wolf
#

Have you tried using lscpu command? PepoThink