#development

1 messages · Page 1952 of 1

earnest phoenix
#

ty

#

I made fs read a sqlite file every 9s to save the file even when i'm not in replit and it's working, like a week passed and no corruption or anything...

lyric mountain
#

Oh my

earnest phoenix
#

it's a test bot btw, the real one is safe

lyric mountain
#

What's the influx of data?

earnest phoenix
#

influx of data?

lyric mountain
#

You'll only face corruption when you have a steady IO flux

#

Like, many reads/writes per second

earnest phoenix
#

yeah I'm reading it every 9s and a week passed

lyric mountain
#

Not with fs

#

I mean database operations

earnest phoenix
#

oh

#

then it's better not to add this stuff?

lyric mountain
#

For example, if the database is in the middle of an operation and you fs the file boom, corruption

earnest phoenix
#

ok

#

uh, no corruption showed even when i'm spamming commands where the db has to add, subtract and delete stuff

#

¯_(ツ)_/¯

lyric mountain
#

That's cuz sqlite

#

It's really hard to force a slow operation on the fastest db

earnest phoenix
#

oh

lyric mountain
#

You need to get a thousand ops running "at the same time"

#

Note quotes

earnest phoenix
#

ok

#

ty

lyric mountain
#

Try insert-deleting very quickly

earnest phoenix
#

I'll better continue using vsc and railway

lyric mountain
#

Like, insert 1000, delete 300, insert 1200, delete 1000, insert 500, etc

#

Then fs save it during the sequence

earnest phoenix
#

ok

lyric mountain
#

And put it into a loop, not manually

#

You'll never be fast enough alone

earnest phoenix
#

yep the db blasted

#

did that

compact pier
#

