#development

1 messages ยท Page 1786 of 1

cinder patio
#

what the fuck

pale vessel
#

How could someone make such a thing

opal plank
#

thats what that reminds me of

woeful pike
#

this dude used to work at discord

pale vessel
opal plank
#

clearly a discord dev

crimson vapor
#

probably*

crimson vapor
#

how is the type as bad as that code?

opal plank
#

so wheres the line where an expert can create a massive derp in terms of code

opal plank
#

thats stupid

crimson vapor
#

I think I used that once or twice

opal plank
#

at that point just use [key;string]

crimson vapor
#

just need to check

#

nah I needed typed keys

opal plank
#

import an interface then

crimson vapor
#
export type Language = {
  [key in Array<keyof typeof lang>[number]]: string | LanguageFunction
}
#

ah yes

#

that shit

opal plank
#

mine went ever further

#

in keyof typeof

crimson vapor
#

the best part is that I don't even use that code

#

I think

opal plank
#

also that tilts me a bit

#

ive been taught to use interfaces for objects , and types for primitive derivates

crimson vapor
#

no I do use it pog

opal plank
#

so when someone uses a type for what should be an interface, i tilt a bit

crimson vapor
#

ill fix that right now

#

nvm ts doesn't like me just changing the name

flat copper
#
const languages = {
	auto: 'Automatic',
	af: 'Afrikaans',
	sq: 'Albanian',
	am: 'Amharic',
	ar: 'Arabic',
	hy: 'Armenian',
	az: 'Azerbaijani',
	eu: 'Basque',
	be: 'Belarusian',
	bn: 'Bengali',
	bs: 'Bosnian',
	bg: 'Bulgarian'
}```
```js
const m = await message.channel.send('**Translating.........**');
	const translated = translate(q, { to: lang }).catch(e => {
			message.channel.send({
				embed: {
					title: 'error!',
					description: e.message
				}
			});
		});
console.log(translated)
const l = translated.from.language.iso

		const resEmbed = new Discord.MessageEmbed()
			.setAuthor(
				'Translator',
				client.user.displayAvatarURL({
					size: 512,
					dynamic: true,
					format: 'png'
				})
			)
			.setTitle(`Detected lang : ${languages.l}`)
			.addField('your text!', '```' + q + '```')
			.addField(lang, '```' + translated.text + '```')
			.setColor('RANDOM')
			.setFooter(message.author.username, message.author.displayAvatarURL());
		m.edit('', resEmbed);

Itz showing me detected language undefined

opal plank
#

not because of how bad it is, but its inconsistency

flat copper
opal plank
#
message.channel.send({
                embed: {
                    title: 'error!',
                    description: e.message
                }
            });```
#

you send raw payloads here

#
 const resEmbed = new Discord.MessageEmbed()```
#

but then use builders here

flat copper
#

I mean its working fine

opal plank
#

you also send a new message without returning an error

#

which would in turn continue ur code

flat copper
#

But Detected lang is undefined

opal plank
#

const translated = await translate

#

.catch(() => undefined)

#

if(!translated) return send(error)

#

that should get you the gist of what i mean

#

also the indentation

#

PLEASE use a linter/formatter

flat copper
#
.setTitle(`Detected lang : ${languages.l}`)
#

I mean this

#

How can I get language from isolated code

crimson vapor
flat copper
#

From languages

opal plank
#
const m = await message.channel.send('**Translating.........**');
const translated = translate(q, { to: lang }).catch(e => {
  message.channel.send({
    embed: {
      title: 'error!',
      description: e.message,
    },
  });
});
console.log(translated);
const l = translated.from.language.iso;

const resEmbed = new Discord.MessageEmbed()
  .setAuthor(
    'Translator',
    client.user.displayAvatarURL({
      size: 512,
      dynamic: true,
      format: 'png',
    }),
  )
  .setTitle(`Detected lang : ${languages.l}`)
  .addField('your text!', ' + q + ')
  .addField(lang, ' + translated.text + ')
  .setColor('RANDOM')
  .setFooter(message.author.username, message.author.displayAvatarURL());
m.edit('', resEmbed);```
crimson vapor
opal plank
#

there, now its redable

quartz kindle
#

translated must be awaited

opal plank
#

await it and check if its there afterwards

#

that catch block will just run on its own and let the rest of the code continue

#

you must add a return clause or another scope on an if()

#

if(translated) { rest}

flat copper
#

This ^

quartz kindle
#

we just told you how

flat copper
#

undefined

opal plank
#

you should read our answers

quartz kindle
#

multiple times

opal plank
#

^^

quartz kindle
#

also

#

languages[l] not languages.l

flat copper
#

Thnx for your help

#

To all!

cobalt spruce
#

hi

#

status changing

#

how much time should it be?

#

2min

vivid fulcrum
#

the fastest you can go is every 12s

#

if you want it to be fast, you should probably do every 15-20s

#

otherwise do whatever

feral aspen
#

Heyo.

#
const message = `Hello, the ID is ${}.`;

const id = message.id;

Could I send the ID of the message in the same string itself?

earnest phoenix
cinder patio
#

๐Ÿค” Not sure what you mean? Do you want to store the ID in the string?

opal plank
feral aspen
#

That's possible?

earnest phoenix
feral aspen
#

Works for embeds as well right?

opal plank
#

at least for custom_status. Anything lower than 15 seconds will start to backlog

#

i assume the ratelimit is shared for the other status types

earnest phoenix
feral aspen
#

Oh.. alright!

vivid fulcrum
#

divide 60 by 5 and you'll get the fastest period possible without getting ratelimited

#

12s

opal plank
#

i could've sworn i tested it and the minimum was 15

#

maybe there was delay included

feral aspen
#

Some bots do 5 seconds and whenever I report, I get no response.

opal plank
#

realistically, they dont really care

#

you shouldnt do it

#

but its not like they dont have other issues to attend to

feral aspen
#

I don't for the sake of safety..

opal plank
#

pedos, baiters, hackers, scammers, nitro servers, all taht shit

#

in regards to priority, i assume bots that are just changing their status is quite low

vivid fulcrum
#

in regards to priority, everything is low

#

you have to make a deal with the devil himself in order to talk to an actual human in the support team

#

that is, if the ticket gets answered to in the first place

opal plank
#

i only see truths

#

and it hurts

#

bad

feral aspen
#
let bugChannel = new MessageEmbed()
.setFooter(`Message ID: ${bugChannel.id}`)

(node:8996) UnhandledPromiseRejectionWarning: ReferenceError: Cannot access 'bugChannel' before initialization
#

Bruh, I thought it would work... ๐Ÿ˜

#

.. or is it while sending. ๐Ÿ‘€

opal plank
#

you clearly cant do that

quartz kindle
#

bugChannel is not even a channel? its an embed

opal plank
#

unless you have another variable called it, which then you'd be obfuscating

#

which is a really bad idea

feral aspen
#

Hm..

#

Let me try something.

earnest phoenix
opal plank
#

nah, you can obfuscate shit in js too

#

its a bliss /s

#
client.on('message', message => {
  setTimeout(() => {
    let message = message.content;
  })
})

shit like that

#

now you cant access the original message anymore

quartz kindle
hidden axle
#

How to get diamonds

#

Pls bro tell

opal plank
feral aspen
quartz kindle
#

no

feral aspen
#

What?

quartz kindle
#

it wont work

opal plank
#

you cant use a variable before you define it

quartz kindle
#

you cannot use a variable you are declaring in its own declaration

opal plank
#

i dont think its resonably possible to send a message and know its ID beforehand,. you'd have to do some insane stuff to do that

feral aspen
#

Oh.. how can I make it send the message id in the footer?

quartz kindle
#

you cant

#

you cannot know a message id before the message is created

opal plank
#

message ids are created AFTER you dispatch it(aka u create it)

quartz kindle
#

you need to create/send the message first, then you get its id

opal plank
#

^^

feral aspen
#

Damn..

quartz kindle
#

the only way is to send the message then edit

opal plank
quartz kindle
#

pretty much impossible

feral aspen
#
const m = await message.channel.send("Loading bug details");
await m.edit(embed);
#

.. can I do that?

quartz kindle
#

yes

feral aspen
#

Sweet.

quartz kindle
#

yes

quartz kindle
# opal plank now i wanna see if its fesible to guess a message id before snding it

ids have 3 components, timestamp, instance id and sequence id. good luck:
a. guessing which discord worker will generate it
b. guessing which sequence number it will be by guessing how many other ids were generated in that worker before
c. guessing the exact timestamp that your request will actually reach the worker and be generated

feral aspen
#

That is the final now.

const m = bot.channels.cache.get("758978182807420938").send(`${bughunteremoji} Loading Bug Details...`);

let bugChannel = new MessageEmbed()
.setFooter(`Message ID: ${m.id}`)

await m.edit(bugChannel)
quartz kindle
#

lmao

opal plank
feral aspen
quartz kindle
#

idea: discord lottery bot

woeful pike
#

why do you even need the message id in an embed lol

quartz kindle
#

bet on which message id will be generated

feral aspen
opal plank
#

fair question

woeful pike
#

but why do you need the embed message's OWN id in the embed itself

#

seems completely meaningless

silk ridge
#
const canvacord = require("canvacord");
module.exports = {
    name: 'wanted',
    description: 'wanted',
    execute(client, message, args, database){

      let user = message.mentions.users.first() || message.author;


      let image = canvacord.Canvas.trigger(user.displayAvatarURL({dynamic: false,format: "png"}));

      let newAttachement = new Discord.MessageAttachment(image,"trigger.png")

      message.channel.send(newAttachement)


    }
};```
#

