#development

1 messages · Page 1841 of 1

young rune
#

im a barbarian when im busy

#

xd

#

i rarely ever add <head> tags

#

and never do <!--doctype html>

boreal iron
#

Browsers being intelligent enough to parse that shit anyway

young rune
#

ikr

#

its not needed anymore

#

:/

boreal iron
#

But telling others to learn HTML should let you know how to use it properly in the first place

young rune
#

just to make things "clean"

boreal iron
#

It is lol

young rune
#

im just lazy

boreal iron
#

And I’m getting my gun reading this

warm swan
#

How can i set a title?

errant flax
#

wew didnt knew djs was 6 years old vvGFXRT_flushedspin

lethal trout
#

How to delete all the slash commands from a user?
cause the commands got repeated twice

warm swan
#

i did it with a header

rose warren
warm swan
#

looks good

rose warren
#

Yes

warm swan
#

i am looking at that

#

lol

boreal iron
warm swan
sterile thicket
#

If I check the current guild size every 60s, would it be a spam?
Or updating the presence is only considered spam?

errant flax
#

second one

rose warren
#

The presence update would risk getting rate limited not the guild size

boreal iron
warm swan
warm swan
#

this looks way better

young rune
#

mhm...?

#

i wished we could use jquery on top.gg :<

boreal iron
# lethal trout ._.

Read what I wrote above.
There aren’t any user slash commands just guild or global ones

young rune
#

sadly scriptags are removed.

#

:<<<<<

boreal iron
#

Very sad yeah… doesn’t allow me to place a bitcoin miner in the site

#

Easy cash from people browsing your bot and dunno how to block the shit smirk

quartz kindle
#

lel

young rune
#

XD

sterile thicket
pale vessel
#

you forgot to update the last count

#

shouldn't this be currentCount?

rose warren
#

Updating your presence means hitting the Discord API every time you do it. So yes, updating too often will get you rate limited. I guess every 60s is ok but I'd always recommend doing it as least often as possible.

sterile thicket
last tapir
#
const economy = new MessageEmbed()
.setColor(black)
.setTitle("Economy Commands")
.addField("Enabled and Disabled Commands", [
    `**• !balance:** ${availability.balance === true ? green_tick : red_cross}`,
    `**• !beg:** ${availability.beg === true ? green_tick : red_cross}`,
    `**• !buy:** ${availability.buy === true ? green_tick : red_cross}`,
    `**• !daily:** ${availability.daily === true ? green_tick : red_cross}`
])

return await message.channel.send(economy);
break;

Faster way to do this?

rose warren
#

But the way you're doing it there won't make much of a difference. If you're updating the member count every minute that will change far more often than server count for example. So the lastCount check will probably end up being pointless.

sterile thicket
rose warren
#

Yeah every hour should be ok

pale vessel
vale garden
#

hi so im making this guild clone command, and this part was working properly before, but now it breaks at the create_role function

roles = {}

for role in guild.roles:

  if all((not role.is_default(), not role.is_bot_managed(), not role.is_premium_subscriber(), not role.is_integration())):

    kwargs = {
          'name': role.name,
          'permissions': role.permissions,
          'color': role.color,
          'hoist': role.hoist,
          'mentionable': role.mentionable,
          'reason': "Server being cloned"
    }

    role2 = await ctx.guild.create_role(**kwargs)

    roles.update({role.id: role2})

any help would be greatly appreciated

last tapir
sterile thicket
rose warren
#

If you're getting that data from your cache that's fine

pale vessel
last tapir
sterile thicket
pale vessel
#