my website is optimized (except the perfomance, cause I don't use webpack)

sudden geyser
#

nice

cinder patio
#

why would webpack lower performance?

compact pier
#

it doesn't

sudden geyser
#

probably meant to invert that question

compact pier
#

I can't add the webpack to my app

#

in some way

#

just some dumb error that I can't google

cinder patio
#

ah

#

I mean 87 is good

#

and yes I completely misread that

compact pier
#

me too

#

I wrote expect instead of except

#

lol

sudden geyser
#

isn't webpack just a protocol buffer

compact pier
#

it split files

#

so the file requirement will be faster

#

cause the files are lighter

#

=> rendering is faster

quartz kindle
#

depends on the configuration

#

webpack is a bundler, it can be configured in a billion different ways, it wont necessarily improve performance

compact pier
#

i think so..

quartz kindle
#

not really

sudden geyser
#

To my knowledge, it's used to reduce bandwidth.

cinder patio
#

AFAIK by performance lighthouse means how fast the page takes to load. That means time to download assets

quartz kindle
#

its mostly used to handle stuff like css/js versioning for cache bypass, merge js files into one, and some other quality control features like minification with source maps

#

and often also transpiling js/ts into older versions for compatibility

lyric mountain
#

var 😔

quartz kindle
#

var var var

#

honestly i dont like webpack

#

but i only tried it once

lyric mountain
#

Errr...you mean send embed?

#

Afaik you do it normally

#

See the docs

sudden geyser
lyric mountain
#

The only mistake you did was passing a type instead of an actual embed

eternal osprey
#

Why the fuck hasn’t discord verified my intents yet

sudden geyser
#

intents verification is always slow

eternal osprey
#

I have requested it like 6 days ago and haven’t had a single response since

lyric mountain
eternal osprey
#

2 months!!!!??

lyric mountain
#

They kept sending the same email again and again

#

Until I sent a long complaint email

#

Then finally a human wrote an email to me

eternal osprey
#

Is there any way I could teach their support?

#

Reach*

sudden geyser
lyric mountain
#

Asking for a few images/gifs of functionality usage

eternal osprey
lyric mountain
# sudden geyser did they bother to say sorry
Hey KuuHaKu​​,

Thanks for reaching out and applying for privileged intents! Everything is looking good so far. We had some additional questions to continue with the process:

Would you be able to provide some screenshots or short videos of your bot's moderation and custom answer functionality?

Thanks in advance!
Shipwreck​
sudden geyser
#

lol they didn't

eternal osprey
#

Whahahahha erg

sudden geyser
#

and that's just a copy paste response

compact pier
#

how long it take for a dns changes?

lyric mountain
#

Before that all they asked was stuff I already answered on the intent form

eternal osprey
#

Wtf, I will try to contact their support later on to get a rough estimate on how long it will take.

lyric mountain
#

It's like sending a CV then being asked your professional experience

eternal osprey
#

cuz 2 months? That is fucking longer than topgg’s own bot verification

lyric mountain
#

Yeah, some get it earlier and some later

#

I even sent 6 or 7 gifs of the features that required message intent

#

On the form

#

I really doubt they even opened 'em

eternal osprey
#

Whahahahah wtf

#

Just realised my pics are hosted on an image platform that deleted the gifs and images after 1 month

#

for fuck sakes

lyric mountain
#

Onedrive hosts images sent as attachments

#

You can just attach it normally

#

U added a subcommand

#

That's why

#

Just do it then

#

/category subcategory command

#

This is the structure for commands

#

/command
/category command
/category subcategory command

#

Actually

#

Add a command

#

Not a subcommand

#

I guess

#

You still need to delete the old command

#

Else you'll get duplicate name error

#

You need to supply type

boreal iron
#

For the command option you set

#

The type of the option could be a string, number, user, channel etc.

eternal osprey
#

Too*

lyric mountain
#

Just keep answering their emails

#

Eventually they'll send a human

#

After that it'll take at most 1 week or so

boreal iron
#

You should stop register commands multiple times

#

create() does register a command and a command does only need to be registered once

#

If you run the code again and register the same command again this issue can happen even if the code responded to the interaction

#

Update the commands using the method set()

#

This does overwrite all commands, guild commands in your case

earnest phoenix
#
  client.guilds.cache.get('834615041537867806')?.commands.set(commandfile.name, commandfile)

Would that not work to load guild only commands?

boreal iron
#

Depends on the structure of the var commandfile

#

It needs to be a valid application command structure

#

An object with a name, description and optionally options

earnest phoenix
#
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
#
client.commands = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
const data = []

for (const file of commandFiles) {
  const commandfile = require(`./commands/${file}`);
  client.guilds.cache.get('834615041537867806')?.commands.set(commandfile.name, commandfile)
  data.push({
    name: commandfile.name,
    description: commandfile.description,
    options: commandfile.options
  })
}```
#

That's the full thing 🤣

hidden gorge
#

Actually it does not it gives random responses

boreal iron
#

In your case data would be what you can push as 2nd parameter in set()

#

I don’t get why you push an array called data

#

What’s it’s purpose?

#

log commands and you will see why map() isn’t available

#

And what’s the result?

#

commands is the command application resolver

#

Not just a property

earnest phoenix
#

Oh shit @solemn latch

unkempt ocean
spark flint
#

how do i get a users flags

#

using discordjs

#

or better how do i see if a user has X flag

earnest phoenix
spark flint
#

i'm using v12

earnest phoenix
#

idk

proven lantern
#

@modern sable ^

#

dang

#

sorry for the ping

proven lantern
#

ty

#

there was a nitro spammer and it was deleted right when i pinged

#

pls forgive me

hollow prawn
#

does anyone know or have a "behind the scenes" of how interactions work, more in particular im wondering is discord receiving information as of what slash command interactions my bot has and provides those to the user so they can see and execute them? or does it actually send a message with the slash command and the bot reads it and works with it?
as well can I even change the slash command's slash to something else as writing a slash on mobile is kind-of annoyingly hard where on pc it is easier

sudden geyser
#

is discord receiving information as of what slash command interactions my bot has and provides those to the user so they can see and execute them? or does it actually send a message with the slash command and the bot reads it and works with it?
Most likely the former.

#

Given you upload your commands and Discord dispatches them

proven lantern
sudden geyser
#

can I even change the slash command's slash to something else
No

hollow prawn
proven lantern
#

if you use a library it takes care of this part for you

#

i think

hollow prawn
#

yeah i do use DJS library

lyric mountain
#

is there a way to either get a table name or make a "inverse" switch-case?

#

or at least a non-null type

sudden geyser
#

confuzzled

#

what's a table in this context

lyric mountain
#

ok, I'll explain the full context

#
SELECT c.id
     , CASE /* HERE WHAT? */
           WHEN ch.card_id THEN 'SENSHI'
           WHEN eq.card_id THEN 'EVOGEAR'
           WHEN fd.card_id THEN 'FIELD'
           ELSE 'KAWAIPON'
    END AS type
FROM card c
         LEFT JOIN champion ch ON ch.card_id = c.id
         LEFT JOIN equipment eq ON eq.card_id = c.id
         LEFT JOIN field fd ON fd.card_id = c.id
WHERE c.id = :id
sudden geyser
#

oh sql

#

out of here

lyric mountain
#

you see, I'm trying to find in which table the join doesn't return null

proven lantern
#

database is for storing state

#

not doing logic stuff

lyric mountain
#

to find out the card's type

sudden geyser
#

databases are inherently logical

#

sql at least

lyric mountain
#

sql is turing-complete actually

sudden geyser
#

not as fun as datalog but still good enough

lyric mountain
#

it's certainly not impossible to do what I'm trying to, and it'll probably be better than my current method

#

thing is, I need to check which column ISN'T null

#

ah wait

proven lantern
#

like an outer join without the inner join stuff?

sudden geyser
#

NOT NULL?

lyric mountain
#

doesn't work

sudden geyser
#

sadge

lyric mountain
#

I'll try converting null/nonnull to boolean

proven lantern
#

write a program that fixes the data

lyric mountain
#

it will never fix

#

cuz there's nothing to be fixed

#

you see, a card can have 3 types

#

champion, equipment or field

#

so if it's a champion, it'll always be null in the other 2

proven lantern
#

move the logic part to the program. fetch the data from the db and do the logic stuff in the program

sudden geyser
#

oh please don't

proven lantern
#

lol

sudden geyser
#

that never works out

lyric mountain
#

meh, I might just make a "booleanize" procedure

#

oh wait

#
SELECT c.id
     , CASE FALSE
           WHEN ch.card_id IS NULL THEN 'SENSHI'
           WHEN eq.card_id IS NULL THEN 'EVOGEAR'
           WHEN fd.card_id IS NULL THEN 'FIELD'
           ELSE 'KAWAIPON'
    END AS type
FROM card c
         LEFT JOIN champion ch ON ch.card_id = c.id
         LEFT JOIN equipment eq ON eq.card_id = c.id
         LEFT JOIN field fd ON fd.card_id = c.id
WHERE c.id = :id
#

I was thinking too much

#

forgot "IS NULL" exists

sudden geyser
#

I was thinking of that too

#

but given you said not null doesn't work I didn't know if that would too

#

statements vs. expressions man

lyric mountain
#

not null doesn't, but is null does booleanize it

#

or you meant IS NOT NULL?

sudden geyser
#

both

#

Do you really need that FALSE in there though

lyric mountain
#

yep to evaluate which case will be the correct one

#

funny enough, IS NULL with FALSE is returning 30ms faster than IS NOT NULL with TRUE

#

or it might just be too few samples to make a proper benchmark

sterile lantern
#

How would I fetch the user's current avatar URL and put it next to their tag on a website? Rn it's just:

 <div class="accordion-item">
                  <button id="accordion-button-1" aria-expanded="false"><span class="accordion-title">Developer</span><span class="icon" aria-hidden="true"></span></button>
                  <div class="accordion-content">
                    <p>samm#0021</p>
                  </div>
                </div>```
lyric mountain
#

so like, all will return false but one, which will be the correct card type

sterile lantern
#

ic

lyric mountain
#

you can also use oauth2 iirc, just need to use proper scope

sterile lantern
#

yeah

eternal osprey
#

What type of members are being cached

#

Only online users right?

earnest phoenix
#

I have a typescript module uploaded to github but I don't know how to make it transpile when I install it

quartz kindle
#

have typescript as a dependency

#

and add an install script in your package.json

simple stump
#

How do I check if a message already has a thread?
I get this error when clicking the "Discuss" button.

/home/container/node_modules/discord.js/src/structures/Message.js:765
    if (this.hasThread) return Promise.reject(new Error('MESSAGE_EXISTING_THREAD'));
                                              ^

Error [MESSAGE_EXISTING_THREAD]: The message already has a thread
    at Message.startThread (/home/container/node_modules/discord.js/src/structures/Message.js:765:47)
    at Client.<anonymous> (/home/container/index.js:1131:27)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  [Symbol(code)]: 'MESSAGE_EXISTING_THREAD'
}

Line 1131

interaction.message.startThread({
        name: 'suggestion',
        autoArchiveDuration: 60,
        reason: 'Suggestion',
      });

Full if statement

if (interaction.customId === "discuss") {
      await interaction.deferReply({ ephemeral: true });
      interaction.message.startThread({
        name: 'suggestion',
        autoArchiveDuration: 60,
        reason: 'Suggestion',
      });
      await interaction.editReply("Started thread.");
    }
wheat mesa
supple oriole
#

I got a working Automemes Command using Mongodb. But it works only after I restart the bot. [Using client on ready] How do I make it work so it starts after I set the channel. (Multi Guild)
AutoMemes Event Folder: https://sourceb.in/d1sUTaZV4M

sacred aurora
shell quartz
#

hi

supple oriole
#

¯_(ツ)_/¯

sacred aurora
supple oriole
sacred aurora
#

I think the best way is to make a handler just for that

supple oriole
#

how e

sacred aurora
#

Cause when you change the channel, you need to delete the old interval and make a new one

supple oriole
#

hu-

sacred aurora
#

OR

#

you can make a global variable or put it on client that hold all the current meme channel with guild id as its key

supple oriole
#

am lost

sacred aurora
#

Hmmm

#

Well there's the solution

supple oriole
#

e

earnest phoenix
#

What's tofu the bot command

compact pier
#

is there anyway to return raw json file from react?

cinder stratus
novel jetty
#

Any idea how i can get my database ping?