why this canvacord not working?

feral aspen
#

Send the error.

opal plank
#

people really do need to learn how to handle promises tho

flat copper
#

Can I get the message id by replying to someone msg?

feral aspen
#

Ah.. handle the promise in let image = ...

opal plank
#

no, handle the promise as in catch blocks

#

its a promise

#

and it can fail / return errors

#

otherwise you'd have an unhandled rejection

feral aspen
#

I mean they could do that too.

opal plank
#

if ur bot doesnt have permissions to send embeds

#

or send messages

feral aspen
#

Unhandled Rejection..

silk wadi
#

I have this function as to when it is clicked, the text will be deleted:

htag.onclick = function() {
  document.getElementById("subtags").value = x.toString().replace(`,${htag.id}`, "");
  this.remove();

But I want to know exactly what the user has inputted and I'm storing this data in an hidden input:

<input type="hidden" id="subtags" name="subtags">

When the user inputs something, the data is added to this input's value.
So, if I input "Hello", it should look like this:

<input type="hidden" id="subtags" name="subtags" value=",Hello">

And if I type "Bye" afterwards, it should look like this:

<input type="hidden" id="subtags" name="subtags" value=",Hello,Bye">

So my div is looking something like this:

<div>
  <h4 id="Hello">Hello</h4>
  <h4 id="Bye">Bye</h4>
</div>

If I click "Bye", the input's value goes to

<input type="hidden" id="subtags" name="subtags" value=",Hello">

as expected.
But if I click "Hello" instead, the entire value field is deleted when it should be:

<input type="hidden" id="subtags" name="subtags" value=",Bye">

Does anyone know why?
I gtg rn, so if you have an answer pls ping

opal plank
#

or attachment permissions

#

it can error, and quite easily

quartz kindle
feral aspen
#

I see.

silk ridge
#

but....if we do that...

#

the execute...

feral aspen
#

Did I do it wrong? It doesn't edit but sends both. ๐Ÿ˜‚

const m = await bot.channels.cache.get("758978182807420938").send(`${bughunteremoji} Loading Bug Details...`);

let bugChannel = new MessageEmbed()
.setFooter(`Message ID: ${m.id}`)

await m.edit(bugChannel)
flat copper
#
execute: async(client, message, args, db) => {
//code
      }```
silk ridge
#

ok

feral aspen
#

Why 2?

#

What's the difference between await m.edit(bugChannel) and m.edit("", bugChannel), docs is killing me.

flat copper
#

bcz it will edit you msg = null

#

Just try

silk ridge
feral aspen
#

I will try, but I want to understand how that is a difference.

#

m.edit(oof) edits it to the value oof

#

.. but m.edit("", bugChannel) puts an empty string and an embed?

flat copper
#

So.....

#

That's why I think..

feral aspen
#

Oh.

#

I see. ๐Ÿ‘

flat copper
#

If you send embed then just that

silk ridge
quartz kindle
flat copper
#

And code too

quartz kindle
silk ridge
# flat copper Show the error
(node:315) UnhandledPromiseRejectionWarning: TypeError [REQ_RESOURCE_TYPE]: The resource must be a string, Buffer or a valid file stream.
    at Function.resolveFile (/home/runner/HandmadeWetProfile/node_modules/discord.js/src/util/DataResolver.js:135:11)
    at Function.resolveFile (/home/runner/HandmadeWetProfile/node_modules/discord.js/src/structures/APIMessage.js:309:41)
    at /home/runner/HandmadeWetProfile/node_modules/discord.js/src/structures/APIMessage.js:241:72
    at Array.map (<anonymous>)
Fontconfig error: Cannot load default config file
Promise { <pending> }
Hint: hit control+c anytime to enter REPL.
Listening on 3003
Init Complete, Crowny Bot is online
Bot came online on 19|06|2021 16:49
(node:529) UnhandledPromiseRejectionWarning: TypeError [REQ_RESOURCE_TYPE]: The resource must be a string, Buffer or a valid file stream.
    at Function.resolveFile (/home/runner/HandmadeWetProfile/node_modules/discord.js/src/util/DataResolver.js:135:11)
    at Function.resolveFile (/home/runner/HandmadeWetProfile/node_modules/discord.js/src/structures/APIMessage.js:309:41)
    at /home/runner/HandmadeWetProfile/node_modules/discord.js/src/structures/APIMessage.js:241:72
    at Array.map (<anonymous>)
    at APIMessage.resolveFiles (/home/runner/HandmadeWetProfile/node_modules/discord.js/src/structures/APIMessage.js:241:46)
    at ExtendedTextChannel.send (/home/runner/HandmadeWetProfile/node_modules/discord-buttons/src/v12/Classes/TextChannel.js:26:50)
    at Object.execute (/home/runner/HandmadeWetProfile/Commands/Fun/wanter.js:15:23)
    at /home/runner/HandmadeWetProfile/index.js:87:32
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:529) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:529) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
quartz kindle
#

you're trying to send invalid data

silk ridge
flat copper
#

Code?

silk ridge
#
const canvacord = require("canvacord");
module.exports = {
    name: 'wanted',
    description: 'wanted',
    run: async (client, message, args, database) => {

      let user = message.mentions.users.first() || message.author;


      let image = canvacord.Canvas.trigger(user.displayAvatarURL({dynamic: false,format: "png"}));

      let newAttachement = new Discord.MessageAttachment(image,"trigger.png")

      message.channel.send(newAttachement)


    }
};```
flat copper
#
let image = await canvacord.canvas.trigger(user.displayAvatarURL())```
silk ridge
#
const canvacord = require("canvacord");
module.exports = {
    name: 'wanted',
    description: 'wanted',
    run: async (client, message, args, database) => {

      let user = message.mentions.users.first() || message.author;


      let image = await canvacord.Canvas.trigger(user.displayAvatarURL({dynamic: false,format: "png"}));

      let newAttachement = new Discord.MessageAttachment(image,"trigger.png")

      message.channel.send(newAttachement)


    }
};```
flat copper
#

Now try?

silk ridge
flat copper
#

Use execute

#

Not run

#
const Discord = require('discord.js');
const canvacord = require("canvacord");
module.exports = {
    name: 'wanted',
    description: 'wanted',
    execute: async (client, message, args, database) => {

      let user = message.mentions.users.first() || message.author;


      let image = await canvacord.Canvas.trigger(user.displayAvatarURL({dynamic: false,format: "png"}));

      let newAttachement = new Discord.MessageAttachment(image,"trigger.png")

      message.channel.send(newAttachement)


    }
};
silk ridge
flat copper
#

Try

silk wadi
#

tho

#

the variables ive set

#

is already to document.getElementById("subtags").value

flat copper
silk ridge
#

nvm i fixed !

silk ridge
flat copper
silk ridge
silk ridge
earnest phoenix
#

i am trying to make music bot

#

but something went wrong

#

just read the error fam

eternal osprey
#

log that first

#

above the ytld.find

earnest phoenix
#

umm

#

Im not sure what to do

earnest phoenix
nova basin
#

Help me please for HTML

#

Actually I had made this script for the description in the bots lists I used on top.gg it worked correctly I wanted to put it in the description in other bot list and it does not work anymore

quartz kindle
#

if this is for another bot list, you'll have to ask there

last tapir
#

hi tim ๐Ÿ‘‹

#

hope you are having a great day

feral aspen
#

I have a message ID.. and I want to use that message ID to edit the message that is in there.. is that possible?

#
const m = await message.channel.send(`This is a message`);
const ID = m.id;

// Using ID to get the message and edit that, is that possible?
#

.. maybe fetch()?

hot sage
#

is there a simple way to use hex codes for the embeds color in python?

#

i swear there was but I can't remember

sudden geyser
#

You can convert the hex string (e.g. FFFFFF) to an int with int(hex, 16).

#

It seems like there's no set_color/add_field method on an discord.Embed instance, so you'll need to construct the embed manually.

#

e.g.

embed = discord.Embed(color=int(hex, 16))

@hot sage

hot sage
#

ok

#

ty

feral aspen
mild agate
#

F... edited

feral aspen
#

bot.channel.messages.cache.get(id)?

mild agate
#

No

#

message.channel

feral aspen
#

.. in a normal command.

sudden geyser
#

If you want to fetch if the channel or message isn't in the cache, use fetch instead of get and resolve the promises beforehand.

feral aspen
#

What's <guild> for, though?

#

I am doing this in a normal command not in an event.

sudden geyser
#

It represents a guild instance (e.g. message.guild). If you already have the channel instance, you won't need to get/fetch the channel (e.g. message.channel.messages.cache.get(...).edit(...))

feral aspen
#

Ah. Let me try..

#

message.guild.channels.cache.get("...").messages.cache.get("...").edit()

pulsar spade
#

can anyone help me with - <coroutine object Command.call at 0x7f13adf6e5c0>

sudden geyser
#

You probably forgot to await a coroutine.

pulsar spade
#

@client.command()
async def sum(ctx, x: float, y: float):
#plus = sum(x , y)

embed = discord.Embed(title='Sum', description = sum(x,y) , color = (0xF85252))
await ctx.send(embed = embed) #new 2

#

code

sudden geyser
#

Why are you calling the sum command again?

pulsar spade
#

idk i was just testing out

#

it was not working from first time

sudden geyser
#

If you want to add two numbers together, just use the + operator.

hot sage
#

i am confused as to why i am getting a syntax error here

pulsar spade
#

i know that but i made .py for some math operation

sudden geyser
sudden geyser
hot sage
sudden geyser
#

Oh

#

It's with the int(...) thingy

pulsar spade
#

yes'

sudden geyser
# hot sage invalid syntax*
  1. That's not a string. You just made a comment resulting in your syntax error.
  2. You shouldn't have # in your input, so it should just be 2555AC (but as a string)
pulsar spade
#

i did call all the function on main but it's not working on embed

sudden geyser
#

That's because you have a name conflict. You want to call a sum function defined elsewhere but the command has the same function name. You could either have the sum function defined in another file and add its namespace before it, or you could rename your sum function while explicitly setting the command name.

# Second approach
@client.command(name="sum")
async def _sum(ctx, x: float, y: float):
  pass # Call `sum` function since it doesn't conflict
#

@pulsar spade

pulsar spade
#

because this -->

#

def sum(x: float, y: float):
return x + y # -> plus

sudden geyser
#

Yes, so use one of the solutions as it will still work.

pulsar spade
#

ok i see

#

let me test

#

@sudden geyser Thank you it solved

earnest phoenix
#

Someone knows how to do reaction menu?

#

I've been searching for it for days but couldnt find any guide

long crow
#

Hi, hello.. for documentation purpose, how can I document this? url,title.. are still saying any

sudden geyser
#

You're expecting an object with all those fields/methods.

slender thistle
#

I'm literally not sure why you would re-define built-in sum with a function that literally does the same thing

hot sage
#

why is this an invalid syntax? am i this dumb?

sudden geyser
#

missing comma

hot sage
#

where

sudden geyser
#

try looking for it

hot sage
#

i am blind wtf

zenith terrace
#

idk how you dont see it

feral aspen
#
await message.guild.channels.cache.get("758978182807420938").messages.cache.get(bughunter.bugs.find(key => key.id === bugID - 1).messageID).edit(embed);

(node:5388) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'edit' of undefined
// bughunter.bugs.find(key => key.id === bugID - 1).messageID is equal to the message ID.
#

Not sure why it's not working.

sudden geyser
#

the message wasn't found in the cache

hot sage
feral aspen
#

That's a shame for my bot. ๐Ÿ˜‚

sudden geyser
#

if you know the message should exist use fetch instead

#

it'll look in the cache first and send an http request if it wasn't found

feral aspen
#

Could you show me an example on how I can use it, no spoonfeeding.

#

Suppose I have a message ID as 855811790218068009

feral aspen
sudden geyser
#
let channel = message.guild.channels.cache.get("123456789");
let messageID = bughunter.bugs.find(key => key.id === bugID - 1).messageID;
let message = await channel.messages.fetch(messageID); // Will throw if it still wasn't found.
feral aspen
#

Hm..

#
await message.guild.channels.cache.get("758978182807420938").messages.fetch(bughunter.bugs.find(key => key.id === bugID - 1).messageID).edit()
#

Let me try that.

sudden geyser
#

won't work since fetch returns a promise

hot sage
sudden geyser
#

did you find it?

hot sage
#

;-;

#

i found it

#

but i am dumb

feral aspen
sudden geyser
#

Nah, that's just more reason to learn

hot sage
#

how did it take me ~10 minutes to find that

feral aspen
#

Why should I make a variable for this change, though?

flat copper
#

How can I get msg id by replying to the user?

sudden geyser
#

I'd rather have a variable, wrap it in a try catch block, and have my message instance from there

feral aspen
#

Ahh.. alright, let me try.

feral aspen
#

Bruh, I fix something and get another error, I fix the other error, AND ANOTHER ERROR.

#

Tf does this even mean.

(node:3724) UnhandledPromiseRejectionWarning: TypeError: (intermediate value).setColor(...).setAuthor(...).setAuthor(...).setTitle(...).addField(...).addField(...).addField(...).addField(...).setFooter(...).setTimestamp(...) is not a function
#

I literally just fixed my issue.. but that shows up.

sudden geyser
#

means you tried calling a function that doesn't exist

feral aspen
#
(await message.guild.channels.cache.get("758978182807420938").messages.fetch(bughunter.bugs.find(key => key.id === bugID - 1).messageID)).edit("", embed);

I did this.. got the channel.. fetched for the message ID to edit it.

hot sage
#

this looks extremely messy, and kinda hard to read. How can i change it to seem less like i copied a list and pasted it in?

hot sage
feral aspen
#

Make each value a value.

hot sage
#

ok

feral aspen
#

Maybe put the words in an array and map them with the .join(", "), not sure how you do it in python.

flat copper
#

@feral aspen attitude is your bot?

feral aspen
#

Yes.

flat copper
#

Ooo
I saw that in WBL

feral aspen
#

:D

#

Just trying to solve an issue.. ๐Ÿ˜

solemn jolt
#

I wanna good host for discord.js

hot sage
#

nvm

#

there isnt a pinned list i dont think

#

oh wait

#

yes

solemn jolt
#

I wanna free host

hot sage
#

this

hot sage
#

uh

lusty quest
#

free doesnt exist, you pay in some way

hot sage
#

idk what to tell you then

#

i mean, repl.it is mediocre, but it kinda works

lusty quest
#

but one of the so called "free" hosts are repl.it

solemn jolt
#

If you now one exist tell me

feral aspen
solemn jolt
#

Repl.it is bad for code i use github for edit

lusty quest
#

rip using github as IDE

sudden geyser
#

there's also google cloud shell

solemn jolt
lusty quest
#

github is mostly a Versioning system and code sharing platform

sudden geyser
#

Can you install an editor like Visual Studio Code in your environment?

lusty quest
#

if you want to have the proper experience get a decent Code editor like Visual studio code and get git

#

so you can write the code in a proper code editor, and just upload it to github

solemn jolt
lusty quest
#

thats a big RIP

solemn jolt
#

I now

long crow
long crow
#

I need to practice more on documenting my codes

sudden geyser
#

JSDoc sucks anyway

long crow
#

Not really sure how to on this one

vale garden
#

hi

#

does anyone know

#

if its possible to make a command, which is used to make custom commands

#

with their own name, description, functionality and stuff

long crow
#

^ban plox

#

oops

long crow
vale garden
#

like a command, which allows the creation of new commands

#

ive seen it on a bot before

#

but ive never seen the feature on any tutorials, github repos or anything

cinder patio
#

use your imagination and knowledge there isn't a tutorial for everything

#

it is possible yeah if that's all you need to know

lusty quest
#

if you need some hints, there is a bot that does it on github

earnest phoenix
lusty quest
#

wont work bcs the bot uses a lib that maybe 8 people on this planet use

earnest phoenix
#

Detritus? Kapp

lusty quest
#

ye

slender thistle
lusty quest
#

the docs will become better soon, so more people eventually adopt it, since it allows much more flexible scaling than d.js

earnest phoenix
#

If erwin was paid to talk about detritus and shit on d.js, he would be a billionaire now

lusty quest
#

well he just tells the truth tbh

earnest phoenix
#

yea

lusty quest
#

after using it for like 3 weeks i can say it does way much stuff so much better than d.js

#

sure there are still missing important features, but the lib overall is relatively new

earnest phoenix
#

Honestly the only thing its missing is a d.js-like documentation

lusty quest
#

and some small stuff like a debug event and better errors for certain stuff

stiff lynx
#

If I give the clientID of my bot can be hacked?

solemn latch
#

no, clientid is a public number

stiff lynx
#

so no risks

#

only with token'

solemn latch
#

this is @gilded plank's id 264811613708746752

stiff lynx
#

?

lusty quest
#

only the token is risky (also badly secured servers, databases)

solemn latch
#

anyone can get your bots id, as its public

stiff lynx
#

so if I give my client ID for a bot website I dont risk anything

earnest phoenix
#

2 risky things: client token, client secret

earnest phoenix
solemn latch
#

I mean the invite url for your bot has to contain the client id. every bot ever has to share its id.

stiff lynx
#

I have another question, I want to do commands in private messages. Where I found it in the docs?

earnest phoenix
#

You mean ephemeral messages?

#

If so you gotta use slash-commands

stiff lynx
#

Can I denounce someone for copying my commands?

#

and my ideas?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

latent heron
#

why would you even do that?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

latent heron
#

are we trying to bring twitter cancel culture logic to Discord bot communities now?

summer torrent
#

what is that flow

latent heron
#

and since when did you own the rights to ideas of commands?

#

that's stupid

sage bobcat
#

One message removed from a suspended account.

latent heron
#

that's not even the concern

sage bobcat
#

One message removed from a suspended account.

latent heron
#

it's acting like you have intellectual ownership of a command

#

that gets me

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

latent heron
#

it's a horrible idea

#

and it'd also make you a shitty person to be petty and denounce people for making a bot similar to yours in concept

#

you don't see Mee6 devs trying to denounce Miki for copying their similarity?

sage bobcat
#

One message removed from a suspended account.

latent heron
#

or really any bot dev

sage bobcat
#

One message removed from a suspended account.

latent heron
#

they still share similarity

sage bobcat
#

One message removed from a suspended account.

latent heron
#

it doesn't matter how similar they are

#

it really doesn't

#

i could denounce someone for copying the idea of my bot

#

that's what is being suggested here

#

@slender thistle i've got a good amount of the source code of my bot rewritten

#

i can share it with you today

slender thistle
#

Do you still need help with it btw KEKW

long crow
#

can I denounce all those music bot? KEKW

vale garden
#

it might be annoying when a beginner has a really good idea

sage bobcat
#

One message removed from a suspended account.

vale garden
#

who has never made bots

worn sonnet
#

Oh bot fights?

vale garden
sage bobcat
#

One message removed from a suspended account.

vale garden
#

then what is it

#

tell me

worn sonnet
#

Stand down I'm a bot Dev too now

sage bobcat
#

One message removed from a suspended account.

worn sonnet
vale garden
#

thats another point

#

but the first one is true as well

#

also mee6 is pretty mundane and normal lol

#

it doesnt have any unique features

worn sonnet
#

They are popular just cuz of their dashboard I guess

sudden geyser
#

most (90-95%) bots don't have unique features

worn sonnet
#

I fall in those 90-95%

vale garden
sudden geyser
#

probably

#

if your bot is multipurpose it usually falls in there

worn sonnet
#

But I've got a feature to gray-scale images

#

Or make GIFs from given images

sage bobcat
#

One message removed from a suspended account.

slender thistle
sudden geyser
#

bots probably just slap on mit/apache license anyway

lusty quest
#

copyrights are expensive af tho, iirc its like 300-1kโ‚ฌ/month here

worn sonnet
#

And no doubt this guy @slender thistle helped me a lot whenever I do silly syntax errors

worn sonnet
hot sage
#

i found this when looking for how i can make an array in python. I wanted to know how I could use/implement this into an added field, as a value. So, I want an array, for a value, but I dont know how I can do this/if i can use this

worn sonnet
#

I'm just dumb enough I don't understand the question you asked

hot sage
#

i worded it horribly lmao

#

so

near stratus
#

It's a slash command I'm using

hot sage
#

i want, an array in a field of a discord embed

#

and i didn't know if i could use something like the above ss

near stratus
#

Update Discord

worn sonnet
hot sage
#

ok

#

how exactly

worn sonnet
#

You want array in field value right?

#

Use f-string?

hot sage
#

ok

#

yeah

worn sonnet
#

Or u can decorate it with string formatting

inland oracle
#

how do i make the logo of my bot hover on the page? could i have an example please

slender thistle
hot sage
#

the code to the above is this

slender thistle
#

See: str.join

#
>>> timeit.timeit('""')
0.009867799999998539
>>> timeit.timeit('str()')
0.08838610000000102

huh

near stratus
hot sage
#

yes

flat copper
near stratus
hot sage
#

lmao

sage bobcat
#

One message removed from a suspended account.

rocky hearth
#

~~Guyz, I want to convert the type Awesome to MoreAwesome. ~~
Basically I just want to remove the first parameter.

type Awesome = {
  fun1: (a: A, b: B) => void
  fun2: (a: A, b?: B) => void
  fun3: (a: A) => void
}

type MoreAwesome = {
  fun1: (b: B) => void
  fun2: (b?: B) => void
  fun3: () => void
}

nvm, I accomplished that by doing,

type MoreAwesome = {
  [Key in keyof Awesome]: (payload: Parameters<Awesome[Key]>[1]) => void
}
earnest phoenix
#

hi

rustic nova
#

@earnest phoenix don't advertise please

earnest phoenix
#

where can i

sudden geyser
#

No where!

rocky hearth
#

google ads maybe

latent heron
#

@slender thistle are you busy rn?

slender thistle
#

Err.... yes and no

sinful thistle
#

I see you

slender thistle
#

Just working on random stuff

latent heron
#

can you join general vc

#

im streaming the new source code for the bot

#

i wanna show you how i currently got it set up

scenic kelp
slender thistle
#

DICT() MMMM

#

MMMMMMMMMMMMMMMMMMMMMMMMMMMM.

#

JUST HAVE PYCHARM CONVERT THEM TO DICT LITERALS

#

BRO

#

aye fuck you too :D

sage bobcat
slender thistle
#

LMFAO

#

We do talk about dict method

#

ok but why save the command data in a json file

#

Why not move to bot dev vc bro

#

oh well

#

that works too

#

The way speedian does it is store commands in a CommandHandler

#

which seems cleaner to me

#

@rustic nova scam link

#

Ok but like

#

Why in a file specifically?

#

Ah

#

noice

#

Neat

#

Now, about the dict functions...

#

KEKW it looks UGLY BROOOOO

#

oh yeah true

#

#UseMongo

#

speak of the devil

#

I forgot to reinstall it

#

lazy ass smh

#

lmfao

#

sorta

#

Pain of reading rST format instead of Numpy

#

KEKW it's okay

boreal iron
#

Pain of

#

reading

#

Each

#

Word

#

In

#

A

#

New

slender thistle
#

__init__ shouldn't even return anything

boreal iron
#

Line

slender thistle
#

Nice KEKW

boreal iron
#

shame on you

slender thistle
#

Just slap an aiohttp request in an asyncio.run_until_complete ezpz

#

ah

pale vessel
#

Just unmute ez

slender thistle
#

nah

pale vessel
#

Skill issue

slender thistle
#

Laziness

#

Could give it a try since it doesn't seem all that bad unlike speedian's codebase

#

kekw

#

bless your soul

#

heh

#

aye

rustic nova
#

heck is thi

crimson vapor
#

yes

slender thistle
#

How the fuck am I getting tuples as dict keys

cobalt spruce
#

oi

slender thistle
#

Turns out I was creating another unnecessary list

latent heron
plain edge
wise quartz
#

How to check if someone actually voted for my bot?

wise quartz
#

Can you explain more?

#

Oh nvm someone gave a link on the other channel

#

Ty

slender thistle
wheat mesa
#

dear god I love youtubers who have nice UI tutorials

#

I love this look

sudden geyser
#

wish the sidebar was on the trailing edge

wise quartz
#

What should my webhook url be??

wheat mesa
sudden geyser
#

aka the right edge

wheat mesa
#

Meh

#

Seems a little small

#

Even if I moved it over it just seems just up to preference

sudden geyser
#

Imo it looks better on larger screens

wise quartz
#

Guys please any help?????

wheat mesa
sudden geyser
#

But it's still pretty big. It's not even centered or aligned with anything!

wheat mesa
sudden geyser
#

still big

wheat mesa
#

Iโ€™ll make it smaller

#

compresses your bot

lyric mountain
wise quartz
lyric mountain
#

Literally

#

You're the one creating the endpoint

#

So it's anything you want

prime mist
#

Just make it /webhook. Done.

#

Next question please.

wheat mesa
#

Iโ€™ve been pinged

lyric mountain
#

Ye, by unicode

wise quartz
#

Ok so now that the webhook url is set... what do i do?

#

Cuz i literally dont know anythin

#

How do i check if the user voted

#

Like does anyone have examples?

wheat mesa
unkempt wedge
#

wtf

#

client.login just isn't working?

#

anyone have any idea why? client.login should be the most basic thing of djs but its not working even though this script has been unchanged for 1 day and just now is acting up...

#

im so fucking confused

#

maybe it has to do with repl

wheat mesa
#

@unkempt wedge show your code and the error you're getting?

unkempt wedge
#
const Discord = require("discord.js");
const client = new Discord.Client();
const WOKCommands = require('wokcommands');
const mongo = require("./mongo")
const mongoose = require('mongoose')
require('dotenv').config()

// Hopefully REPL Stuff
const express = require('express');
const app = express();
const port = 3000;

app.get('/', (req, res) => res.send('Hello World!'));

app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`));
// End of REPL stuff



botVersion = "1.0.0"
mode = "normal"
module.exports = botVersion, mode

client.on('ready', async () => {
    console.log('ready')
    mongoose.set('useFindAndModify', false);
    client.user.setActivity("S.A.M.! stonks?setup\n Need help? there was an inivte here i removed", { type: "PLAYING"});
    new WOKCommands(client, {
        commandsDir: 'commands',
        featureDir: 'features'
    }).setDefaultPrefix('stonks?').setMongoPath(process.env['mongoPath'])

    await mongo().then(mongoose => {
        try{
            console.log("Connected to mongo!")
        }
        finally{
            mongoose.connection.close()
        }
    })
})

client.login(process.env.token)```
fresh verge
#

Do Bots have the 4000 character limit, or does it still only have the 2000 character limit?

unkempt wedge
#

FUCK I PUT A STATUS WITH AN INVITE

crimson vapor
fresh verge
unkempt wedge
#

thats why you dont copy code without looking through it kids

fresh verge
#

Ikr.

sudden geyser
#

I tried writing a long suggestion today and I think I went over the 2k limit but the bot was able to image it. Sent it in an embed as 2010 characters; unsure

wheat mesa
#

embeds have 4k limit I believe

zenith terrace
#

no they do not

sudden geyser
#

It's 2048

zenith terrace
#

bots only have a limit of 2k as well

#

not 4k

tender raft
#

I'm so happy my discord bot got approved!

sudden geyser
#

congrats

crystal furnace
#

hey

#

how to get total stats of all shard ( like users in shard 1 + users in shard 2 = total users)

lusty quest
#

run a loop over the shards, get the users per shard and just add up the users

crystal furnace
#

clearly

#

i am noob at this

lusty quest
#
    if (shardCount === client.config.shards - 1) {

      let guildCount = 0;
      let userCount = 0;
      let memberCount = 0;
      let totalUsers = 0;
      let channelCount = 0;

      for (const shard of (client.client as ClusterClient).shards.values()) {
        guildCount += shard.guilds.size;
        userCount += shard.users.size;

        for (const guild of shard.guilds.values()) {
          memberCount += guild.members.size;
          totalUsers += guild.memberCount;
        }

        channelCount += shard.channels.size;
      }

      console.log(
        'Bot is ready!\n' +
          'Loaded with:\n' +
          `cached users: ${userCount}\n` +
          `total users: ${totalUsers}\n` +
          `cached channels: ${channelCount}\n` +
          `cached members: ${memberCount}\n` +
          `cached guilds: ${guildCount}`,
      );
    } else shardCount++;
  },