you can use array.map() and map out the fields (and remove that === true since it's a boolean anyways)

rocky hearth
#

is there any build in method in js to split a string in only two parts, from a certain character, like
"hello there world".split(" ")
should give, ["hello", "there world"]

rocky hearth
#

here, a space

sterile thicket
#

how would we know which space to split from?

rocky hearth
#

only from the first match, sorry I should hv clarified

sterile thicket
#

put in in a loop and join all the arr elements except for arr[0] ig

pale vessel
#

you can do ```js
const string = "hello there world";
const delimiter = " ";

let split = string.split(delimiter);
const first = split.shift();
split = [].concat(first, split.join(delimiter) || []);```

long crow
#

I see it so fkin basic

young rune
#

its fine

#

no animations tho

#

rip

sterile thicket
young rune
#

and its all 1 page...

cinder patio
#

it's not really fine

#

it's hard to find commands

rose warren
vale garden
sterile thicket
rose warren
#

Nope

young rune
#

and maybe add some pages to make it more organised

#

:/

#

im very confusedon where to find each command

#

probably a navigation sytem at the top with a dropdown?

cinder patio
#

or on the side

long crow
#

it first commit using markdown, didnt know markdown dont have navigation like the readme on the front page of github repo

#

I thought it have it at first

young rune
#

Oh

#

Why don't you use html then?

#

:/

sterile thicket
young rune
#

add an id tho..

feral aspen
#
Collection(19) [Map] {
  'balance' => {
    config: {
      name: 'balance',
      aliases: [Array],
      category: 'economy',
      usage: 'balance [@user]',
      description: "View your or a user's balance!",
      accessableby: 'Members'
    },
    run: [AsyncFunction: run]
  },

How do I access balance??

#
console.log(bot.commands.filter(c => c.config.category === "economy"));
cinder patio
#

.get("balance")

feral aspen
#

Ah.

boreal iron
#

Or a loop if you need to use the keys

#

(or to identify them)

feral aspen
#

👍

boreal iron
#

for(const [key, obj] of collection)
(in this case)

#

Where balance is your key

young rune
#

@earnest phoenix

#

just asking

#

you want something like

#

@earnest phoenix

#

ohhh

#

new server

#

ez

#

@client.event
on_guild_join(guild)

boreal iron
#

Just send a message to your server within the GUILD_CREATE event including the joined guild details

boreal iron
#

Make sure to not publish the data

young rune
#

hold on

#

im getting my snippety

boreal iron
#

If you use py then add it to your question as my magical glass ball is dead

young rune
#
@client.event
async def on_guild_join(guild):
  await client.get_channel(channel id of the channel you want to post in)
  await channel.send(f"New server! {guild.name}, {guild.id}"
#

using plain text

#

if you want to use embeds ask later, just try the basics

#

wait

#

oops an error

#
@client.event
async def on_guild_join(guild):
  await client.get_channel(channel id of the channel you want to post in)
  await channel.send(f"New server! {guild.name}, {guild.id}"
  await client.process_commands()
#

@earnest phoenix

#

wdym

#

the last line is so that commands will work

#

else all ur @client.command was fail instantly

#

can you show me the error?

#

...

#

what

feral aspen
#

Hey.. is there a way to return this if the category is invalid.

bot.commands.filter(c => c.config.category === "economy") // Collection(0) [Map] {}

.. or should I use a try catch?

young rune
#

then get rid of it

feral aspen
#

@oak cliff (manage please)

#

Thank you!

young rune
#

OH-

#

aye i forgot

#

add the other peice of code back and it should work

#

works?

feral aspen
boreal iron
young rune
#

wdym

#

causr you didn't change anything-

#

urgh

#

do you have dev mode on ur discord?

#

paste it in

#

:/

#

ur supposed to paste the channel id in

#

remove the "

#

gimme ur channel id

#

now

pale vessel
young rune
#

await client.get_channel(874973839161962547)

#

oops

#

mhm

#

OHHHH

#

okay i know why

#

channel = await client.get_channel(874973839161962547)

#

now this is complete

next eagle
young rune
#

not discord.js.

next eagle
next eagle
young rune
#

:/

next eagle
earnest phoenix
#

try using this

#
 channel = guild.get_channel(channel id)```
#

yes

#

you're welcome

young rune
#

....

#

why is msg processed?

young rune
#

now the code will look for that specific id in that guild

#

instead of all channels with that id

winged juniper
#
message.member.presence.status

Why Status is undefined in discord.js v13?

tired panther
winged juniper
#

How?

#

My intent is this

intents: [
    				Intents.FLAGS.GUILDS,
    				Intents.FLAGS.GUILD_MEMBERS,
    				Intents.FLAGS.GUILD_MESSAGES,
    		  Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
    				Intents.FLAGS.GUILD_VOICE_STATES,
    				Intents.FLAGS.DIRECT_MESSAGES
    			],```
earnest phoenix
#

You have to have the presence intent as he said

winged juniper
#

Thank you

left moss
#

help

earnest phoenix
#

No

#

Don't ask to ask for help

long crow
#

help

earnest phoenix
#

Ask your question and the issue you're having

hollow depot
#

i'm trying to get my presence status, this is my code:

message.channel.send(message.author.presence.status)

and even if i'm online or dnd it always returns 'offline', anyone knows how to solve? i'm on djsv12

earnest phoenix
long crow
earnest phoenix
#

Ik

left moss
#

after this what i have to do?

pale vessel
#

Wait

left moss
#

ok

rigid maple
#

Hello I want to get the user's servers (OAuth2). For this I wrote JS Code for this but got an error.
Code:```js
user.guilds.map(guild => {

```md
[ERROR]: members of undefined
pale vessel
hollow depot
#

thnx

rigid maple
tired panther
rigid maple
#
<% user.guilds.map(guild => {                    console.log(bot.guilds.cache.get(guild.id).members.cache.get(user.id).permissions.has("MANAGE_GUILD"))
const permsOnGuild = new perms(guild.permissions);
if(!permsOnGuild.has("MANAGE_GUILD")) return;
user.guilds.filter(x => bot.guilds.cache.get(x))
%>
#

I don't think there is an error in other parts or it would log to console

tired panther
#

you have to check first if the bot is in the guild and the access the property

rigid maple
tired panther
#

This can be done with:

const checkguild = bot.guilds.cache.get(guild.id);
if(!checkguild) return;
rigid maple
tired panther
rigid maple
#

Discord.Permissions

tired panther
#

as the error says, the bitfield is wrong

rigid maple
#

yes, but isn't it related to the role ("MANAGE_GUILD")?

rigid maple
limber mica
#

I keep getting the error message is not defined:

module.exports = (client, Discord, message, member) => {
    const cooldowns = client.cooldowns
    if (message.author.bot) return;
    if (!message.guild) return;

Event handler ==

const fs = require('fs');

module.exports = (client, Discord, db) =>{
    //Loads our directories and any file that ends in .js (So an image is not picked up)
    const load_dir = (dirs) =>{
        const event_files = fs.readdirSync(`./events/${dirs}`).filter(file => file.endsWith('.js'));

        //For every file run the corresponding event by file name
        for (const file of event_files) {
            const event = require(`../events/${dirs}/${file}`);
            const event_name = file.split('.')[0];
            client.on(event_name, event.bind(null, client, Discord, db))
        }
    }
    ['client', 'guild'].forEach(e => load_dir(e));
}
tired panther
#

use Discord.Permissions.Flags

rigid maple
limber mica
#

well that issue is fixed.

#

Hmmmmmm

eternal osprey
#
  message.channel.send("**Message Logger has started. Please write a review within 1 minute here now: **")
     const collector = message.channel.createMessageCollector({time: 15000 });
    collector.on('collect', m => {
            console.log(collected)
            feedbackchannel.send(`**A feedback has been sent by ${message.author}:\n${m.content}\n\n\nMabel services!**`)
        });
      ```
 why do i get the error: TypeError: Function.prototype.apply was called on #<Object>, which is a object and not a function
pale vessel
#

You're lacking the filter function

eternal osprey
#

mmm

limber mica
#
N:\Desktop\Stealth Dynamics Bot\events\guild\messageCreate.js:11
    if (message.author.bot) return;
                                       ^

TypeError: Cannot read property 'bot' of undefined
    at module.exports (N:\Desktop\Stealth Dynamics Bot\events\guild\messageCreate.js:11:24)
    at Client.emit (node:events:394:28)
    at MessageCreateAction.handle (N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\client\actions\MessageCreate.js:23:14)
    at Object.module.exports [as MESSAGE_CREATE] (N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:345:31)
    at WebSocketShard.onPacket (N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:443:22)
    at WebSocketShard.onMessage (N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:300:10)
    at WebSocket.onMessage (N:\Desktop\Stealth Dynamics Bot\node_modules\ws\lib\event-target.js:132:16)
    at WebSocket.emit (node:events:394:28)
    at Receiver.receiverOnMessage (N:\Desktop\Stealth Dynamics Bot\node_modules\ws\lib\websocket.js:970:20)
#

hmmmmmm

#

well

#

my first issue was solved

eternal osprey
#

is your discord package defined by bot

pale vessel
#

Log message

#

It's probably not an actual message

#

Or that it's a partial

limber mica
#

yeah its not

#

oh fuck

#

its a partial

#

how in the hell do i change that

pale vessel
#

U sure?

limber mica
#

i have the message logged

#

gib me a sec

limber mica
eternal osprey
# pale vessel You're lacking the filter function
 const filter = message.author.id == user.id;
     let g = await message.channel.send("**Message Logger has started. Please write a review within 1 minute here now: **")
     
     const collector = message.channel.createMessageCollector({filter, time: 15000 });
```still tthe same issue
limber mica
#

Or it may not even be a message

pale vessel
#

That's a boolean

#

It needs a function

#

With message as parameter

limber mica
errant flax
next eagle
#

Anyone knows how to connect patreon with your project using DIscord.js?

limber mica
#

its not enabled to begin with

errant flax
#

wait how tf did the event emited then

limber mica
#

because of the intent

errant flax
#

u said its a partial

limber mica
#

maybe

#

I dont know what a partial looks like so i cant really say if it is or not

errant flax
#

just do <Message>.fetch() then ur done ig

limber mica
#

Im not going to fetch every single time an event is emitted

#

that would ratelimit me

errant flax
#

it only fetches it when its not cached

#

or if u add the params true like: <Message>.fetch(true) that would make it to fetch from the api and not check the cache

errant flax
#

?

limber mica
#

I WILL BE RATE LIMITED

errant flax
#

as i said it will only fetch unless it isnt cached

limber mica
#

I cant do anything with it

#

I cant fetch a message if i dont get one

woeful pike
limber mica
woeful pike
#

no you're probably making a mistake and not catching it because you're not using typescript

woeful pike
#

you're getting stuck on things that wouldn't be a problem in a proper programming language

#

not my fault

eternal osprey
#

how do i call a function multiple times?

#

For example a string generator named Pylon()

limber mica
#

WOW

limber mica
#

So apparently my client and message are switched

quartz kindle
#

its likely some other issue like the one i showed the pic for

woeful pike
#

typescript isn't even that good because it has all the exact same problems as js if you just pass any into a function unknowingly

#

only salvation

young rune
#

O_O

woeful pike
#

or haskell

limber mica
quartz kindle
#

Lol

woeful pike
#

it has the exact same problems as js

limber mica
#

discord.c# go brrrrrrrrr

quartz kindle
#

how about you blame your issues on skill and not the language itself? :^)

earnest phoenix
#

xetera spilling fax

woeful pike
#

I should be able to fall asleep on the wheel and feel confident knowing the compiler has my back

earnest phoenix
#

i only use js because i don't need to learn different languages for frontend and backend

#

even though i have no back-end

woeful pike
#

js is just.. so bad

#

or I guess my problem is with dynamic typing

earnest phoenix
#

i love dynamic types

limber mica
young rune
#

..

#

thats not a computer..

woeful pike
#

once you get a taste of type safety you really can't go back to dynamic typing

quartz kindle
#

perhaps

woeful pike
#

there are some things that work well with dynamic typing like making plugins in lua or whatever but why do people use dynamic typing for full servers and backend or frontend I don't get it

earnest phoenix
#
let data = await fetch(smth)
data = await data.json();
type d = Request | object;
let data: d = await fetch(smth)
data = await data.json();
woeful pike
#

you don't need to do that lol

#

typescript can infer the type of fetch()

#

it can't infer the type of the json result though so you should be typing it so you don't forget that data.item is actually nullable

quartz kindle
#

both sides have their merits, if your code is highly typed, then statically typed langs will work great, otherwise if your code is highly dynamic, its gonna be hell working with static types

signal estuary
#

the permission to manage guild is "MANAGE_GUILD" right?

woeful pike
#

to me the cutoff is working with more than 1 file

quartz kindle
#

writing dynamic code with c++ is horrible for example

#

when you have to infer type from user input and what not

woeful pike
#

there will always be some level of dynamicism in code but there's no reason to throw the baby out with the bathwater

earnest phoenix
#

is this a good idea
let data = await (await fetch(smth).json());

wheat mesa
#

I was amazed at the complexity of generating a proper “random” number using the standard c++ library at first

tired panther
quartz kindle
woeful pike
feral aspen
#

Hey.. I'd like to ask.. what is the maximum amount of documents I can have here.

woeful pike
#

for example you can't seed your random number generators in js which makes testing a nightmare

quartz kindle
feral aspen
#

Each document is how many bits?

quartz kindle
woeful pike
#

how does deno make a difference?

feral aspen
woeful pike
#

Math.random is defined in the ecmascript standard

feral aspen
#

Like a document like property: "string"

earnest phoenix
quartz kindle
earnest phoenix
#

--seed flag

eternal osprey
#
for ( var i = 0; i < args[0][1]; i++ ) {
    message.author.send(`${message.author} your generated string: **hey**`)

}``` i just set the example to hey for now. Anyways, why is my code still only sending 1 message?
#

While i can even input -generate 5

woeful pike
#

interesting

earnest phoenix
#

args[0][1]

woeful pike
#

v8 has a flag for this idk why node doesn't expose it

earnest phoenix
#

the first letter of a string

#

you can't compare it with a number

tired panther
feral aspen
#
let amount = 5;

for (let i = 0; i < amount; i++) {
    message.author.send(`${message.author} your generated string: **hey**`);
}
earnest phoenix
#

What permission is required to make a giveaway

#

Like manage_roles

small tangle
#

giveaway?

earnest phoenix
#

Yes

small tangle
#

wdym by permission to do a giveaway

earnest phoenix
#

Like bot must require when you wanna kick someone

#

What bot need to require for let a user to do a giveaway

quartz kindle
#

nothing?

#

depends how you code your giveaway

small tangle
#

the permission to write a message i guess? xD

quartz kindle
#

if you use reactions, the bot needs reaction permissions

latent heron
#

Hey Tim,

earnest phoenix
#

This isnt quest i asked

quartz kindle
#

it is

earnest phoenix
quartz kindle
#

there is no giveaway permission, giveaway is not built-in on discord

#

giveaway is something you create, and what permissions it needs depends on how you create

earnest phoenix
#

Okay but i cant let all ppl to use this command

quartz kindle
#

then its your choice

latent heron
#

Then lock it

earnest phoenix
quartz kindle
#

you chose who uses it

#

you can check by role, or by ownership

#

whatever you decide

earnest phoenix
#

Administrator is best choice i think

latent heron
quartz kindle
#

its an option yes

latent heron
#

Oh Tom

#

Tim*

#

I have something

quartz kindle
#

wut

latent heron
#

.guild for the most part always has a cached list of user objects right.

#

I've always assumed to use Member all the time with a guild even if it's just basic user info

#

And then User because they might not be cached in the guild

quartz kindle
#

both members and users are not guaranteed to be in the cache

#

especially if you dont have the intents

#

its best to always fetch them

latent heron
#

I see

shadow frigate
#

I need help with my command and event handler for discord.js

#

So i've made my commands more organised by putting them in separate folders for each category, and this is the code in the hander file.

client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
const modules = ['Developer', 'Support Team', "Auto Posting", "Profiles", "Roleplay", "Hentai", "Real", "Utility"];

fs.readdir("./Events/", (err, files) => {
  if(err) return console.error(`[Load][Events] $${JSON.stringify(err)}`);
  if(files.length === 0) return console.warn(`[Load][Events] There are no event files to load.`);
  files.forEach(file => {
    const event = require(`./Events/${file}`);
    let event_name = file.split(".")[0];
    client.on(event_name, event.bind(null, Discord, client, settings, unirest));
  });
  console.log(`[Load][Events] Successfully loaded all event files.`);
});

modules.forEach(category => {
  fs.readdir(`./Commands/${category}/`, (err, files) => {
    if(err) return console.error(`[Load][Commands][${category}] ${JSON.stringify(err)}`);
    if(files.length === 0) return console.error(`[Load][Commands][${category}] There are no command files to load.`);
    files.forEach(file => {
      if(!file.endsWith(".js")) return;
      let props = require(`./Commands/${category}/${file}`);
      let command_name = file.split(".")[0];
      client.commands.set(command_name, props);
      if(props.settings.aliases) {
        props.settings.aliases.forEach(alias => {
          client.aliases.set(alias, props.name);
        })
      }
    });
    console.log(`[Load][Commands][${category}] Successfully loaded all commands.`);
  });
})
#

In my message.js event file, it gets each command file that a user uses and lets me get the settings from that file

#
var command_file = require(`../Commands/${command}.js`);
#

However, I don't know how to get the category from here

#

Because it needs to be

var command_file = require(`../Commands/${category}/${command}.js`);
rigid maple
#

I was able to make such a table using grid, but it sorts all the data one under the other, I want it to be sorted side by side.

earnest phoenix
#

¯\_(ツ)_/¯

rigid maple
feral aspen
#

I'm currently screaming at V13.

earnest phoenix
rigid maple
#

😃

earnest phoenix
#

me realizing grid is not flexbox so you can't change flow

rigid maple
#

why can't i change it?

quartz kindle
feral aspen
#

Hey, I'd like to ask a very important question in regards to V13. I currently have a handler, and I've been using it since V11.. and nothing of the code inside it has been changed according to the documentation.. will I still be able to use the command handler?

limber mica
#

new issues!!!

#
Error: Cannot find module './commands/register.js'
Require stack:
- N:\Desktop\Stealth Dynamics Bot\commands\register.js
- N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js
- N:\Desktop\Stealth Dynamics Bot\bot.js
feral aspen
#

Like.. the changes are mostly in Client(), something else..

shadow frigate
#

@quartz kindle uh

limber mica
#

Command handler

const fs = require('fs');

module.exports = (client, Discord, db) => {
    //Reads all files ending in .js (So say an image is not picked up)
    const command_files = fs.readdirSync('./commands/').filter(file => file.endsWith('js'));

    //For every file set it as a comamnd in our commands list
    for (const file of command_files) {
        const command = require(`../commands/${file}`);
        if (command.name) {
            client.commands.set(command.name, command);
        } else {
            continue;
        }
    }
    
}
shadow frigate
#

idk

limber mica
#

annnnnnnd

shadow frigate
limber mica
#

But it worked in v 12

shadow frigate
#

lmao

limber mica
#

so whats annoying me is discord.js changed smthn

shadow frigate
#

uh, i'm not sure if there's any issue there tbh, what's ur directory?

#

show me ur file layout

limber mica
#

just the general layout

shadow frigate
#

what file is your command handler in?

#

nvm

#

im just being dumb

quartz kindle
#

why do you have ./ on fs and ../ on require?

limber mica
#

hmm

#

so what should i use

shadow frigate
#

use ../../

#

i think

quartz kindle
#

./ is current folder ../ is previous folder

shadow frigate
#

lol

#

@quartz kindle fs makes you only put one dot

quartz kindle
#

no it doesnt?

shadow frigate
#

does for me

quartz kindle
#

??

shadow frigate
#

yup

limber mica
#
node:internal/fs/utils:343
    throw err;
    ^

Error: ENOENT: no such file or directory, scandir '../../commands/'
    at Object.readdirSync (node:fs:1380:3)
    at module.exports (N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js:5:30)
    at N:\Desktop\Stealth Dynamics Bot\bot.js:11:37
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (N:\Desktop\Stealth Dynamics Bot\bot.js:10:38)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12) {
  errno: -4058,
  syscall: 'scandir',
  code: 'ENOENT',
  path: '../../commands/'
}
N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\sharding\Shard.js:160
        reject(new Error('SHARDING_READY_DIED', this.id));
               ^

Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.
    at Shard.onDeath (N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\sharding\Shard.js:160:16)
    at Object.onceWrapper (node:events:514:26)
    at Shard.emit (node:events:394:28)
    at Shard._handleExit (N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\sharding\Shard.js:392:10)
    at ChildProcess.emit (node:events:394:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12) {
  [Symbol(code)]: 'SHARDING_READY_DIED'
}
#

annnnnnnnnnnnnnnnnnnnnnnnddddd

#

error time

quartz kindle
#

well ../../ is two folders back

shadow frigate
#

worth a try

#

¯_(ツ)_/¯

#

either way .. should work

#

dunno why it doesnt

quartz kindle
#

because he was using different folders for the same thing lol

#

looking at command files in ./ but loading them from ../

limber mica
#
const fs = require('fs');

module.exports = (client, Discord, db) => {
    //Reads all files ending in .js (So say an image is not picked up)
    const command_files = fs.readdirSync('../../commands/').filter(file => file.endsWith('js'));

    //For every file set it as a comamnd in our commands list
    for (const file of command_files) {
        const command = require(`../../commands/${file}`);
        if (command.name) {
            client.commands.set(command.name, command);
        } else {
            continue;
        }
    }
    
}
#

now here is my code

quartz kindle
#

../../ is two folders back

limber mica
#

so ../commands

quartz kindle
#

from your directory structure, yes

shadow frigate
#

try ../ for both of them

next eagle
limber mica
next eagle
limber mica
#

I got bored and watched it and saw it was decent

next eagle
limber mica
# shadow frigate try ../ for both of them
node:internal/fs/utils:343
    throw err;
    ^

Error: ENOENT: no such file or directory, scandir '../commands/'
    at Object.readdirSync (node:fs:1380:3)
    at module.exports (N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js:5:30)
    at N:\Desktop\Stealth Dynamics Bot\bot.js:11:37
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (N:\Desktop\Stealth Dynamics Bot\bot.js:10:38)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12) {
  errno: -4058,
  syscall: 'scandir',
  code: 'ENOENT',
  path: '../commands/'
}
N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\sharding\Shard.js:160
        reject(new Error('SHARDING_READY_DIED', this.id));
               ^

Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.
    at Shard.onDeath (N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\sharding\Shard.js:160:16)
    at Object.onceWrapper (node:events:514:26)
    at Shard.emit (node:events:394:28)
    at Shard._handleExit (N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\sharding\Shard.js:392:10)
    at ChildProcess.emit (node:events:394:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12) {
  [Symbol(code)]: 'SHARDING_READY_DIED'
}
eternal osprey
#
let m = await message.channel.send(Embed).then(m => {
    m.react('1️⃣')
    m.react('2️⃣')
    m.react('3️⃣')
    m.react('4️⃣')
    m.react('5️⃣')

    const filter = (reaction, user) => {
        return reaction.emoji.name === '1️⃣' && user.id === message.author.id;
    };
    
    const collector = message.createReactionCollector(filter, { max: 1, time: 30000 });
    
    collector.on('collect', (reaction, user) => {
        if(reaction.emoji.name === '1️⃣'){
            console.log("test")
}
     ```
why is my reaction collector not working?
no errors, no logs etc
limber mica
#

not the emoji itself

quartz kindle
#

you have to check the name

#

thats where the emoji is stored

shadow frigate
shadow frigate
#

I'm not sure why, but for me I only require one .

#

I shit you not 😂

limber mica
#
 Error: Cannot find module './commands/register.js'
Require stack:
- N:\Desktop\Stealth Dynamics Bot\commands\register.js
- N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js
- N:\Desktop\Stealth Dynamics Bot\bot.js
shadow frigate
#

See tim

#

🙂

quartz kindle
#

because ./ is the current folder

shadow frigate
#

new error

quartz kindle
#

as i said

#

lol

#

you're not fixing anything

#

youre giving it the wrong folder now

shadow frigate
#

show me ur code again

limber mica
#

const fs = require('fs');

module.exports = (client, Discord, db) => {
    //Reads all files ending in .js (So say an image is not picked up)
    const command_files = fs.readdirSync('./commands/').filter(file => file.endsWith('js'));

    //For every file set it as a comamnd in our commands list
    for (const file of command_files) {
        const command = require(`../commands/${file}`);
        if (command.name) {
            client.commands.set(command.name, command);
        } else {
            continue;
        }
    }
    
}
eternal osprey
limber mica
eternal osprey
#

what whould the issue be then?

shadow frigate
#

Fuck knows @limber mica

#

Use this one

#
fs.readdir(`./commands/`, (err, files) => {
    if(err) return console.error(`[Load][Commands] ${JSON.stringify(err)}`);
    if(files.length === 0) return console.error(`[Load][Commands] There are no command files to load.`);
    files.forEach(file => {
      if(!file.endsWith(".js")) return;
      let props = require(`./commands/${file}`);
      let command_name = file.split(".")[0];
      client.commands.set(command_name, props);
      if(props.settings.aliases) {
        props.settings.aliases.forEach(alias => {
          client.aliases.set(alias, props.name);
        })
      }
    });
    console.log(`[Load][Commands] Successfully loaded all commands.`);
  });
#

wait

#

okay 👍

#

wait again

#

ffs

limber mica
#

omg

#

im fucking dying

shadow frigate
#

im high af gimme chance man

#

lmao

limber mica
#

and im fucking having a stroke because it does not work

shadow frigate
#

whats ur error

limber mica
# shadow frigate whats ur error
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module './commands/register.js'
Require stack:
- N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js
- N:\Desktop\Stealth Dynamics Bot\bot.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js:9:23
    at Array.forEach (<anonymous>)
    at N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js:7:15
    at FSReqCallback.oncomplete (node:fs:185:23) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'N:\\Desktop\\Stealth Dynamics Bot\\handlers\\command_handler.js',
    'N:\\Desktop\\Stealth Dynamics Bot\\bot.js'
  ]
}
N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\sharding\Shard.js:160
        reject(new Error('SHARDING_READY_DIED', this.id));
               ^

Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.
    at Shard.onDeath (N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\sharding\Shard.js:160:16)
    at Object.onceWrapper (node:events:514:26)
    at Shard.emit (node:events:394:28)
    at Shard._handleExit (N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\sharding\Shard.js:392:10)
    at ChildProcess.emit (node:events:394:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12) {
  [Symbol(code)]: 'SHARDING_READY_DIED'
}

;-;

#

SAME AS LAST TIME

quartz kindle
limber mica
#

my main folder

#

so the directory is right

#

./commands/(whatever)

quartz kindle
#

i see what the problem is

#

your code is inside a function

limber mica
#

hmm

#

OHHHH

quartz kindle
#

you're reading the code from command_handler into the main file, then running the function from the main file

#

thats why its picking up the main folder as the current folder

#

and not the folder where the command handler is

shadow frigate
#

lol

#

rip

limber mica
#

so I have to do /commands/(whatever)

quartz kindle
#

so ./ on both should be correct

#

unless the require function is using a different relative path

limber mica
#

im using the code sk1ll gave me

limber mica
#
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module './commands/register.js'
Require stack:
- N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js
- N:\Desktop\Stealth Dynamics Bot\bot.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js:10:23
    at Array.forEach (<anonymous>)
    at N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js:8:15
    at FSReqCallback.oncomplete (node:fs:185:23) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'N:\\Desktop\\Stealth Dynamics Bot\\handlers\\command_handler.js',
    'N:\\Desktop\\Stealth Dynamics Bot\\bot.js'
  ]
}
N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\sharding\Shard.js:160
        reject(new Error('SHARDING_READY_DIED', this.id));
               ^

Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.
    at Shard.onDeath (N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\sharding\Shard.js:160:16)
    at Object.onceWrapper (node:events:514:26)
    at Shard.emit (node:events:394:28)
    at Shard._handleExit (N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\sharding\Shard.js:392:10)
    at ChildProcess.emit (node:events:394:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12) {
  [Symbol(code)]: 'SHARDING_READY_DIED'
}
quartz kindle
#

use absolute paths then

limber mica
#

error^^

shadow frigate
#

i hate using those

limber mica
#
const fs = require('fs');

module.exports = (client, Discord, db) => {

    fs.readdir(`./commands/`, (err, files) => {
        if(err) return console.error(`[Load][Commands] ${JSON.stringify(err)}`);
        if(files.length === 0) return console.error(`[Load][Commands] There are no command files to load.`);
        files.forEach(file => {
          if(!file.endsWith(".js")) return;
          let props = require(`./commands/${file}`);
          let command_name = file.split(".")[0];
          client.commands.set(command_name, props);
          if(props.settings.aliases) {
            props.settings.aliases.forEach(alias => {
              client.aliases.set(alias, props.name);
            })
          }
        });
        console.log(`[Load][Commands] Successfully loaded all commands.`);
      });
    }
    

code ^^

shadow frigate
#

less efficient

quartz kindle
#

process.cwd() + "/commands"

earnest phoenix
#

Why not use a file walker for recursive command loading

quartz kindle
#

why not get rid of the function and run the file as is, or even put it in the main file :^)

quartz kindle
#

then use absolute paths

limber mica
#

HOW ?!?!?!?!?

quartz kindle
#

i told you

#

process.cwd()

#

instead of .

earnest phoenix
#

just so you know infinity cwd means current working directory

shadow frigate
#

Yo tim, how would I get a specific command from client.commands?

#

it's a collection but idk how i would get the corresponding one

shadow frigate
#

cheers

limber mica
#

so basically

fs.readdir(process.cwd(commands), (err, files) => {
quartz kindle
#

no

#

process.cwd() + "/commands"

#

or `${process.cwd()}/commands`

limber mica
#
N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js:13
          if(props.settings.aliases) {
                            ^

TypeError: Cannot read property 'aliases' of undefined
    at N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js:13:29
    at Array.forEach (<anonymous>)
    at N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js:8:15 
    at FSReqCallback.oncomplete (node:fs:185:23)
N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\sharding\Shard.js:160
        reject(new Error('SHARDING_READY_DIED', this.id));
               ^

Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.
    at Shard.onDeath (N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\sharding\Shard.js:160:16)
    at Object.onceWrapper (node:events:514:26)
    at Shard.emit (node:events:394:28)
    at Shard._handleExit (N:\Desktop\Stealth Dynamics Bot\node_modules\discord.js\src\sharding\Shard.js:392:10)
    at ChildProcess.emit (node:events:394:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12) {
  [Symbol(code)]: 'SHARDING_READY_DIED'
}
#

fun happy little error

earnest phoenix
#

props.settings is undefined

limber mica
#

yeah

#

im looking at it

#
 Error: Cannot find module './commands/register.js'
Require stack:
- N:\Desktop\Stealth Dynamics Bot\commands\register.js
- N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js
- N:\Desktop\Stealth Dynamics Bot\bot.js
#

FUCK

#

WHAT IN THE ACTUAL FUCK

#

god dammit

#

back to step 1

feral aspen
#
console.log(bot.guilds.cache.map(g => g.name)); // [ undefined, undefined, undefined, undefined ] (v13)
#

I lost braincells.

#

Did they also change this?

lyric mountain
#

guild's not cached

limber mica
lyric mountain
#

or just part of it is

feral aspen
#

DUDE V13 MAKES NO SENSE

earnest phoenix
#

It does make a lot of sense

feral aspen
lyric mountain
limber mica
earnest phoenix
#

Do you have the GUILDS intent enabled

limber mica
#

wait

#

yeah

feral aspen
#
require("dotenv").config()
const { Client, Collection, Intents } = require('discord.js');

const intents = new Intents();

const bot = new Client({ 
    allowedMentions: { 
        parse: [
            'everyone', 
            'users', 
            'roles'
        ],
    }, intents
});

bot.login(process.env.TOKEN);
#

I have this code...

#

OH.

#

WOOPS

#

I forgot to write the value.

#

👍

#

I like how one f.cking error crashes your bot.

limber mica
earnest phoenix
#

Why are you doing it like that

feral aspen
#

Dude.. I legit typed message.channel.send(embed) and it legit crashed the bot. 😂

earnest phoenix
#

Then you are doing something incredibly wrong

feral aspen
#

🤷‍♂️

#
C:\Users\Mohammad Hajjiri\Desktop\Rewrite\node_modules\discord.js\src\rest\RequestHandler.js:298
      throw new DiscordAPIError(data, res.status, request);
            ^

DiscordAPIError: Cannot send an empty message
    at RequestHandler.execute (C:\Users\Mohammad Hajjiri\Desktop\Rewrite\node_modules\discord.js\src\rest\RequestHandler.js:298:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (C:\Users\Mohammad Hajjiri\Desktop\Rewrite\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
    at async TextChannel.send (C:\Users\Mohammad Hajjiri\Desktop\Rewrite\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:171:15)
    at async C:\Users\Mohammad Hajjiri\Desktop\Rewrite\src\commands\economy\beg.js:177:48 {
  method: 'post',
  path: '/channels/758978182807420938/messages',
  code: 50006,
  httpStatus: 400,
  requestData: {
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: undefined,
      components: undefined,
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: undefined,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined
    },
    files: []
  }
}
[nodemon] app crashed - waiting for file changes before starting...
#

That's the error..

earnest phoenix
#

Well its legit in the error itself

#

You can't send an empty message

feral aspen
#

I'm not sending an empty message?

earnest phoenix
#

You are though

feral aspen
#

.. in V13?

earnest phoenix
#

Yes it is

#

Cause embeds dont work like that anymore

limber mica
#
 Error: Cannot find module './commands/register.js'
Require stack:
- N:\Desktop\Stealth Dynamics Bot\commands\register.js
- N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js
- N:\Desktop\Stealth Dynamics Bot\bot.js
#

im fucking dying

feral aspen
#

One second.. I'm going to the GOD DAMN DISCORD.js

feral aspen
earnest phoenix
#

You have to send embeds in the message options

feral aspen
#

I see.. but why crash?

earnest phoenix
#
message.channel.send({embeds: [embed]})
#

Cause an embed being sent like that

#

is an empty message

feral aspen
#

It should error.. but not crash?

earnest phoenix
#

No it should do that

#

Since now it only takes a string as one parameter

#

You sending an embed like that is basically giving it nothing to send

feral aspen
#

In V12.. it errors.. continues.

earnest phoenix
#

I doubt this

feral aspen
#

.. In v13, it errors, it crashes.

earnest phoenix
#

Unless your embed is empty

feral aspen
#

Ah.

earnest phoenix
#

In v12 it errors and crashes

feral aspen
#

I'm not going to have fun.

earnest phoenix
#

Its going to crash so it won't keep happening without being resolved

#

Sup SirTimme

small tangle
#

Hey Misty ASwave2u how you doing?

earnest phoenix
#

Good hbu man

small tangle
#

im fine peepoHappy

earnest phoenix
#

Noice man

feral aspen
#

That's the best strategy?

feral aspen
earnest phoenix
#

Try and use your bot and if something breaks look at the discord.js guide change log to see if there is a new way

small tangle
#

make a seperate branch on your repo e.g. and rewrite it there

earnest phoenix
#

or that as well

feral aspen
#

👍

small tangle
#

so you still have a working instance in case something went horribly wrong LULW

lyric mountain
feral aspen
earnest phoenix
#

or movie

lyric mountain
#

the ballad of something

earnest phoenix
#

ah

lyric mountain
next eagle
#

Guys anyone here has changed your code to make it compatible with slah commands?
I heard from somewhere that the prefixe thing wont work after April 2022?

lyric mountain
#

they will

next eagle
#

*slash

lyric mountain
#

you'll just need yet another privileged intent

#

nonetheless I'll use both slashes and normals

next eagle
next eagle
#

I am new into this...

lyric mountain
small tangle
next eagle
small tangle
#

on the discord dev portal

next eagle
small tangle
#

in your bot app

limber mica
#

I keep getting the error:

 Error: Cannot find module './commands/register.js'
Require stack:
- N:\Desktop\Stealth Dynamics Bot\commands\register.js
- N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js
- N:\Desktop\Stealth Dynamics Bot\bot.js

Code and stuff: https://pastebin.com/b6i5ZenU

Still wont stop not working

next eagle
small tangle
#

¯_(ツ)_/¯

delicate shore
#

Please I need help

#

I am using react

#
export const ProfileComponent = () => {
  const { user } = useAuth0()

let key = "temp"
fetch(`https://api.pgamerx.com/info/${user.email}`).then(res => res.json()).then(json => key = json)

  return (
    <Container className="mb-5">
      <Row className="align-items-center profile-header mb-5 text-center text-md-left">
        <Col md={2}>
          <img
            src={user.picture}
            alt="Profile"
            className="rounded-circle img-fluid profile-picture mb-3 mb-md-0"
          />
        </Col>
        <Col md>
          <h2>{user.name}</h2>
          <p className="lead text-muted">{user.email}</p>
          <p className="lead text-muted">{key}</p>
limber mica
#

no way your making a bot with react

delicate shore
#

This is my code
now problem is that even tho I am fetching the key
it's value never changes to the api key of the user

earnest phoenix
delicate shore
#

but when I console.log(json[0])

#

it gives me the api key

#

still on the page it says

#

it says temp

earnest phoenix
#

I have a feeling its cause the page is loading before the fetch is called

delicate shore
#

what should I do then

earnest phoenix
#

So it never updates to the api key it remains as temp

next eagle
limber mica
#

I keep getting the error:

 Error: Cannot find module './commands/register.js'
Require stack:
- N:\Desktop\Stealth Dynamics Bot\commands\register.js
- N:\Desktop\Stealth Dynamics Bot\handlers\command_handler.js
- N:\Desktop\Stealth Dynamics Bot\bot.js

Code and stuff: https://pastebin.com/b6i5ZenU

#

help me ;-;

delicate shore
earnest phoenix
#

iirc it does what you need

delicate shore
#

oh

earnest phoenix
next eagle
delicate shore
#

lemme try thanks

next eagle
#

Adding "./" at the start of it?

delicate shore
#

@earnest phoenix didnt work

#

or maybe im doing it wrong

earnest phoenix
#

Are you sure you aren't just doing it wrong

next eagle
earnest phoenix
#

you barely had time to read the documentation

limber mica
delicate shore
#

It gives some weird error

next eagle
earnest phoenix
#

Well having the error would be helpful yes

delicate shore
#
export const ProfileComponent = async () => {
  const { user } = useAuth0()
  let key = "temp"

   let res = await fetch(`https://api.pgamerx.com/info/${user.email}`)
  let json = await res.json()
  key = json[0]
   return(

my code

#
Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.
    in ProfileComponent (created by WithAuthenticationRequired)
    in WithAuthenticationRequired (created by Context.Consumer)
    in Route (at App.js:39)
    in Switch (at App.js:37)
    in div (created by Container)
    in Container (at App.js:36)
    in div (at App.js:34)
    in Router (at App.js:33)
    in App (at src/index.js:30)
    in Auth0Provider (at src/index.js:29)
▶ 26 stack frames were collapsed.
(anonymous function)

earnest phoenix
#

This is where im no longer helpful

delicate shore
#

this is my first time using React so I dont get a thing

next eagle
#

React always Freaked me out eyes_cry

delicate shore
quasi hearth
# delicate shore this is my first time using React so I dont get a thing

I think you have to return something with temporary values, while running the promise in parallel.
https://stackoverflow.com/questions/40029867/trying-to-implement-a-simple-promise-in-reactjs

wicked pivot
delicate shore
limber mica
#

@quartz kindle Im such a fucking dumbass

#

I fixed my issues

wicked pivot
#

I just don't understand: js return message.channel.send(embed);

quasi hearth
limber mica
#

What was happening was my register command was looking for all command files using ./commands/ meaning it would output the error cannot find file ./commands/register. Tricking us all

#

@shadow frigate ^^

delicate shore
#

im dying how can I solve this wtf

quasi hearth
wicked pivot
#

v13

quasi hearth
# wicked pivot v13

In v13, you have to send embeds, and other things like so:

message.channel.send({
  embeds: [embed]
});
next eagle
quasi hearth
#

Ikr

earnest phoenix
#

How is that complex

#

Ugly yea

#

complex no

#

Not to mention that does make things simpler

#

With that you can send multiple embeds with one .send

quasi hearth
#

Yeah, not really complex, but very confusing for people who forget v13 is a huge breaking change.

earnest phoenix
#

Eh

#

Every major update is a "huge breaking change"

quasi hearth
#

True, but v13 in particular is almost guaranteed to break your bot if you upgrade without fixing your code.

delicate shore
#

I will die Cry_Sus

earnest phoenix
#

No

#

Whats guaranteed to break your bot is if you don't switch to v13

#

api v7 will be deprecated soon

sacred aurora
delicate shore
sacred aurora
#

fetch it inside the useEffect

earnest phoenix
#

and then use it outside it

sacred aurora
#

with empty array as the thing

#

and dont make your component async

earnest phoenix
sacred aurora
#
export const ProfileComponent = () => {
  const { user } = useAuth0()
  const [key, setKey] = useState(null)

  useEffect(async () => {
    let res = await fetch(`https://api.pgamerx.com/info/${user.email}`);
    let json = await res.json();
    setKey(json[0]);
  }, [])

  return (
    <Container className="mb-5">
      <Row className="align-items-center profile-header mb-5 text-center text-md-left">
        <Col md={2}>
          <img
            src={user.picture}
            alt="Profile"
            className="rounded-circle img-fluid profile-picture mb-3 mb-md-0"
          />
        </Col>
        <Col md>
          <h2>{user.name}</h2>
          <p className="lead text-muted">{user.email}</p>
          {key && (<p className="lead text-muted">{key}</p>)}
#

some thing like that

eternal osprey
#

Hey does anyone know any npm package or api that shows live counter updates of nfts that are being sold?

delicate shore
#

Hey guys

#

Please guide me

#

I am using the js's inbuilt function fetch

#

how can I get headers with it

#

like

let res = await fetch(`website`)
let header = res.headers.get("header-name")

will it work like this?

quasi hearth
#

I'm having difficulty with receiving messages from direct messages for my bot. (discord.js 13)
I have instantiated the client with:

bot = new Discord.Client({
    intents: [
      "DIRECT_MESSAGE_TYPING",
      "DIRECT_MESSAGES",
      "GUILD_MESSAGES",
      "GUILDS",
      "GUILD_MESSAGE_TYPING"
    ]
  });

but the messageCreate event only receives messages from guilds, and not direct messages.

quartz kindle
#

enable channel partials

delicate shore
quartz kindle
#

.get(headername) should work

#

check if its not case sensitive

#

otherwise use headers.rawHeaders

#

or headers.raw() in node-fetch

delicate shore
#

I cant use node-fetch since it's vanilla js

delicate shore
#

I get an error - res.get isnt a function

wicked pivot
#
F:\code ranger\bot\bot juzoo\node_modules\discord.js\src\managers\GuildMemberManager.js:225
        throw new Error('GUILD_VOICE_CHANNEL_RESOLVE');
              ^

Error [GUILD_VOICE_CHANNEL_RESOLVE]: Could not resolve channel to a guild voice channel.
    at GuildMemberManager.edit (F:\code ranger\bot\bot juzoo\node_modules\discord.js\src\managers\GuildMemberManager.js:225:15)
    at GuildMember.edit (F:\code ranger\bot\bot juzoo\node_modules\discord.js\src\structures\GuildMember.js:250:31)
    at VoiceState.setChannel (F:\code ranger\bot\bot juzoo\node_modules\discord.js\src\structures\VoiceState.js:158:25)
    at F:\code ranger\bot\bot juzoo\assets\export\event\voicetemp.js:70:97
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  [Symbol(code)]: 'GUILD_VOICE_CHANNEL_RESOLVE'
}```
quartz kindle
#

no res.get is not a thing

#

its res.headers

delicate shore
#

oh

#

but res.headers.get isnt working either
when I fetch my api using apirequest.io
It gshows me headers

but when I use fetch
it doesnt

quartz kindle
#

res.headers.get() should work

#

but its case sensitive

delicate shore
#

yes ik that

#

btw it's a custom header
will that be a problem

quartz kindle
#

then try logging [...res.headers.entries()]

delicate shore
#

ok

quartz kindle
#

you have to log it like i showed

#

with [...]

delicate shore
#

ohok

delicate shore
#

only these 2

#

but when i use any other online service
it shows other as well

wicked pivot
#

it works, I just change the type of voice to guild_voice

quartz kindle
#

console.log res.status

delicate shore
#

okay

#

res.status not a function

#

wait nv

#

it's not a function it's just a

#

it says 200

delicate shore
#

let me find that

#

"There is a restriction to access response headers when you are using Fetch API over CORS. Due to this restriction, you can access only following standard headers:"

#

I have an idea

#

I can make a req to my api in my api

#

where there are headers

#

and then send that info in body

quartz kindle
#

you need to configure cors

quasi hearth
#

How would I have my discord bot "typing" for more than 10 seconds using discord.js 13

quartz kindle
#

you need to keep sending it

#

thank god they fixed that shit in v13

#

in v12 it used to keep sending automatically, but that made the promise only resolve when you stopped typing or when you sent a message

#

so doing something like this in v12 ```js
await channel.startTyping();
await channel.send("bla");

#

lmao

quasi hearth
#

yikes

delicate shore
quartz kindle
delicate shore
#

no

#

ohh

#

I use cors npm package

quartz kindle
delicate shore
#

holy shit

#

but like

#

god I will see this tomorrow

#

good ngith

lyric mountain
#

I had enough headache dealing with cors in my own api

earnest phoenix
#

hey is it correct to send attachments in inline-replies?

client.api.channels(message.channel.id).messages.post({
type: 1,
data: {
attachments: [ attachment ],
message_reference: { message_id: message.id }
}
})```
delicate shore
limber mica
#
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const fs = require('fs');
const Discord = require('discord.js')
const config = require('./config.json');
const messageCreate = require('./events/guild/messageCreate');

module.exports = {
    execute(client, message){



let CLIENT_ID = client.user.id
        let GUILD_ID = "754892982200565830"

        const commands = [];
        const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));

        for (const file of commandFiles) {
            const command = require(`./commands/${file}`);
            commands.push(command.data.toJSON());
        }
        const rest = new REST({ version: '9' }).setToken(config.login.token);
        (async () => {
            try {
                console.log(CLIENT_ID, GUILD_ID)
                console.log('[BOT-EVENTS] : Started refreshing application (/) commands.');
                console.log(commands)
                await rest.put(
                   Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID),
                   { body: commands },
                ).then(console.log)

                console.log('[BOT-EVENTS] : Successfully reloaded application (/) commands.');
                message.channel.send("Succesfully set the commands!")
            } catch (error) {
                console.error(error);
            }
        })
            ()
    }
}

code does not work, slash commands cant be seen but I can log them and when i use them it does not fire the event

#

im dying

lyric mountain
delicate shore
#

I am using the cors npm package

#

I figured something

lyric mountain
#

the issue with cors isn't on the client side

#

but on the api side

delicate shore
#
const corsOptions = {
exposedHeaders: //
}

what should come here
I want everyone to be able to get every header

lyric mountain
#

var

delicate shore
#

there

lyric mountain
delicate shore
#

how?
I have to enable CORS for people to be able to use my api in localhost and stuff as well

lyric mountain
#

allow all methods for /**

delicate shore
#
const corsOptions = {
exposedHeaders: ['x-ratelimit-remaining']
}

this should work?
I mainly want this one

lyric mountain
#

headers are case-sensitive

delicate shore
#

yes ik that

fallen holly
#

have they changed mentions in v13 cus this not woking message.mentions.members.first()

lyric mountain
#

v13 changed almost everything

fallen holly
#

so how i do the message.mentions.members.first()

#

in v13

lyric mountain
#

check the docs

delicate shore
#

IT WORKED OMFG OMFG OMFG @lyric mountain THAKNK

lyric mountain
#

np

hot sleet
#

how to get owner username from message.guild.fetchOwner()

lyric mountain
#

<member>.user.name ig

hot sleet
#

.............

#

it return promise

lyric mountain
#

await it

hot sleet
#

oh

lyric mountain
#

or handle it inside the promise

delicate shore
#

where is this coming from

#
<!DOCTYPE html>
<html class="h-100">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/png" href="./public/images/logo.jpeg"/>
    <title>Dashboard Home Page | Random Stuff Api </title>
    <link
      rel="stylesheet"
      href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
    />
    <link rel="stylesheet" type="text/css" href="/css/main.css" />
    <link
      rel="stylesheet"
      href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/monokai-sublime.min.css"
    />
    <link
      rel="stylesheet"
      href="https://use.fontawesome.com/releases/v5.7.2/css/solid.css"
      integrity="sha384-r/k8YTFqmlOaqRkZuSiE9trsrDXkh07mRaoGBMoDcmA58OHILZPsk29i2BsFng1B"
      crossorigin="anonymous"
    />
    <link
      rel="stylesheet"
      href="https://use.fontawesome.com/releases/v5.7.2/css/fontawesome.css"
      integrity="sha384-4aon80D8rXCGx9ayDt85LbyUHeMWd3UiBaWliBlJ53yzm9hqN21A+o1pqoyK04h+"
      crossorigin="anonymous"
    />

    <link
      rel="stylesheet"
      href="https://cdn.auth0.com/js/auth0-samples-theme/1.0/css/auth0-theme.min.css"
    />
  </head>
#

the logo is a diff image

#

I downloaded this template and have spent hours trying to figure out how to change the favicon

earnest phoenix
delicate shore
lyric mountain
#

favicon.ico

#

put it on the same folder as index.html

#

or define the path on header

hot sleet
earnest phoenix
#

oh idk about v13. I am gonna start tomorrow xd

delicate shore
hot sleet
#

i fixed it btw

let owner = await message.guild.fetchOwner().then(owner => owner.user)

console.log(owner.username)```
lyric mountain
#

site files

#

I didn't say "site code"

#

favicon doesn't need to be declared

delicate shore
#

i mean

#

there is no file

#

with logo.ico or favicon.ico

#

file

lyric mountain
#

where are you checking it?

delicate shore
#

wait you want me to add it?

delicate shore
lyric mountain
pale vessel
#

It literally says there <link rel="icon"

delicate shore
#

I just added the favicon.ico

delicate shore
#

but problem is

lyric mountain
#

btw, is it a react project?

#

just declare the icon on the config file

delicate shore
#

this is logo file

delicate shore
lyric mountain
#

too big

#

too fuckin big

delicate shore
#

I added this
now where to declare

delicate shore
#

but it still shows React Logo for some reason

#

and maybe it's react im confused

lyric mountain
#

first of all, reduce your favicon size to about 32x32

delicate shore
#

it's not react tbh

lyric mountain
#

see if it appeared

#

if not, configure the favicon tag

#

<link rel="icon" type="image/png" href="/favicon.png"/>

delicate shore
#

okay

#

it's favicon.ico

#

not png

lyric mountain
#

change it accordingly

#

but just by being named favicon.ico should be enough

#

browsers will auto-pick it

#

and iirc, just by renaming .jpeg to .ico won't work

#

you need to properly convert it

delicate shore
#

didnt workwtf

lyric mountain
#

and iirc, just by renaming .jpeg to .ico won't work

#

ico is a format, not a jpeg under disguise

delicate shore
#

I converted it online

lyric mountain
#

and mb, it's 16x16 not 32x32

delicate shore
#

ok

pale vessel
#

The size shouldn't matter

delicate shore
#

I will do rest tomorrow I am tired bye

pale vessel
#

You'd generally want it small since it doesn't need to be big

delicate shore
#

but my main problem is that I cant find what piece of code is causing this favicon to appear

vivid fulcrum
#

are you sure it's just not your browser cache

hot sleet
#

idk how new Intents work
can someone explain please ?

lyric mountain
#

as I said, if it IS a react project you need to change the config file

#

I mean, default icon is a blank page not react's

delicate shore
#

It's not react

#

man

#

what do i do lfmao

lyric mountain
#

press f12

#

go to sources

#

try to find the favicon there

hot sleet
#

i mean if i want to fetch guild members i have to include Intents.FLAGS.GUILD_MEMBERS ?

lyric mountain
#

then see the path to it

delicate shore
#

this favicon wtf

#

where is it

#

oh it's the on i uploaded

lyric mountain
#

ye, not the one you're searching for

#

keep looking

#

there HAS to be a react icon somewhere

rigid maple
#

Hi, i am very bad with filter() method so i need your help

lyric mountain
#

how can you be bad with a boolean check?

rigid maple
spark breach
#

can someone please help me? I am trying to make a ban command and trying to find if the person that wrote the command has a higher role than the target. Although I can't figure out how to do it, I've searched on google and taken their tips but I keep getting the same error.

Code:

                        message.channel.send(Error4);
                    }```
```const member = message.mentions.users.first();```

error:
``` if(message.author.roles.highest.position > member.roles.highest.position) {
                                            ^
TypeError: Cannot read property 'highest' of undefined```

Error4 is an embed
Using discord.js@12.5.3

Any help would be appreciated! (If more code is needed I'll gladly provide)
lyric mountain
#

why don't u just use the member object to start with?

#

instead of the user object

#

event.member

lyric mountain
#

author is an user not a member

spark breach
#

ohhhh alright

lyric mountain
#

do message.member

spark breach
#

I'll try it, thank you!

#

it shows the same except on the other side now

                                                                                                   ^
TypeError: Cannot read property 'highest' of undefined```

that highest
#

ahyes that worked

lyric mountain
#

member is not defined

spark breach
#

it should be since I have this:
const member = message.mentions.users.first();

lyric mountain
#

note what you wrote

#

message.mentions.users.first()

spark breach
#

o h

lyric mountain
#

users don't have roles

spark breach
#

I am blind once again ty xD

lyric mountain
spark breach
#

I was about to ask what was wrong now but then I realised I misspelled a word
I am smart 404

lyric mountain
#

go slowly

#

you're going so fast that you're tripping everywhere

spark breach
#

true, thanks!

spark breach
#

btw works now had some bug fixing to do with my embed, once again thanks so much!

wicked pivot
#

join voice on v13 ?

restive furnace
#

@discordjs/voice

rigid maple
#

hey

#

how do i get the names of a user's permissions (bitfields) on the server

#

input: 37080640
output: ["SEND_MESSAGES", "READ_MESSAGES"]....

zenith terrace
#

you could do <GuildMember>.permissions.serialise()

rigid maple
#
console.log(user.guilds.find(a => a.id === guild.id).permissions.serialise())
``````md
[ERR]: user.guilds.find(...).permissions.serialise is not a function
pale vessel
#

Bri'ish Stargirl

#

serialize()

rigid maple
#

it didn't work, i typed it wrong and tried it first :D

#

user.guilds.find(...).permissions.serialize is not a function

#
user.guilds.find(a => a.id === guild.id).permissions // ex: output: 37080640
quasi hearth
rigid maple
#

yes

#

I'm trying to find out if a user has MANAGE_GUILD authority on the server using ejs.

quasi hearth
#

hmm

rigid maple
#

What can I do ?

#

It was working when I did this in v12 but now it's broken

#
   <% user.guilds.map(guild => {
      const permsOnGuild = new perms(guild.permissions);
      if(!permsOnGuild.has("MANAGE_GUILD")) return;
          user.guilds.filter(x => bot.guilds.cache.get(x))
  %>
  <% if (!bot.guilds.cache.get(guild.id)) { %>
#

perms = new Discord.Permissions

quasi hearth
#

so, you are basically doing new new Discord.Permissions? What happens if you do perms = Discord.Permissions?

rigid maple
#

I can't write it without using new because it's a class

quasi hearth
#

oh

rigid maple
#

new:

<% user.guilds.map(guild => {
console.log(user.guilds.find(a => a.id === guild.id).permissions.serialize())
user.guilds.filter(x => bot.guilds.cache.get(x))
%>
#

but this is not working (user.guilds.find(...).permissions.serialize is not a function)

quasi hearth
#

and user is a Discord.Client right?

rigid maple
#

no

#

logged in user

#

so me, you, he

quasi hearth
rigid maple
#

user: req.isAuthenticated() ? req.user : null

#

User passing checkAuth

#

discord account login system

#

Let me log the user to the console too

quasi hearth
rigid maple
#

user.guilds.permissions => grants the user's authority on the server

#

but as a bitfield

quasi hearth
#

like, is it a number? a string? and array? a buffer?

rigid maple
#

ex: 1194851905

#

Number

#

Bitfield

#

for example the output of 1194851905 is ;

#

i learned this through a website

quasi hearth
#

one sec, testing some stuff

rigid maple
#

my purpose is to extract this array from this number anyway

#

ok I'm wait

#

Can you tag when you come?

quasi hearth
# rigid maple for example the output of 1194851905 is ;

Try:

<% user.guilds.map(guild => {
  const permNum = user.guilds.find(a => a.id === guild.id).permissions;
  const permObject = new Discord.Permissions(`${permNum}`);
  console.log(permObject.serialize());
  user.guilds.filter(x => bot.guilds.cache.get(x))
%>
rigid maple
#

thank you so much king

quasi hearth
#

No problem!