cinder stratus
#
const timestamp = Date.now();
//request to your db
const timeTaken = Date.now() - timeStamp;
#

That how you would do in js

#

If you are using any other language the logic should be still same

novel jetty
#

Gotcha

#

Thanks

cinder stratus
cinder stratus
#

Noo

#

Unless you are caching

#

Can you show the code?

novel jetty
# cinder stratus Can you show the code?
import { CommandProps, Command } from "../../@types";
import { db } from '../..'
import Discord from 'discord.js'
export = {
  name: "ping",
  category: "misc",
  aliases: [],
  description: "Check Bot ping",
  usage: "",
  cooldown: 5000,
  run: function (e: CommandProps) {
    const {
      message, args, client
    } = e;

    const timestamp = Date.now();
    //request to your db
    const timeTaken = Date.now() - timestamp;

    message.channel.send(`Calculating Ping...`).then(p =>{
      const ping = p.createdTimestamp - message.createdTimestamp

      const embed = new Discord.MessageEmbed()
        .setColor('GOLD')
        .setDescription(`:ping_pong:**Ping:** ${ping}ms\n :clock1230:**API Ping:** ${client.ws.ping}ms\n**Database Ping:** ${timeTaken}ms`);
      p.edit({ embeds: [embed], content: null, allowedMentions: { repliedUser: false } });

    })
    
    
  }
} as unknown as Command
cinder stratus
#

You literally copy pasted that

#
//request to your db
#

Part was supposed to be

#

Where you make request to your database

novel jetty
#

?

cinder stratus
#

What db you use?

novel jetty
#

Im a bit lost here

novel jetty
cinder stratus
#

ORM?

novel jetty
#

orm?

#

Im using MongoDB database

cinder stratus
#

Object relation mapping

#

What package you use?

novel jetty
#

mongoose

#

quickmongo

#

These are all my packages

cinder stratus
#

I see mongoose

#

You can make a request like this Schema#findOne()

#

Or something

#

I am afraid I can't help more than that

novel jetty
#

Right

signal estuary
#

Is it possible to send a message to the user who invited the bot via bot? discordjs

gentle condor
#

how do i loop through every key in mongodb and get the key which contains a specific value? (edited)
like i have 3 keys:

{"user":"blob","skill":"conding"}
{"user":"JoJo","skill":"dancing"}
{"user":"Ben","skill":"coding"}
so i only want to get those who has coding skill

sacred aurora
#

wut

gentle condor
#

mongodb

#

btw i found the solution

sacred aurora
#

you can just

<Collection>.findOne({skill: "coding" });
#

ah alright

gentle condor
#

ty

novel jetty
#

Any idea why the button is sending "Interaction Failed"?

import { CommandProps, Command } from "../../@types";
import Discord, { Interaction, MessageActionRow, MessageButton, MessageEmbed } from 'discord.js'
export = {
  name: "button",
  category: "",
  aliases: [],
  description: "",
  usage: "",
  run: async function (e: CommandProps) {
    const {
      message, args, client
    } = e;
    if (!message.guild)
      return;

      const embed = new MessageEmbed()
        .setAuthor('Help Desk')
        .setColor('GOLD')
        .setDescription(`Select your category by pressing a button of your choice!`)


        const button = new MessageActionRow()
          .addComponents(
            new MessageButton()
              .setLabel('Moderation')
              .setCustomId('mod')
              .setEmoji('👑')
              .setStyle('SUCCESS')
          )

            message.reply({ embeds: [embed], components: [button]})

            const collector = await message.createMessageComponentCollector();
              collector.on('collect', async i => {
                if(i.customId === 'mod') {
                  await i.update({ content: 'A Button was clicked!', components: []})
                }
              })

  }
} as unknown as Command
sacred aurora
#

why are you collecting it from the user message

novel jetty
#

?

sacred aurora
#

message.createMessageComp.....

novel jetty
#

Oh

sacred aurora
#

i dunno if it works with reply, but you should save the reply as variable then collect from it

#

so

const msg = await message.reply(....);
const collector = msg.createMessage.....;
collector.on(....)
novel jetty
#

?

sacred aurora
#

i guess??

#

i never used message component tbh

novel jetty
#

I see

#

Thanks

novel jetty
#

Anyone know how i can fix this?

sacred aurora
#

wut

#

did someone ping me or something

gentle condor
#

i need some help

#

i tried the code you gave me

#

it returns <pymongo.cursor.Cursor object at 0x7fee812eba60>

#

so now how do i get the key from this?

sacred aurora
#

oh wait, u used py?

gentle condor
#

yes

sacred aurora
#

lemme read the docs

gentle condor
#

lol

#

docs are confusing

sacred aurora
#
<Collection>.find_one({skill: "coding" });
#

maybe

#

or did you already do it like that?

gentle condor
#

it returns only

#

the first key

#

with that

sacred aurora
#

ah

gentle condor
#

skill

sacred aurora
#

just use find then

gentle condor
#

find_them

#

?

sacred aurora
#

just find

spark flint
gentle condor
#

i tried it

#

it retuns <pymongo.cursor.Cursor object at 0x7fee812eba60>

#

this

spark flint
#

Then add .toArray() at the end

sacred aurora
#

isn't that js

#

or is it the same

gentle condor
spark flint
#

I’m on mobile rn

spark flint
gentle condor
#

oh

sacred aurora
#
<Collection>.find({skill: "coding" }).toArray();
gentle condor
#

what does it return?

#

wait

sacred aurora
#

an array

gentle condor
#

let me try

sacred aurora
#

in js

gentle condor
#

collection.find({"sh":pokemon}).toArray() AttributeError: 'Cursor' object has no attribute 'toArray'

#

@sacred aurora

spark flint
#

Oh

#

2 secs

gentle condor
#

k

spark flint
#

Oh I think I know

sacred aurora
#

pymongo doesn't need toArray then

spark flint
#

Try list(the collection thing)

#

Get rid of toArray and put it inside list()

gentle condor
#

@spark flint , now how do i get just the id of the user from this:

[{'_id': ObjectId('61d2d679de9767e5ce917162'), 'user': 742612257275641876, 'sh': 'rayquaza'}, {'_id': ObjectId('61d2dbe855819c0b1d2f9aa3'), 'user': 682489392207626271, 'sh': 'rayquaza'}]

spark flint
#

Exactly

#

Now you can do for <variable> in <list>

#

id = <variable>._id

gentle condor
#

sorry im kinda new to py

spark flint
#

are you printing list(collection……)

gentle condor
#

yes

#

it gave me that

spark flint
#

do something like

all = list(collection …….)

spark flint
#

then

for one in all:
id = one._id

gentle condor
#

ohhh

gentle condor
spark flint
#

Indentation error by any chance?

gentle condor
#
      f = list(collection.find({"sh":pokemon}))
      for one in f:
        id = one.user

      await interaction.response.send_message(f"yo {id}")
#

says it has no attribute user

gentle condor
gentle condor
#

ok

spark flint
#

Oh shit yeah

#

It’s not JavaScript

gentle condor
#

@spark flint

#

can you help me a little

gentle condor
#
      f = list(collection.find({"sh":pokemon}))

      for one in f:
        id = one["user"]