``` one way to do it
crystal furnace
#

your code ?

#

thank you

lusty quest
#

will not work with d.js tho

crystal furnace
lusty quest
#

bcs its not d.js

crystal furnace
#

ahhhhh

lusty quest
#

you didnt specified anything so i just pick a random lib and language and give a example

crystal furnace
#

how to do with discord.js i mean

crystal furnace
#

i mean in discord.js

lusty quest
crystal furnace
#

give me the link of documentary

#

=)))

lusty quest
#

ShardingManager.shards gives you a collection of shards, just loop over them and get the member count per guild

crystal furnace
#

my sister will be happy =)))

#

i'm code the bot with her

untold token
#

that seems awfully long

#

im pretty sure there's an alternative

#

for one thing, broadcastEval exists and im pretty sure its for this exact reason

#

fetchClientValues as well

lusty quest
#

in Detritus broadcastEval is not a thing

untold token
#

this is discord.js

lusty quest
#

since he doesnt specify anything i usually just grab a random lib and give examples

untold token
#

he did specify discord.js

near stratus
lusty quest
#

me?

#

bcs its way better than d.js

near stratus
lusty quest
#

like you can scale it way easier

#

and you can define caches pretty good with an TTL

untold token
#

im not sure how to use it exactly but i'd at least give it a shot before writing a big messy thing like that

#

it would do the job, yes, but there's an easier way

vale garden
#

hi

vale garden
pale vessel
#

The "other" discord lib

vale garden
#

js?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

vale garden
#

oh kk

#

oh damn

#

i just checked it out

#

it seems a lot better than discord.s

#

*js

#

anyways i use py so im not gonna be switching to it anytime soon

opal plank
near stratus
#

fu

near stratus
opal plank
vale garden
#

yeah

opal plank
wheat mesa
#

Quick question

#

Are you old enough for discord per their TOS?

#

What?

opal plank
lusty quest
#

also found the example faster than for Selenium

opal plank
#

im gonna be VERY honest, it can have some nice optimizations

#

my code isnt as pristine as it should

#

but thats mainly for the sake of readability

#

i could shave off some startup time with some preset configs

#

but thats not that big of a deal, the main point of the repo is just to show how to do a decent bot

lusty quest
#

having some fancy logging is nice, sure no one will see it, but it can sort of help in certain situations

flat copper
#

What is the latest version of djs

sick agate
#

13 beta
12 fully released

sly sierra
#

but yea

flat copper
#

So button is available in 12 right?

lusty quest
#

d.js? no will be with V13, but there is a other npm package for it

flat copper
#

Ooo

near stratus
sick agate
#

Erwin being Erwin

lusty quest
#

atleast they have sort of out of the box Button support, even tho its made by someone else

opal plank
opal plank
# opal plank

also funfact, lib devs have access to those new things months before they are released, d.js legit had about 3 months to add buttons, and yet hasnt done shit. Every single major lib out there already had buttons before or within the first week

#

shamefull

lusty quest
#

but they have a easy way for buttons. and you dont need to reinvent the wheel to do so

opal plank
#

still kinky that they havent added it while they had so much time to do so

eternal elbow
#

Hi, I have a little problem. I'm trying to pull the user's servers from discord.com/api/users/@me/guilds, but I'm getting a 401 unauthorized error, I'm using the access token from passport-discord as an access token and I've tried a lot but still can't succeed. Can you explain step by step or tell me the problem?

opal plank
#

idk how passport does it

eternal elbow
lusty quest
#

did you use oAuth?

opal plank
earnest phoenix
eternal elbow
opal plank
#

what you receive from the oauth needs to be autehnticated first

#

so you get the actual "usable" token, per se

#

the path is the following

lusty quest
#

you get 2 tokens iirc, one for authentification and one for refreshing the token

#

just make sure you send the correct one

opal plank
#

oauth => get token => exchange token for access_token => use the access_token for whatever you need

near stratus
# opal plank
class InteractionMessage {
    constructor (client, interaction, readonly){
        this._client = client;
        this._interaction = interaction;
        if(!readonly){
            this._message = { data: {
                type: 4,
                data: {
                    content: "",
                    embeds: [],
                    components: []
                }
            }}
        } else {
            this._message = { data: {
                type: 4,
                data: {
                    flags: 64,
                    content: "",
                    embeds: [],
                    components: []
                }
            }}
        }
    }
    send(){
        this._client.api.interactions(this._interaction.id, this._interaction.token).callback.post(this._message);
    }
    setContent(messageString){
        this._message.data.data.content = messageString;
    }
    addEmbed(embed){
        this._message.data.data.embeds.push(embed);
    }
    addButton(buttonObj){
        let a = 0;
        while(true){
            if(!this._message.data.data.components[a]){
                this._message.data.data.components.push({
                    type: 1,
                    components: []
                });
            }
            if(this._message.data.data.components[a].components.length >= 5){
                a ++;
            }else{
                break;
            }
        }
        if(a >= 5){
            console.log("maximum number of buttons reached");
        }else{
            this._message.data.data.components[a].components.push(buttonObj);
        }
    }
}

and

const Button = (name, id, style) => {
    if(!style){
        style = 1;
    }
    let _buttonObj;
    
    if(style !== 5){
        _buttonObj = {
            type: 2,
            label: name,
            style: style,
            custom_id: id
        }
    }else {
        _buttonObj = {
            type: 2,
            label: name,
            style: 5,
            url: id
        }
    }
    return(_buttonObj);
}
eternal elbow
stiff lynx
#

guys, I would like to do a command in the bot DM, but I dont find anything in docs, anyone that can help me? at least the docs page link

lusty quest
#

check if the channel type is DM

lusty quest
#

but be aware DMs are annoying to handle

stiff lynx
lusty quest
#

since you dont have direct access to stuff like guilds

eternal elbow
near stratus
eternal elbow
#

@opal plank one more question

opal plank
#

imagine having to use the raw api cuz the lib didnt update it after 3 months

opal plank
eternal elbow
# opal plank sup

Do I need to do oauth2 again and again. Does this accesstoken I get have a validity period?

stiff lynx
near stratus
lusty quest
#

like i said you get 2

opal plank
eternal elbow
#

okay i'm listening

lusty quest
near stratus
lusty quest
#

i know

stiff lynx
#

so I do the command and then I check if channel === 'DM'

opal plank
#

a new user auths => you get sent a code in the headers => you use that code in the /authorize endpoint, that'll give you both a refresh token and the token you'll be using

#

remember, it has an expiry amount of time

opal plank
#

unless d.js is retarded, which it might be uppercased

stiff lynx
#

I'm confused, lowercase or uppercase?

opal plank
#

and not channel

#

channel.type

eternal elbow
opal plank
#

lowecase most likely

opal plank
#

once you got the token, you're good

#

but dont mistake the 2 things you'll use

#

forget about refresh token

#

thats just to regenerate a new token for you

#

you likely wont be using it

#

your only 2 concerns are not mistaking the code you receive from oauth with the token you get from the /authorize endpoint

eternal elbow
#

Did I get right

near stratus
#

you don't need the refresh token
it's pretty much useless most of the time

eternal elbow
#

Ok, I'll check them out and try again, thank you very much.

opal plank
#

no problomo

#

who ghost ponged me

eternal elbow
#

I asked a question but realized it was in the docs๐Ÿ˜…

opal plank
#

oh, aight

slender thistle
#

Dash is making me go crazy istg

eternal elbow
#
fetch("https://discord.com/api/v8/oauth2/token", {
            method: "POST",
            body: {
                'client_id': process.env.CLIENT_ID,
                'client_secret': process.env.CLIENT_SECRET,
                'grant_type': 'refresh_token',
                'refresh_token': "my_refresh_token"
            },
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        }).then(res => res.json())
            .then(json => console.log(json));


{
error: 'unsupported_grant_type',
error_description: 'Grant type None is not supported'
}

Why is this happening? @opal plank

near stratus
#

and it works somehow

stiff lynx
#

if(!channel.type === 'DM') return

#

like this for checking if this is a direct message?

#

because channel is not defined

queen hemlock
#

nani is going on

#

is this a webhoock

prime mist
stiff lynx
prime mist
#

If you are using discord.js then I can't help you :)

stiff lynx
#

ty same

prime mist
#

What library are you using then?

opal plank
stiff lynx
crystal furnace
#
client.on('ready',() => {
//client.shard.fetchClientValues('guilds.cache.size')
const promises = [
client.shard.broadcastEval('this.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)'),
client.shard.fetchClientValues('guilds.cache.size'),
//client.shard.broadcastEval('this.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)','this.guilds.cache.reduce((acc, guild) => acc + guild.guildCount, 0)')
//client.shard.broadcastEval('this.guilds.cache.reduce((acc, guild) => acc + guild.GuildCount, 0)')
];

return Promise.all(promises)
.then(results => {
    //console.log(`Total member count: ${results.reduce((acc, memberCount) => acc + memberCount, 0)}`);



    //console.log(`stats ${client.users.cache.size}Users(turnoffdata),${client.channels.cache.size}Channels,${client.guilds.cache.size} Servers!`);//
console.log(`This SHARD is running with 
${client.guilds.cache.reduce((a, b) => a + b.memberCount, 0)} Users 
${client.channels.cache.size} Channels 
${client.guilds.cache.size} Servers
---------------------------------------------
`)
console.log(`TOTAL (current):
${results[1].reduce((acc, guildCount) => acc + guildCount, 0)} total guilds
${results[0].reduce((acc, memberCount) => acc + memberCount, 0)} total members `)

})

.catch(console.error);
#

Launched shard 1
Error [SHARDING_IN_PROCESS]: Shards are still being spawned.
at ShardingManager.fetchClientValues (C:\Users\Win10\Desktop\bot3 - Copy\node_modules\discord.js\src\sharding\ShardingManager.js:248:75)
at Shard._handleMessage (C:\Users\Win10\Desktop\bot3 - Copy\node_modules\discord.js\src\sharding\Shard.js:326:22)
at ChildProcess.emit (events.js:387:35)
at emit (internal/child_process.js:910:12)
at processTicksAndRejections (internal/process/task_queues.js:83:21)
Launched shard 2
This SHARD is running with
8 Users
14 Channels
2 Servers

TOTAL (current):
5 total guilds
36 total members

#

???

#

why error

stiff lynx
opal plank
stiff lynx
#

I know that I have to define channel, but in this case I dont know how

stiff lynx
#

but I already know how to define an object or a variable

opal plank
#

which is why i sent you those 3 docs

prime mist
crystal furnace
#

lol why no one help me =)))

opal plank
crystal furnace
#

hmmm

#

it's so not important

opal plank
#

i use detritusjs, not discordjs

crystal furnace
#

because this is console log

stiff lynx
near stratus
stiff lynx
prime mist
#

broadcastEval? What a scary sounding monster. What has discord.js done?

queen hemlock
#

wait does my bot need to get approved to get the Bot dev role

queen hemlock
#

ok

opal plank
#

i never understood why their cluster manager doesnt have access to the children

#

for example, rather than ts Manager.broadcastEval('return this.guilds.cache.size')
do

<Manager>.shards.map(s => s.guilds.cache.size)```
prime mist
prime mist
opal plank
quartz kindle
#