#

i have this code now

#

how do i add every single user to a string and send them at once

spark flint
#

all = “ “

#

then for each loop all = all + f”, {id}”

feral aspen
#

Apparently, the code is trying to tell you that command.options does not return an array that allows you to use the .map() method.

solemn elk
#

@marble juniper

from javascript import require, On
mineflayer = require('mineflayer')
pathfinder = require('mineflayer-pathfinder')

RANGE_GOAL = 1
BOT_USERNAME = 'python'

bot = mineflayer.createBot({
  'host': 'mc.scopes.cf',
  'port': 25653,
  'username': BOT_USERNAME
})

bot.loadPlugin(pathfinder.pathfinder)
print("Started mineflayer")

@On(bot, 'spawn')
def handle(*args):
  print("I spawned 👋")
  mcData = require('minecraft-data')(bot.version)
  movements = pathfinder.Movements(bot, mcData)

  @On(bot, 'chat')
  def handleMsg(this, sender, message, *args):
    print("Got message", sender, message)
    if sender and (sender != BOT_USERNAME):
      bot.chat('Hi, you said ' + message)
      if 'come' in message:
        player = bot.players[sender]
        print("Target", player)
        target = player.entity
        if not target:
          bot.chat("I don't see you !")
          return

        pos = target.position
        bot.pathfinder.setMovements(movements)
        bot.pathfinder.setGoal(pathfinder.goals.GoalNear(pos.x, pos.y, pos.z, RANGE_GOAL))

@On(bot, "end")
def handle(*args):
  print("Bot ended!", args)
#

It stops at the first print statement

marble juniper
solemn elk
#

Perfect

#

Thanks

signal estuary
#

I have a message filter here

const msgCol = (m) => m.author.id === inter.user.id;

and a collector:

const channelCollector = inter.channel.createMessageCollector({ msgCol });

But for any reason the filter doesnt work and it collects messages from user who didnt create the interaction

quartz kindle
#

because you didnt set a filter

#

{ filter: msgCol }

#

if you do { msgCol }, thats a shortcut for { msgCol: msgCol }

#

there is no msgCol parameter in the collector options

#

whereas if you name your filter filter, then you can do { filter }, because its a shortcut for { filter: filter }, and filter is a valid collector option

#

so unless you name it exactly as the name of the option you want, you need to specify the name of the option in the object

marble juniper
#

the python thing is just the bridge doing it

earnest phoenix
#

but that code is py

#

may i ask why

marble juniper
#

mineflayer has no native python implementation

earnest phoenix
#

minecraft is java/c++

#

discoord
works only with prime go or rust or pubg 3HC_sweat

#

wait slash commands have permissions now?

spark flint
#

How can I get a users Guild profile pic with DiscordJS v12?

quartz kindle
spark flint
#

ah

#

so its not possible with djs

quartz kindle
#

await client.api.guilds(id).members(id).get()

spark flint
#

that would work right?

quartz kindle
#

yes

broken kelp
#

.

gentle condor
quartz kindle
#

you doesnt help

earnest phoenix
#

how can I filter a object by same content? like ```js
let obj = {
"obj": {age: 22, brick: "Not a brick"},
"obj2": {age: 23, brick: "Yep"},
"obj3": {age: 22, brick: "Homie"}
}
//Filtered output:
obj, obj3 //they have same age

#

the example doesn't make sense but it's a example...

#

oh google helped

gentle condor
pallid vale
#

-needdev, hi i have a server with my stickers uploaded but i need a bot to upload the stickers as images, because i lost my original stickers because my computer had to factory reset because chrome browser kept crashing. thank you for reading in advance

cinder patio
compact pier
#

or just use chrome dev tool

feral aspen
#
/* Logging Direct Messages */
if (message.channel.type === "dm") console.log(`${bold(time.toLocaleString())} | [${magenta('LOG')}] - Direct Message: User Information: ${message.author.tag} (${message.author.id}) Message Content: ${message.content}`);

Am I not able to log the content of the direct messages?

compact pier
#

did u enable the dm intents?

feral aspen
#

I did.

compact pier
#

dont actualy

#

but other things console log?

#

@feral aspen

feral aspen
#

Yes.

compact pier
#

DIRECT_MESSAGES u enabled this thing?

feral aspen
#

Indeed.

compact pier
#

maybe it is a embed?

#

or sticker

#

so it won't be displayed to content

feral aspen
#

It's a legit message.

#

I'm doing this on the messageCreate event, too.

#

Did I do something wrong, like?

compact pier
#

at line 16

#

u stoped the code

feral aspen
#

I stopped it with a log, that's how JS works.

compact pier
#

yes

feral aspen
#

So?

compact pier
#

so it should log hi

#

but after that

#

it won't

feral aspen
#

I came here since it doesn't.

feral aspen
compact pier
#

you made return console.log()

#

so the code will stop

#

right?

feral aspen
#

That's what I want..

compact pier
#

yes

#

so It won't display the message.content

#

becasue the code is not executed

#

when u stoped the code before that

feral aspen
#

Honestly, if you just log message.content and send a message via DMs, it doesn't work. ;-;

compact pier
#

and it is not dm

#

it is

#

wait

feral aspen
compact pier
#

cap

quartz kindle
#

uppercase

compact pier
#

yes

feral aspen
#

Congratulations, it didn't work. 😂

#

I'm confused.

compact pier
#

bro, we trying to help you here and you write like kinda rude :<

feral aspen
feral aspen
#

Although, I am yet to explain to you the following:

Honestly, if you just log message.content and send a message via DMs, it doesn't work. ;-;

compact pier
#

but it console log hi?

feral aspen
#

Nope?

compact pier
#

nothing?

feral aspen
#

Nothing. ;-;

compact pier
#

can u show me the intents?

quartz kindle
#

it would never log anything because .type === "dm" would always be false

#

did you fix that?

compact pier
#

i guess so

compact pier
#

it must be DM

#

instead of dm

feral aspen
#

I fixed that the moment he sent his previous message?

compact pier
#

can u show me the intents?

feral aspen
#

Although, did the changes, still no result.

feral aspen
slender thistle
compact pier
#

just show me

feral aspen
slender thistle
#

I curse you with my stare so that your previous curse wears off.

#

Thee shall face heavenly intentions.

compact pier
#

so 32767 equals every intents?

feral aspen
compact pier
#

maybe try the old school one

#

just for a try

#
intents: [ Intents.FLAGS["DIRECT_MESSAGES"] ]
quartz kindle
#

you dont need to blindly test intents like that, just console.log(message) and see if it logs the dm message

compact pier
#

it does

#

as he said

#

message.author

quartz kindle
#

so console.log(message) works but console.log(message.content) does not?

compact pier
quartz kindle
#

im pretty sure he was talking about the other things outside of the if(dm)

compact pier
#

:))

#

maybe

feral aspen
compact pier
#

yeah then something with your event or intent

feral aspen
feral aspen
compact pier
#

but the guild messages?

compact pier
quartz kindle
compact pier
#

chill

feral aspen
quartz kindle
#

like just do console.log(message) directly, without any if(type === dm)

feral aspen
compact pier
#

can you try with the old school way

#

the intent

feral aspen
#

Didn't work.

compact pier
#

maybe enable the partial?

feral aspen
compact pier
feral aspen
#

I went to the .Client() options and it turns out, I can add a new property named as partials and enable the six partials. It works, afterall. 👍

compact pier
#

partial is kinda new

#

v12 didn't have, or maybe it wans't required

signal estuary
#

Why doesn it react to any reactions from the interaction user?

const reactionFilter = (reaction, user) => {
  return reaction.emoji.name === '![Error](https://cdn.discordapp.com/emojis/927189822995574835.webp?size=128 "Error")' && user.id === inter.user.id;
};
enterID = await inter.followUp({ embeds: [embed], fetchReply: true })
enterID.react('![Error](https://cdn.discordapp.com/emojis/927189822995574835.webp?size=128 "Error")')
enterID.awaitReactions({ filter: reactionFilter, max: 1 })
.then(collected => {
  console.log(collected)
  if (enterID) enterID.delete().catch(err => { })
})
quartz kindle
#

it was often needed for reaction menus

compact pier
#

the partial

quartz kindle
#

because you wouldnt receive reaction events on uncached messages

compact pier
#

oh

quartz kindle
#

so your reaction menu would not work on older messages after your bot restarted

compact pier
#

that is why

#

I alway have to cache the role reaction message on bot start up

quartz kindle
#

i dont like the partials system, idk why they taught it would be a good idea to omit discord events if there was missing data

compact pier
#

but now there aren't a return for it :))

solemn latch
#

can interaction replies be edited multiple times? 🤔

quartz kindle
#

i dont see why not

solemn latch
#

well, I must be doing something wrong then, hmm.

spark flint
#

Why am i getting {"reason":{"type":"ReplicaSetNoPrimary","servers":{},"stale":false,"compatible":true,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"setName":"atlas-kk6xv2-shard-0","maxSetVersion":6,"maxElectionId":"7fffffff00000000000000ce","commonWireVersion":9,"logicalSessionTimeoutMinutes":30}}

#

with mongo

#

on nodejs

#

ah its working now

#

@solemn latch it worked

#

quicker now

#

down to 140ms

novel jetty
#

Anyone know how i can fix this?

earnest phoenix
#

Not use channel on something that doesn't have channel on it

signal estuary
#

I have a messageComponent collector, but after leaving the message for a while and clicking then on a button I get this error:

DiscordAPIError: Invalid Webhook Token

code:

const filter = (filter) => {
  if (inter.user.id === filter.user.id) return true
  return inter.reply({ embeds: [embed], ephemeral: true })
}
const collector = message.createMessageComponentCollector({
  filter,
})
collector.on('collect', async (i) => {
  try{
  i.deferUpdate()
  ...
  }catch()
})

Whole error:

iscordAPIError: Invalid Webhook Token
    at RequestHandler.execute (C:\Users\Flo\Documents\GitHub\noah-bot\bot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (C:\Users\Flo\Documents\GitHub\noah-bot\bot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
    at async InteractionWebhook.editMessage (C:\Users\Flo\Documents\GitHub\noah-bot\bot\node_modules\discord.js\src\structures\Webhook.js:325:15)
    at async CommandInteraction.editReply (C:\Users\Flo\Documents\GitHub\noah-bot\bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:139:21) {
  method: 'patch',
  path: '/webhooks/926421352234233866/{token}/messages/@original',
  code: 50027,
  httpStatus: 401,
  requestData: {
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: [
        {
          title: 'Logs for Fabboy#4725',
          type: 'rich',
          ....

How can I prevent that error? I have already all stuff in try catch blocks

pallid vale
compact pier
#

what is the problem with chromebook

#

every browser have dev tool tho

#

just press shift ctrl i

signal estuary
#

I never sent a webhook btw, it seems like the interaction expires. But I dont know how to prevent that

compact pier
#

oh

solemn latch
#

interaction webhooks expire after 3 seconds, or 15 minutes if you deferred them

compact pier
#

sorry didnt read all of them

solemn latch
#

looks like you are deferring in the collector, you probably are looking to defer before then.

#

no wait 👀

quartz kindle
#

indeed, its using the return value from the reply as the filter value. since reply returns a promise, and a promise is truthy, your filter passes when it shouldnt

heavy phoenix
#

Hi,Is it difficult to slash all your commands?

compact pier
#

like make all of your command to be slashed?

heavy phoenix
#

yes

compact pier
#

nah

pallid vale
heavy phoenix
compact pier
pallid vale
#

k, will message back if i dont find it

compact pier
#

or u can write 106 slash commans

compact pier
heavy phoenix
compact pier
#

nope engliah pls

#

english

heavy phoenix
#

because with discord who wants to go into slash bah the transferred will be hot

compact pier
#

just slash the importain commands

#

I dont like slash so much, so yeah old cli will better

heavy phoenix
#

yes thanks you for help ^^

compact pier
#

well i didnt help anything, but ok ^^

heavy phoenix
#

well you answered me anyway super nice

#

@compact pier

compact pier
#

thank you thank you :))

hidden gorge
#
const { Client, Collection } = require("discord.js");
const { DiscordTogether } = require('discord-together');
const mongoose = require("mongoose");
const Dashboard = require("./dashboard/dashboard");
const client = new Client({
    intents: 32767,
});
module.exports = client;
Dashboard(client);
// Global Variables

client.commands = new Collection();
client.slashCommands = new Collection();
client.config = require("./config.js");
mongoose.connect(client.config.mongooseConnectionString, {
    useNewUrlParser: true,
    useUnifiedTopology: true
  });
client.discordTogether = new DiscordTogether(client, {
     token: client.config.token
 });

// Initializing the project
require("./handler")(client);
client.login(client.config.token);```
quartz kindle
hidden gorge
#

@quartz kindle I updated Node Still getting the error

sudden geyser
#

can you show your package.json

hidden gorge
#

sure

#

@sudden geyser

  "name": "djs",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node index.js",
    "test": "nodemon index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "aki-api": "^6.0.8",
    "autoprefixer": "^10.2.6",
    "body-parser": "^1.19.0",
    "discord-together": "^1.1.62",
    "discord.js": "^13.1.0",
    "djs-anime": "^2.0.9",
    "djs-games": "^2.0.6",
    "djs-misc": "^1.0.1",
    "djs-utils": "^1.1.2",
    "dotenv": "^10.0.0",
    "ejs": "^3.0.2",
    "express": "^4.17.1",
    "express-session": "^1.17.0",
    "fetch": "^1.1.0",
    "glob": "^7.1.7",
    "mal-scraper": "^2.11.3",
    "memer-api": "^3.0.6",
    "memorystore": "^1.6.2",
    "mongoose": "^5.12.3",
    "ms": "^2.1.3",
    "node": "^17.3.0",
    "node-fetch": "^2.6.1",
    "node.js": "0.0.1-security",
    "passport": "^0.4.1",
    "passport-discord": "^0.1.3",
    "postcss": "^8.3.5",
    "postcss-cli": "^8.3.1",
    "random-words": "^1.1.1",
    "reconlx": "^2.5.2",
    "txtgen": "^3.0.0",
    "weather-js": "^2.0.0",
    "weky": "^3.1.8"
  }
}
solemn latch
#