your code is running twice, once in each shard

#

the first time it runs, only the first shard is ready, the second is not

#

thats why the error

crystal furnace
#

oh but still thank to you Tim

crystal furnace
#

@quartz kindle

#

the code is oke

#

but why error still exist

crystal furnace
#

but

#

oh what ever this is not important

quartz kindle
#

check which shard it is

#

and only run it on the last shard

#

or catch the error

crystal furnace
#

catch the error is better

#

client.on('ready', () => {

//console.log(stats ${client.users.cache.size}Users(turnoffdata),${client.channels.cache.size}Channels,${client.guilds.cache.size} Servers!);//
console.log(This SHARD (${shard.id +1}) is running with ${client.guilds.cache.reduce((a, b) => a + b.memberCount, 0)} Users ${client.guilds.cache.size} Servers ${client.channels.cache.size} Channels ${client.emojis.cache.size} Emojis ---------------------------------------------)

const promises = [

client.shard.broadcastEval('this.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)'),
client.shard.fetchClientValues('guilds.cache.size'),
client.shard.fetchClientValues('channels.cache.size'),
client.shard.fetchClientValues('emojis.cache.size'),
];

Promise.all(promises)
.then(results => {
console.log(Total (current) ${results[0].reduce((acc, memberCount) => acc + memberCount, 0)} Users ${results[1].reduce((acc, guildCount) => acc + guildCount, 0)} Servers ${results[2].reduce((acc, channelCount) => acc + channelCount, 0)} Channels ${results[3].reduce((acc, emojiCount) => acc + emojiCount, 0)} Emojis );

})
crystal furnace
quartz kindle
#

thats not the problem

#

the fetchClientValues is the problem

crystal furnace
#

and replace with

#

This SHARD (1/2 or 2/2) is running with

#

for easy =))