Personally would remove your node modules folder and redo npm install

hidden gorge
#

How

solemn latch
#

Delete node modules folder(just like any other folder) then run npm install

hidden gorge
#

I don't have a modules folder

#

@solemn latch ^

earnest phoenix
#

ez

hidden gorge
#

ok

#

doing it

#

its running the install

earnest phoenix
#

thats nice

hidden gorge
#

whats npm ci?

#

do I run it?

earnest phoenix
#

never heard of npm ci

#

there is no need to run npm ci

#

it is essentially just npm install but for automated environments (whatever that means)

hidden gorge
#

uhh everything is blurry

earnest phoenix
#

what

hidden gorge
#

my eyes are going blurry

earnest phoenix
#

then go to a doctor or smth

hidden gorge
#

UUUUGH

earnest phoenix
#

Do you have a node_modules folder now

hidden gorge
#

no

#

do i make one?

earnest phoenix
#

:/

#

Did you not let npm install run through?

hidden gorge
#

it ran through

earnest phoenix
#

and it didn't create a node_modules folder

hidden gorge
#

ill run it again

earnest phoenix
#

Can you send an ss of your file structure

hidden gorge
#

ok

#

is really big @earnest phoenix

earnest phoenix
#

collapse any folders

hidden gorge
#

ok

earnest phoenix
#

Oh that is repl or smth

hidden gorge
#

replit

#

why?

earnest phoenix
#

I don't know if npm install works on repl

hidden gorge
#

i think it does

earnest phoenix
#

If it does then why isn't it working for you

spark flint
#

There’s a tab for package install iirc

solemn latch
#

Tbh would contact replit support, or look at their guides.

hidden gorge
earnest phoenix
#

or just idk not use repl

#

there is no point really

spark flint
#

Join their support server

hidden gorge
#

ima instal the NPM package

earnest phoenix
#

I thought repl auto installed stuff when you added to the package.json or through the packages tab'

hidden gorge
#

nope

hidden gorge
#

ok

#

@earnest phoenix it did nothing

#

ima recode it

#

ok

#

thats the top

#

but nothing happens

#

@earnest phoenix ima let it all properly go through

#

ok

#

so remove start?

quartz kindle
#

you should uninstall fs lol

sudden geyser
#

"fs": "^0.0.1-security",
notlikenoot

quartz kindle
#

fs is built in

#

its not a third party lib

sudden geyser
#

forever

quartz kindle
#

since always?

sudden geyser
#

did you even read the readme of the package?

quartz kindle
hidden gorge
#

what was i thinking

#

i didn't

#

i hit the run button

#

oh

quartz kindle
#

hes not using the terminal

#

the .replit file tells what the run button does

#

his .replit file probably has npm start

#

it doesnt matter

#

the problem is

#

that replit doesnt support node 16+ by itself

hidden gorge
#

you can't remove it

quartz kindle
#

so people do these weird hacks that involve installing node as an npm package

hidden gorge
#

I removed it and this happened

#

I FORGOT THE CODE

quartz kindle
#

that wont work lol

#

are you using replit as well?

#

if you do node .

#

it uses replit's system version of node

#

which is v12

#

unless you used one of the other methods

hidden gorge
#
internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module 'node:events'
Require stack:
- /home/runner/flash-discordbot-3/node_modules/discord.js/src/client/BaseClient.js
- /home/runner/flash-discordbot-3/node_modules/discord.js/src/index.js
- /home/runner/flash-discordbot-3/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/runner/flash-discordbot-3/node_modules/discord.js/src/client/BaseClient.js:3:22)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/runner/flash-discordbot-3/node_modules/discord.js/src/client/BaseClient.js',
    '/home/runner/flash-discordbot-3/node_modules/discord.js/src/index.js',
    '/home/runner/flash-discordbot-3/index.js'
  ]
}
exit status 1
 ```
quartz kindle
#

there are several methods to update node on replit

#

hes using the one that involves installing the node package from npm

hidden gorge
#

HOW DO I FIX THIS

#

?

#

ok

#

so .nix

quartz kindle
#

thats probably the easiest way to do it

hidden gorge
#

ok

quartz kindle
#

you need to create a new repl project, using nix as the template, instead of nodejs

hidden gorge
#

this then remove .replit?

quartz kindle
#

no

#

did you create a new project?

hidden gorge
#

like do i remove the .replit file?

hidden gorge
quartz kindle
#

then do it

#

you have to create a new project

#

using a nix template

#

not nodejs

#

idk

#

check docs

hidden gorge
quartz kindle
#

yes

hidden gorge
#

ok

#

will it work with js too?

quartz kindle
#

now in the .replit file

#

run = "node index.js"

hidden gorge
#

ok its creating the repl

#

ok

quartz kindle
#

in the .nix file

{ pkgs }: {
  deps = [
    pkgs.nodejs-16_x
  ];
}
hidden gorge
#

is this bad?

hidden gorge
#

yes i did

#

whoops

quartz kindle
#

create an index.js file

#

and just put this in it

hidden gorge
#

let me do that

quartz kindle
#

console.log(process.version)

hidden gorge
#

ok i made the index file

quartz kindle
#

ok

hidden gorge
#

now I add my code?

quartz kindle
#

now you can transfer the rest of your files yes

hidden gorge
#

Ok

#

Thanks

#

do i keep that console.log code in the index?

quartz kindle
#

no need

hidden gorge
#

ok

quartz kindle
#

was just to confirm

hidden gorge
#

BRUH IT WAS ME

#

I forgot I had the token in the GitHub project

#

Wait what

hidden gorge
#

code ```const { Client, Collection } = require("discord.js");
const { DiscordTogether } = require('discord-together');
const mongoose = require("mongoose");
const Dashboard = require("./dashboard/dashboard");
const client = new Client({
intents: 32767,
});
module.exports = client;
Dashboard(client);
// Global Variables

client.commands = new Collection();
client.slashCommands = new Collection();
client.config = require("./config.js");
mongoose.connect(client.config.mongooseConnectionString, {
useNewUrlParser: true,
useUnifiedTopology: true
});
client.discordTogether = new DiscordTogether(client, {
token: client.config.token
});

// Initializing the project
require("./handler")(client);
client.login(client.config.token);

#

whats the issuse??

sudden geyser
#

Check the value of client.config.mongooseConnectionString

#

And see if it conforms to the correct URL structure

hidden gorge
#

ok

#

ah theres no url in it

sudden geyser
#

well now you have your problem

#

you'll need to add it

hidden gorge
#

ok

#

adding it

#

@sudden geyser How do i set Mongodb up?

sudden geyser
#

don't know

#

there's probably a guide for it on the site

hidden gorge
#

um what is this

#

its definded

#
const { promisify } = require("util");
const { Client } = require("discord.js");

const globPromise = promisify(glob);

/**
 * @param {Client} client
 */
module.exports = async (client) => {

    // Commands
    const commandFiles = await globPromise(`${process.cwd()}/commands/**/*.js`);
    commandFiles.map((value) => {
        const file = require(value);
        const splitted = value.split("/");
        const directory = splitted[splitted.length - 2];

        if (file.name) {
            const properties = { directory, ...file };
            client.commands.set(file.name, properties);
        }
    });

    // Events
    const eventFiles = await globPromise(`${process.cwd()}/events/*.js`);
    eventFiles.map((value) => require(value));

    // Slash Commands
    const slashCommands = await globPromise(
        `${process.cwd()}/SlashCommands/*/*.js`
    );

    const arrayOfSlashCommands = [];
    slashCommands.map((value) => {
        const file = require(value);
        if (!file?.name) return;
        client.slashCommands.set(file.name, file);
        arrayOfSlashCommands.push(file);
    });
    client.on("ready", async () => {
        // Register for a single guild
        await client.guilds.cache
            .get("834390097621286922")
            .commands.set(arrayOfSlashCommands);

        // Register for all the guilds the bot is in
        // await client.application.commands.set(arrayOfSlashCommands);
    });
};
#

oh

sacred aurora
#

What do you mean

#

you can also write it like that

#

Yes you can

#

hmm why the color change

#

Is it working?

hidden gorge
#

WHY DID I TRY A PROJECT THIS BIG?!?!?!?

sacred aurora
#

Oof

#

and with all the comment

hidden gorge
#

No i coed it

#

coded*

#

by watching a vdieo

#

No

#

I wrote it

#

yes

#

ye

#

ok

sacred aurora
#

But you can also learning by doing weirdsip

#

Not a good way to start with a discord bot tho

sudden geyser
sacred aurora
#

Well sorry

hidden gorge
#

no

hidden gorge
#

ima go watch a 2 hour javascript learning video

#

nvm its 3 hours

#

it will be 12 am when i am done

#

its 9 PM

#

its freeCodeCamp im watching

#

its helped me a few times but i'm gonna watch the full 3 hours

#

im learning now

sudden geyser
#

should learn some clojure

hidden gorge
#

i have never been committed enough to watch a 3 hour learning video

sudden geyser
#

You don't need to be committed to it.

#

Watch the video whenever you feel like it in small chunks.

#

It's the slow path that'll teach you your first programming language.

hidden gorge
#

my friends have been telling me for months bc i used to fork code and use it and they hated me for it

#

LOL

#

someone told me to shutdown my bots bc i forked the code

sudden geyser
#

forking projects is fine

#

I don't get why people get mad over people forking their project

#

when making it public on github

#

sad memories of intro to compsci flow through one's mind

#

pain

hidden gorge
#

1 sec my computers default backspace button is sticking ima plug my keyboard in

coral palm
#
                await interaction.reply({ content: 'Aviso Enviado!', ephemeral: true });

                interaction.channel.createWebhook(name, img).then( msg  => {
                    msg.channel_aviso_no_servidor.send({embeds: [embed_2]})
                });```
Erro: TypeError: Cannot read property 'send' of undefined
#

yes it is

#
 let servidor = interaction.guild.id;
        let channel_aviso = db.get(`channel_aviso_${interaction.guild.id}`);
        let channel_aviso_no_servidor = client.guilds.cache.get(servidor).channels.cache.get(channel_aviso);
        
        if (!interaction.member.permissions.has("ADMINISTRATOR")) return interaction.reply({content: 'Você não tem permissões para usar esse comando'});
        if (!channel_aviso_no_servidor || !channel_aviso || channel_aviso === null || channel_aviso === false) return interaction.reply(`**${interaction.author} o chat aviso não está configurada no servidor.**\n **Use** -setaviso "mencionar chat/id" **para configurar**`);```
hidden gorge
#

lol my method of checking my console logs is using my iPad as a second screen

coral palm
#

but is

#

the problem is on the sender

#

the "msg" isnt defined i think

#

because of the "then"