#

haha

#

anyway no body can see my console.log

quartz kindle
#

just add a catch in Promise.all

crystal furnace
#

why after i create a shard

#

and run it

#

a server is add bot in

#

and the total guild is not update

quartz kindle
#

you didnt resolve the promise

crystal furnace
#
client.on(`guildCreate`, async guild => {
  if (guild.id === `538361750651797504`) {
    //blacklist server
    return;
  }
  await guild.members.fetch(guild.ownerID)
  client.shard.fetchClientValues('guilds.cache.size');
  then(results => {
  const create = new Discord.MessageEmbed()
    .setColor("#2bda00")
    .setTitle(`New guild add loli bot yeah!`)
    .addField(`Current guild now`, `${results.reduce((acc, guildCount) => acc + guildCount, 0)}`, false)
    .addField(`Guild Name`, guild.name, false)
    .addField(`Guild ID`, guild.id, false)
    .addField(`Member Count`, guild.memberCount, true)
    .addField("Humans", `${guild.members.cache.filter(member => !member.user.bot).size} `, true)
    .addField("Bots", `${guild.members.cache.filter(member => member.user.bot).size}`, true)
    .addField(`Owner`, guild.owner.user.tag + `[` + guild.owner.id + `]`, false);
  client.channels.cache.get(`688393107821428766`).send(create);
  let myGuild = client.guilds.cache.get(`629882029562920980`);
  let guildCount = `${results.reduce((acc, guildCount) => acc + guildCount, 0)}`;
  let guildCountChannel = myGuild.channels.cache.get(`700002993054941224`);
  guildCountChannel.setName(`GuildUpStatus: ` + guildCount).catch(error => send.processes(client, error));
  });
crystal furnace
#

ahhh

#

i see =))

quartz kindle
#

also

opal plank
quartz kindle
#

you can only change channel name 2x every 10 minutes

#

and your human and bot count requires fetching all members

opal plank
#

also "loli bot" is one hell of a name to put there

crystal furnace
#
client.on(`guildCreate`, async guild => {
  if (guild.id === `538361750651797504`) {
    //blacklist server
    return;
  }
  await guild.members.fetch(guild.ownerID)
  client.shard.fetchClientValues('guilds.cache.size').then(results => {
  const create = new Discord.MessageEmbed()
    .setColor("#2bda00")
    .setTitle(`New guild add loli bot yeah!`)
    .addField(`Current guild now`, `${results.reduce((acc, guildCount) => acc + guildCount, 0)}`, false)
    .addField(`Guild Name`, guild.name, false)
    .addField(`Guild ID`, guild.id, false)
    .addField(`Member Count`, guild.memberCount, true)
    .addField("Humans", `${guild.members.cache.filter(member => !member.user.bot).size} `, true)
    .addField("Bots", `${guild.members.cache.filter(member => member.user.bot).size}`, true)
    .addField(`Owner`, guild.owner.user.tag + `[` + guild.owner.id + `]`, false);
  client.channels.cache.get(`688393107821428766`).send(create);
  let myGuild = client.guilds.cache.get(`629882029562920980`);
  let guildCount = `${results.reduce((acc, guildCount) => acc + guildCount, 0)}`;
  let guildCountChannel = myGuild.channels.cache.get(`700002993054941224`);
  guildCountChannel.setName(`GuildUpStatus: ` + guildCount).catch(error => send.processes(client, error));
  });
})```
#

(node:20460) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined
at C:\Users\Win10\Desktop\bot3\index.js:144:50
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use node --trace-warnings ... to show where the warning was created)
(node:20460) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:20460) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js proce

quartz kindle
#

and you probably want to guild.leave() your blacklisted servers

crystal furnace
#

lol

#

a lot of error cause when sharding

quartz kindle
#

the channel doesnt exist in this shard

#

you're doing cross-shard operations

crystal furnace
#

client.shard.fetchClientValues('guilds.cache.size').then(results => {

#

you mean this ?

quartz kindle
#

no

#

client.channels.cache.get

#

and client.guilds.cache.get

#

cache is only for the current shard

crystal furnace
#

so remove cache ?

quartz kindle
#

if the guild is in the other shard, this will be undefined

crystal furnace
#

so what i should to do

#

to fix it

quartz kindle
#

either fetch it, or send the message with broadcastEval

#

or use client.api

crystal furnace
#

it is more easier if you rewrite

#

sorry =((

#

client.shard.broadcastEval

#

you mean ?

quartz kindle
#

if(!client.channels.cache.get(...)) await client.channels.fetch(...)

#

that would be the easiest way

#

you will have duplicated caches, but its fine if its just a couple channels

#

also you dont need the myguild

#

just fetch the channel directly

crystal furnace
#

so addition on this line ?

quartz kindle
#

before that line

crystal furnace
#

so just add more

#

not need to fix or delete ?

quartz kindle
#

or just do this ```js
let channel = await client.channels.fetch(id);
channel.send(create);

opal plank
#

screeches in promise rejection handling and conditional chaining

quartz kindle
#

chandling

opal plank
#

shush