#
interaction.channel.createWebhook(name, img).then( msg  => {
                    msg.channel_aviso_no_servidor.send({embeds: [embed_2]})```
#

but if the channel_avisos_no_servidor isnt defined

#

the command dont run

#

if (!channel_aviso_no_servidor || !channel_aviso || channel_aviso === null || channel_aviso === false) return interaction.reply(`**${interaction.author} o chat aviso não está configurada no servidor.**\n **Use** -setaviso "mencionar chat/id" **para configurar**`);

hidden gorge
#

huh just figured out you can do this

#

im watching the video

#

OOO

#

I learned that the text listed in the var line is Case sensitive

#

is that right

#

i thought it was gonna say its not defined

sudden geyser
#

JavaScript is very loose on types and syntax

#

It's syntactically correct (how it was written), but semantically incorrect (what it should've done)

earnest phoenix
#

Thunder pog is a br

#

@solemn latch

hidden gorge
#

Oh dam there’s a shortcut on telling the code what something equals by adding (x += x)

solemn latch
#

-= *= /= also work

hidden gorge
#

Oo

solemn latch
#

theres a ton of that stuff

hidden gorge
#

@solemn latch I forgot how do I update node

#

Help me

#

The video didn’t tell me

solemn latch
#

On repl? Not sure

#

I've never used replit

hidden gorge
#

Like what npm do I run?

round cove
#

Fresh install of mongo(ose) on node 16, just trying to build throws this error when building (TS). Any ideas?

#

Looks like mongoose has some weird TS generic issues.

#

I think it's a yarn.lock issue. Nevermind

old cliff
#

did you install typings for node?

round cove
#

Yeah

#

My packages.

#

(I'm transferring data ignore the better-sqltie3)

#

My tsconfig

old cliff
#

try removing type check for dependencies

#

"skipLibCheck": true,

round cove
#

I have never heard of that.

#

Interesting.

#

What's even scarier is the same mongoose version works on two other projects.

#

Well that did what I wanted.

#

So I appreciate it.

spark flint
slender thistle
#

You can but it required some magic shittery

#

If you search for "update node repl" in this channel you might find something

#

cc @hidden gorge

short pilot
#

can anyone think of a way to scan a servers members and do something if their role == something without members intents

#

seems to even detect a role change you have to have members intents so dumb

near stratus
short pilot
#

it's literally on my own server, i mean why. i can view that info with my eyeballs.

near stratus
#

if you have the id you can try fetching the member

near stratus
short pilot
#

is there a way to webhook it or something with integrations

#

i'd need to check if the id is in my server though

near stratus
#

webhooks are shit
they can't do anything except sending messages

near stratus
#

wait

#

it needs guild members intent too

#

fuc

short pilot
near stratus
#

nope

#

it doesn't

#

fetching all members does

short pilot
#

okay so id need them to send a message in the guild to be added to the list and then every 24 hours fetch every member on the list and check if they're in the guild and have the same role

#

pepe_thinking is discord gonna get annoying if in the future i have to send 1000 fetch requests

near stratus
near stratus
#

if this feature is only for your server you can simply create another bot and turn on member intent

#

bots under 100 can turn it as they will

short pilot
near stratus
#

no
they fuc*ed us enough already
so they should also expect some

short pilot
#

how quickly does guild.member_count update

modest maple
#

if you dont have members intent, it doesnt.

short pilot
#

it does though?

viral spade
#

Discord.js command handling - there is local and global deploy option. As i understand global is for all the guilds, local is only for specific guilds?

Because i am just reviewing a code and wondering, if i understood that right..

#

Can someone tell me please if the above code makes sense? shouldn't global commands also be loaded with the test environment?

compact pier
#

add a new variable to Client (client.state as boolean)

#

if the state is true then it will be run on public, else it will run only in the test server

#

in the messageCreate event

if(!client.state && message.guild.id !== "GUILD_ID") return;
#

but that thing, I never seen before

novel jetty
#

Can someone help me with this? Code and error

const embed = new MessageEmbed()
  .setAuthor('Moderation')
  .setColor('GOLD')
  .setDescription('`.prefix`, `.whois`')

  const embed1 = new MessageEmbed()
  .setAuthor('Configuration')
  .setColor('GOLD')
  .setDescription('`.setrolelog`, `.disablerolelog`, `.setjoinchannel`, `.disablejoinchannel`')

client.on('interactionCreate', (interaction) => {
  if (interaction.isButton()) {
    if (interaction.customId === "mod") {
        interaction.reply({ embeds: [embed], ephemeral: true, allowedMentions: {repliedUser: false}});
    } else (interaction.customId === "config"); {
      interaction.reply({ embeds: [embed1], ephemeral: true, allowedMentions: {repliedUser: false}});
    }
}
})
C:\Users\great\OneDrive\Desktop\Angelus\node_modules\discord.js\src\rest\RequestHandler.js:349
      throw new DiscordAPIError(data, res.status, request);
            ^
DiscordAPIError: Unknown interaction
    at RequestHandler.execute (C:\Users\great\OneDrive\Desktop\Angelus\node_modules\discord.js\src\rest\RequestHandler.js:349:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (C:\Users\great\OneDrive\Desktop\Angelus\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
    at async ButtonInteraction.reply (C:\Users\great\OneDrive\Desktop\Angelus\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:99:5) {
  method: 'post',
  path: '/interactions/927887488184373258/aW50ZXJhY3Rpb246OTI3ODg3NDg4MTg0MzczMjU4OmR2R1dDeEpla1pVbUQwOWlYZlh0eGVGcWJmUFdmbEhTTWZPUWl6ZE9UR0pFQ2JqU3I5MlF1QjQ5WUZTaHVXRUVHS2tRRFhZbkZTUzNIRTY2MnI3Um50TDBXSzJ3WGJ4a3EyUnNHWUJWaDUzdGdmeGJ3em5wYkNScEpWMDI1QTgz/callback',
  code: 10062,  httpStatus: 404,
  requestData: { json: { type: 4, data: [Object] }, files: [] }
}
[nodemon] app crashed - waiting for file changes before starting...
pearl trail
#

the interaction that you want to reply is not found? since the http status is 404...

novel jetty
#

Wait, wdym its not found

pearl trail
#

is the interaction exist? like is it deleted

novel jetty
#

It is there

#

I fixed it

earnest phoenix
#

log content[0]

gritty pebble
#

is there an api event on user bot add?

solemn latch
#

Like adding to a server?

earnest phoenix
wheat mesa
#

If you are using the discord api then guildCreate fires when the bot joins a guild :p

#

(Assuming you have the correct intents)

gritty pebble
#

hense it from this api

earnest phoenix
#

From what api

gritty pebble
quartz kindle
earnest phoenix
#

Someone have a cool website template for a discord bot?

earnest phoenix
#

why not

quartz kindle
#

probably because you dont quite understand what this does:

const [list] = JSON.parse(response.body);
const [post] = list.data.children;
earnest phoenix
solemn latch
#

what does that do though 👀

quartz kindle
#

const [a] = something is an array destructor assignment

#

its the same as const a = array[0]

solemn latch
#

oh thats sweet

#
[a, b, ...rest] = [10, 20, 30, 40, 50];

console.log(rest);
// expected output: Array [30,40,50]

quartz kindle
#

so whatever item you are destructuring, it needs to be an array-like, aka an iterable

#

it does not work on objects

#

if you want to destructure object keys, you need const {a} not const [a]

solemn latch
#

thats actually so useful in cases.

earnest phoenix
#

reddit has mega brain
the response json is structured like this:

{  // note the [
  "data": [{
    "data": { // here too
      "children": [{
        // actual post data
      }]
    }
  }]
}
solemn latch
#

no idea how I didnt know about this

quartz kindle
#

the array is inside the data key

earnest phoenix
#

wait there's no [ in the first data

#
async function fetchMeme() {
    let resp = await fetch("https://www.reddit.com/r/memes/random.json");
    resp = await resp.json();
    const meme = resp[0].data.children.find(x => !x.over_18) || await fetchMeme();

    return meme.data;
}
#

some old code of mine that does this

#

yes that's a multi purpose bot 3HC_coolcry

quartz kindle
#

this is what i get from that url

#

so it should be JSON.parse(response).data.children[0].data

earnest phoenix
#
const meme = resp[0]/* wtf */.data.children.yadayadayada
#

I don't understand my own code

quartz kindle
#

your url is different

#

it produces a different response

earnest phoenix
#

me when i use array on the url that does not need array

quartz kindle
#

it does

earnest phoenix
#

it's a single post

quartz kindle
#

this is your url

#

the base object is an array

#

so your code is correct

earnest phoenix
#

but what's the point

quartz kindle
#

JSON.parse(...)[0].data.children

earnest phoenix
#

they can just send the base object

#

or does that array have a second element

quartz kindle
#

it does

earnest phoenix
#
const body = JSON.parse($("pre").innerHTML);
console.log(body[1].data.children);
[]
#

but why doesn't that have anything in it

quartz kindle
#

if body[1] didnt exist, that would throw an error

#

cannot read data of undefined

earnest phoenix
#

what

quartz kindle
#

the code you just sent now

#

body[1].data.children would error

#

if body[1] does not exist

earnest phoenix
#

yes

#

how would it not exist if i just ran that code without errors

quartz kindle
#

you asked why doesnt it have anything in it?

#

oh you're talking about children?

#

i though you were saying why send body[1] if it doesnt have anything in it

earnest phoenix
#

lmao

pulsar bone
#

.

earnest phoenix
#

help plz???

quartz kindle
#

whats the actual error?

#

which module was not found?

earnest phoenix
quartz kindle
#

its literally written there

#

if you scroll up

earnest phoenix
#

here is where the errror comes

quartz kindle
#

you are not showing the actual error

earnest phoenix
#

Error: Cannot find module 'node:events'

#

this?

quartz kindle
#

yes

#

it means your node.js is outdated

earnest phoenix
#

oh

#

how can i update

quartz kindle
#

discord.js v13 requires node.js v16.6+

#

repl.it does not officially support node v16

#

the last official version is v12

earnest phoenix
quartz kindle
#

to use node 16 on repl.it, you need to use some weird hacks

earnest phoenix
#

a....

quartz kindle
#

one of the most common ones is to create a nix project instead of nodejs

earnest phoenix
quartz kindle
#

one of the most common ones is to create a nix project instead of nodejs

earnest phoenix
#

hmm

#

hwo can i do it?