#djs-help-v14

78874 messages · Page 37 of 79

neat nimbus

so when i move a channel it logs multiple any idea

rose tangle

moving a single channel moves many

because the rest are reorganized

you can build some kind of debouncer so it only executes once

neat nimbus

is there a way to stop the spaming

since if i move this up one or down one it logs 10 times 🤣

rose tangle

yeah channel position in discord is calculated weirdly

neat nimbus

i assume there no fix?

neat nimbus

debouncer ?

rose tangle

you can look it up, it's not a djs thing

neat nimbus

so just a timeout thing

rose tangle

that's one way of making one yeah

neat nimbus

remaking one for my v13 bots that still work like meant to but when updating to 14 it just does that

sleek brook

My bot sends like 5000 messages in the same channel daily responding to users. Now I want it to send a message in that channel when a user sends a message in a different channel, so I use: const c = await client.channels.fetch("1230464136366784532"); but it can't find the channel?

For some reason c is null

rose tangle

that should never be null though

if it couldn't find the channel it'd throw

unless you meant fetch(...).catch(() => null);

sleek brook

I have this:

let ch = await client.channels.fetch("1230464136366784532");
if (!ch) ch = channel;

And it's resorting to sending in the current channel

crimson gale

guess it could, if you specifically cache null as value for that id

sleek brook

nvm I'm actually stupid

sly tangle

does discord remove commands from both users and guilds if they're not included in the rest api request

crimson gale

that depends on what api request, the bulk update route will overwrite all commands with the ones you supply and remove all that are not present

lavish sparrow

I have made a slash command for users app, but it don't works in dm is it normal ? I put dmPermission to true but it don't work on dm only on a server :/

rose tangle

you need to set the context for that

lavish sparrow
sharp ginkgoBOT

dtypes v10: InteractionContextType - PrivateChannel
read more

rose tangle

and BotDM if you want it available in the bot's dm as well

lavish sparrow
sly tangle

so if i want to update commands for all the guilds my bot is in is it fine to use the deploy script in the wiki on all the ids? the bot will probably only be in 5 servers max

rose tangle

deploy it globally

much simpler and with less api requests

sly tangle

do all the guild commands get updated with the Routes.applicationCommands() function?

i'm under the assumption that it only affects user installs

kindred moon

that is for deplying globally, like Amgelo said

rose tangle

if you deployed guild commands they'll stay if that's what you meant

rose tangle

they can be used to deploy a command in every guild

sly tangle

i need all the commands for both user and guild installs to be the same

sly tangle

loving this 15 second slowmode 🙃

lavish sparrow

If I use a user command on a server, is it possible to have informations of the server like the id or the name or more ?

lavish sparrow
sharp ginkgoBOT
rose tangle

ah, wait what do you mean exactly with "user command"

a user installed command or a user context menu command?

grizzled bison

is there an api or library that allows fetching pinterest images?

bleak owl

you can google the question, not discord.js related

rose tangle

maybe there is, not djs related though

unique mountain

if my 3 discord bots (same code, different environments, but that's sort of unrelated) are out of sync, I realise I'll have to unregister and re-register the commands, but is there a "best way" to do that? Curious

crimson gale

skip the unregistering and just deploy the new state as bulk overwrite

copper meteor

How to disable buttons after a time when they are in a container?

unique shoal

Bascially the same as usual - make a change to the button to disable it and edit the message

lavish sparrow
loud quartz

though if the interaction comes from a guild that your app doesn't have a bot in, you won't have full guild data

lavish sparrow
loud quartz

what does "0" mean

lavish sparrow
loud quartz

ok but where

or from where

rose tangle

yeah guild seems to be null if the bot isn't in the guild

loud quartz

"0 data" didn't sound like "null", so didn't even think of that

rose tangle
rose tangle
loud quartz
  /**
   * Indicates whether or not this interaction is received from an uncached guild.
   * @returns {boolean}
   */
  inRawGuild() {
    return Boolean(this.guildId && !this.guild && this.member);
  }

figures

narrow umbra

Hi everyone, I’m building a Discord bot from scratch and looking for an experienced developer to help.
It will use discord.js, dotenv, and mongoose, with features like forms, buttons, logs, role management, and automated channels.
If you’re interested, DM me and we can go over the details.

loud quartz

this isn't a recruitment server

this is support server for discord.js, if you have some particular issue with its usage or questions about it

narrow umbra

Thanks for the heads up, I really appreciate it.
I understand this server is for support only and not for recruitment.
I’ll make sure to follow the rules and only ask technical questions here in the future.
Thanks again for your guidance

tired kindle
if (!message.inGuild())

This works if checking for user sending a message to the bot in dms?

unique shoal

it should yeah

You can also directly check message.channel.type

lapis plover

is there a way to mention someone in a container (or in general components V2 message) without notifying them (only for a specific message)? If so how?

sharp ginkgoBOT
kindred moon

oh thats what they meant

rose tangle

oh, well it depends on what you exactly mean by notifying

supress notifications indeed is for not notifying (desktop/app notification) but it's possible you meant to not ping

in which case it'd be allowedMentions

kindred moon

^

wide elk

Do you think creating additional text channels and distributing the threads among them would resolve the issue?

crystal cloud

Why does a components V2 section need a thumbnail?

wide elk

Do you think creating additional text channels and distributing the threads among them would resolve the issue?"

hallow mesa
crystal cloud

but I guess that's how it is lol

hallow mesa

Not sure what you mean

crystal cloud

actually im trolling, if there were no thumbnails a section would be no different like you said lol

rose tangle
sharp ginkgoBOT

tag suggestion for @wide elk:
We are not Discord, just some nerds who develop Discord bots!

tidal ravine

anyone know of the best way to send a message simultaneously across all servers the bot is in all at once? Been using promise.all and just wanted to know if that was the most efficient method

hallow mesa

I mean. The best way would be to post in your own announcement channel so that server owners can follow it if they want. Promise.all would be a good way to make sure they all resolve before proceeding, if that's something you need

polar karma

Or use a webhook that pushes the message out

You sending a message to every individual server is not going to scale upwards at all as your bot grows

solar furnace

hintSending.jsreads the following (in my ēvents folder!):

// all of my imports and stuff
module.exports = {
    name: Events.MessageCreate,
    async execute(interaction) {        
// code 
    if (interaction.channel.name === 'command log') {
//code
}
}

and index.js reads:

// Require the necessary discord.js classes
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');
global.mainPath = __dirname;

// Create a new client instance
const client = new Client({ intents: [ GatewayIntentBits.MessageContent] });

client.commands = new Collection();

const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

global.latestDaSubmission = "";

for (const folder of commandFolders) {
  const commandsPath = path.join(foldersPath, folder);
  const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
  for (const file of commandFiles) {
    const filePath = path.join(commandsPath, file);
    const command = require(filePath);
    // Set a new item in the Collection with the key as the command name and the value as the exported module
    if ('data' in command && 'execute' in command) {
      client.commands.set(command.data.name, command);
    } else {
      console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
    }
  }
}


const eventsPath = path.join(__dirname, 'events');
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));

for (const file of eventFiles) {
  const filePath = path.join(eventsPath, file);
  const event = require(filePath);
  if (event.once) {
    client.once(event.name, (...args) => event.execute(...args));
  } else {
    client.on(event.name, (...args) => event.execute(...args));
  }
}

// Log in to Discord with your client's token
client.login(token);

my issue si that i'm simply not receiving my MessageCreate event at all. when is end a message, i don't get a console log that i wrote, it doesn't seem to be receiving any messages at all. have confirmed i have messagecontent intent on

sick rover

Quick question, Is discord.JS rest able to unban users? Or would i have to use just regular discord.js

solar furnace

bro what has discord done to my formatting

loud quartz

whatever lib you use, or whatever language you use, it's the same API anyway

you can even unban with curl from your terminal

sick rover

Hm, So if im unbanning a user it would just be rest.delete(Routes.guildBan(guild_id, user_id))

clear garnet
loud quartz
solar furnace
clear garnet

GuildMessages/DirectMessages depending on what you're trying to listen to

solar furnace

ahhh thanks

sharp ginkgoBOT

discord Using Gateway: Gateway - List of Intents
read more

clear garnet

This details which events require which intents in order to receive them

solar furnace

sorry, i'm back again :(
i'm now receiving the message but can't access the embeds.

module.exports = {
    name: Events.MessageCreate,
    async execute(interaction) {        
                    console.log('Received message!')

        if (interaction.channel.name === 'command-log') {
              console.log('Received message!')

            const message = interaction.message;
            const command = message.embeds[0].description.split('`')[1];
            const moderator = message.embeds[0].description.split(' ')[0].split(':')[0];
            if (command.startsWith(':log hint')) {
            //code
}
}

error:

TypeError: Cannot read properties of undefined (reading 'embeds')
    at Object.execute (/Users/florentine/Desktop/Code/Rose/log-integration/events/MessageCreate.js:15:37)

(15:37 is the command variable)

clear garnet

Why do you have it called interaction?

solar furnace

should it be something else 😭

ah, is it passing the message to interaction?

clear garnet

Yes, ideally message, because that's the thing the event emits with; a message, not an interaction

solar furnace

thanks for being patient with me :')

polar sun

Is it possible to get the same order as a discord server for the channels?
This is what my server looks like https://kathund.wtf/kzmofnge.png
My drop down isn't really matching that order https://kathund.wtf/o5aqa76v.png (using Channel#rawPosition)
https://kathund.wtf/x6hzq40m.png (using Channel#position)
I have tried both Channel#position and Channel#rawPosition and they both show up differently in my list

const channels = await guild.channels.fetch();
channels
  .filter((channel) => channel !== null)
  .sort((a, b) => a.rawPosition - b.rawPosition)
  .forEach((channel) => parsedData.channels.push({ id: channel.id, name: channel.name, type: channel.type }));```
tidal ravine
stable sun
tidal ravine
stable sun
tidal ravine
polar sun
stable sun Does the bot have the guilds intent?

Yes? I'm creating client like this

this.client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMembers,
    GatewayIntentBits.MessageContent,
    GatewayIntentBits.GuildMessages
  ]
});```
frozen egret

is discord.js's current release up to date with how "pinning messages" is now separate from "managing messages"? and if so, how is it structured/listed as, or where/how can i find it?

rose tangle

djs doesn't support undocumented features/changes

the documentation for that was just opened in a pr less than 12h ago

frozen egret

what i'm hearing, in short; is no. fair enough.

rose tangle

yeah in short no

wanted to argue why though, djs is waiting on discord if anything

rigid crest

i cannot recall but can i do separated images in a v2? like

image - button

image - button

dense jackal

you could do

<Image/>
<Button/>
<Separator/>
<Image/>
<Button/>
rigid crest

thats what i meant i used "-" as "with a" but ty for clarifying

solemn willow

how can I kill a specific shard by id on command while keeping respawn in the sharding manager set to true without it booting back up for debugging purposes

tepid plover

Hey, how can I create container from a old message? I have already sent a message with a container and now I would like to fetch and edit it. I have already tried

const container = new ContainerBuilder(ogmessage.toJSON().components);

And various other ways to retrieve the old container in JSON, unfortunately nothing worked for me

unique shoal

message.components[0].toJSON()

high oxide

does discord not like it if i send 9000 characters as base64 for image embed

over webhook, that is. it is a 77kb file but when i get the base64 data for it, it is about 9000 characters

snow onyx

thats pretty small

high oxide

well fuck it, imma just convert them to links and then send it

rigid crest

so im trying to do a disabler and having a issue with select menus im trying to spawn a row fea each chunk hit it has considering i have 69 commands trying to spawn on one menu causing a error, i am trying this: but all im getting is the panel but no menus

        const chunkSize = 25;
        const commandChunks = [];

        for (let i = 0; i < commands.length; i += chunkSize) {
            const chunk = commands.slice(i, i + chunkSize)
                .filter(cmd => cmd.id !== '1407308767447748639')
                .map(cmd => ({
                    label: cmd.name,
                    value: cmd.id,
                    description: `ID: ${cmd.id}`
                }));
            commandChunks.push(chunk);
        }

       
        const selectMenus = commandChunks.map((options, index) => {
            return new ActionRowBuilder().addComponents(
                new StringSelectMenuBuilder()
                    .setCustomId(`command_select_${index}`) // Unique ID per menu
                    .setPlaceholder(`Select command group ${index + 1}`)
                    .setMinValues(1)
                    .setMaxValues(1)
                    .addOptions(options)
            );
        });
        
        selectMenus.forEach(row => {
            container.addActionRowComponents(row);
        });```
high oxide

nice

rigid crest

facepalm

snow onyx
rigid crest
high oxide
rigid crest

how long has modals had a cancel button? i dont rememebr them having one

wary coral
snow onyx

I think they just changed the design of the Cancel text to be a button now

velvet portal

I have a bot for saving and retrieving "canned messages" to provide guidance to people seeking help in another server, similar to what the bot here does when linking to the documentation
every time a canned message is retrieved, I'd like to provide a way for the person providing the help to ping the help seeker directly in the reply, through the bot

the problem is, because the bot has to search its database for the response, it's ideal to .deferReply(), but then we can't notify/ping the help seeker, as the mention will come from an .editReply()

how can I work around this?

obtuse laurel
velvet portal
obtuse laurel you could use .reply() and include the ping inside, and then later edit it to ha...

my bad I should have made this clear in the original question but it could also be the case that the retrieval from the database fails (e.g. the canned message the user tried to retrieve doesn't exist). when that happens, I'm currently deleting the original deferral and doing an ephemeral followUp(). if the deferral is replaced by an instantaneous ping, this deletion would leave the help seeker with a confusing ghost ping
I wonder if that's an acceptable compromise though

halcyon vault

Hi!

halcyon bison
halcyon vault
rose tangle

are you asking how to set it to no color?

dense jackal

if you do give a color, it looks like that same colored vertical bar on the left like embeds have

halcyon vault
halcyon vault
dense jackal
halcyon vault
fiery crag

does the discord container have a message limit like the embed object?

dense jackal

if you really close to that limit (lets say 4006 characters) you can check if you can replace the \n (2 characters) with a new text display component (max 40 components per message)

if you make 3 text display components out of 1 component that uses \n 2 times, you saved yourself 4 characters

uncut mortar

is that possible to only show the slash command to one user only?

hallow mesa

Server mods can do so through the integration settings

lost mason

why isnt my bot editing the reply even when i tripe checked my cript and everything was perfectly working

rose tangle

show your code, show your error

lost mason

and i think its a djs issue i tried on other bots it worked every command i have that uses editreply does not work

const { SlashCommandBuilder } = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('ping')
        .setDescription('Displays the bot\'s latency to Discord.'),
    async execute(interaction) {
        await interaction.reply({ content: 'Pinging...', ephemeral: true });

        const sent = await interaction.fetchReply(); 
        const latency = sent.createdTimestamp - interaction.createdTimestamp;

        await interaction.editReply({
            content: `**Pong! Latency: ${latency}ms, API Latency: ${Math.round(interaction.client.ws.ping)}ms**`,
            ephemeral: false,
        });
    },
};

heres an example its not deffered but uses edit reply and the reply does not edit

polar karma

npm ls discord.js and show the output please

inner cipher

what is the difference between PermissionFlagsBits and PermissionsBitField

sharp ginkgoBOT
inner cipher

Is there a way, where Slashcommandpermissions are checked based on global user perms (on like a role level) instead of a channel level?

loud quartz

what do you mean?

inner cipher

Can I force my slash commands to only look at the set of permissions that come by default with a role? and ignore the permissionOverwrites? Lets say some user has the "manage channel" permission in their own "private" channel in a guild, id like for that user to not be able to access the commands i've labeled as "manage channel". He could Only have access to that command if he has "manage channels" in the entire guild

I dont know if that makes sense

gray birch

Why can't i put drop downs in a modal?

untold skiff

Where can i read about how to inplement the components v2 in my bot?

kindred dragon

Can you somehow detect if a user clicks on an emoji or any element in an embed? Id like to create a settings menu, but buttons are way too inflexible for that

wary coral
sharp ginkgoBOT

guide suggestion for @untold skiff:
guide Popular Topics: Display Components
read more

bleak owl
wary coral
honest lavaBOT
gray birch

I want to kill my jank settings channel and replace it with a nice clean modal

kindred dragon
wary coral
honest lava

I meant for the Discord API but this is cool, can't wait

snow onyx
wary coral

That is unfortunate. I hope they make one soon I would like to use them

inner cipher
hallow mesa

The two are equivalent. PermissionsBitField.Flags is PermissionFlagsBits

inner cipher

check, just got confused, thanks

hallow mesa

Mark responded to you and you didn't do what he suggested

dense jackal
lost mason
rose tangle

how so?

lost mason
rose tangle how so?

its jexactly hosting when i type in it it it just sends to console and does nothing

rose tangle

but you aren't coding the bot in your host's panel are you?

lost mason
rose tangle

and isn't it possible to execute the command there?

unique shoal

Its good to develop and test locally first where possible

lost mason
rose tangle

add what?

lost mason
rose tangle

npm ls lists your installed versions

unique shoal

We cant really provide support for how various hosts may or may not do things

rose tangle

it doesn't update

lost mason

14.21.0 Is the version

@rose tangle

rose tangle

what's the actual output

nimble sphinx

the compass isn't pointing north but we're not looking for north either

crimson gale

preach, brother

lost mason

this is very strange it works for my friend but not me

@rose tangle

dense jackal
frosty epoch

i got

client.on('guildScheduledEventCreate', async (event) => {

seems to not be firing?

unique shoal

okay

are you subscribed to the corresponding intent?

shut sparrow

Does djs v14 support using ESM?

bleak owl

yes

shut sparrow

Awesome, Thanks!!

frosty epoch
loud quartz

partials wouln't make sense for create event

also monbrey said intent, so didn't relaly mean partials

unique shoal

Its intents, and no, you dont have GuildScheduledIntents

tidal ravine

for components v2 is there a way to kind of make inline fields like a traditional embed

unique shoal

no

tidal ravine
unique shoal no

aw darn. I really like how components v2 look but i don't think there's enough flexibility yet

loud quartz

container is not an embed

so there's not gonna be such "flexibility"

uneven crater

Inline embed fields are a mess on mobile anyway. akkoShrug

languid summit

Is guild tag documentation added in discordjs guide/docs?

bleak owl

it will be added to the docs in the next update

ebon rock

welp, I've exhausted my troubleshooting abilities.
I'm trying to listen to new messages to see if any of them say a specific phrase in order to reply to them, but it just doesn't fire.
I gave my bot the intents and perms, and added them to index.js, so whatever is going wrong is in the event file, I just don't know what, (my javascript college course was pretty basic). And I've stared at it long enough it looks like squiggles.

const { Events } = require('discord.js');

module.exports = {
    name: Events.wish,
    execute(client) {
        client.on('Events.messageCreate', async (message) => {
            console.log(`Received message: ${message.content}`);
            if (message.author.bot) return;

            if (message.content.toLowerCase().includes("i wish")) {     
                await message.reply("Is that the Wish that will make your soul gem shine?");
            }
        });
    }
};```
hallow mesa

Events.MessageCreate should not be in quotes and the "M" should be capitalized

ebon rock

still not getting anything

hallow mesa

Can you show the new code and the client constructor?

Oh. You should probably not be attaching the listener inside your execute function

Maybe that's correct, but different than how most people set things up based on the guide

ebon rock
const client = new Client({
    intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMessages,
        GatewayIntentBits.MessageContent,
        GatewayIntentBits.GuildMembers,
    ],
});```
```js
const { Events } = require('discord.js');

module.exports = {
    name: Events.wish,
    execute(client) {
        client.on(Events.MessageCreate, async (message) => {
            console.log(`Received message: ${message.content}`);
            if (message.author.bot) return;

            if (message.content.toLowerCase().includes("i wish")) {     
                await message.reply("Is that the Wish that will make your soul gem shine?");
            }
        });
    }
};```
hallow mesa

Where/how are you calling the execute?

ebon rock

i dont know, I just kinda copied the boilerplate from ready.js, lemme try something actually...

hallow mesa

The name of your object will also be undefined if you're relying on it for anything

ebon rock

should I just toss all this in a standard eventlistener?

sharp ginkgoBOT

guide Creating Your Bot: Event handling
read more

clear garnet

I would just follow our section in the guide regarding event handling, since that seems to be what you're attempting to create

ebon rock

its like the first thing I read but ill give it another try

clear garnet

Yea, but the guide shouldn't be telling you about Events.wish, because that's not an event that exists. It also doesn't tell you to nest a client.on(...) listener inside your event handler's execute() function, so there seems to be a few steps you're skipping/not understanding

ebon rock

i thought I was just naming it, like a command

okay yeah no I just have terrible reading comprehension

thanks for the help, works

plain nymph

Is it possible to get this as a file using a bot

steel trail

Yes, that is just an attachment with extra properties

frosty epoch
client.on('guildScheduledEventCreate', async (event) => {

event has creator: null, what is this about?
I do get creatorId:

unique shoal

Creator wasn't in cache

And event likely doesn't provide enough data to cache it, or you have that cache disabled

frosty epoch

meaning i'd need to cache guild, then cache/fecth channel

unique shoal

Guilds should always be cached, so that's fine. But so should the channel. Not sure why you'd need to get that manually

You said it was creator that's missing

frosty epoch

i meant just wondering if this event has same options as an interaction

sharp ginkgoBOT
snow onyx

thats what the event emits

frosty epoch

If i log(event) it does not give .guild (unless it's like implied)

snow onyx

its a getter, these dont show up when you log it

thats why the documentation exists :P

frosty epoch
client.on('guildScheduledEventUserAdd', async (scheduledEvent, user) => {

this is not firing at all (when clicking interested) bot is admin
do i need another intent for it?

frosty epoch

even guildScheduledEventUpdate doesnt fire

but guildScheduledEventCreate works

dense jackal
frosty epoch

then why it is not firing 😄

mystic bobcat

Hey, so, any way to detect when a thread got autoarchived? the ThreadUpdate event doesn't seem to catch that and <thread>.archived returns as false.

dense jackal
frosty epoch

actually I do get the guildScheduledEventUpdate(tho it doesnt fire if somebody clicks interested)
but still not getting guildScheduledEventUserAdd

dense jackal

hopefully someone else can tell you why

frosty epoch

nvm all of a sudden i get the event
maybe discord had to wake up

snow onyx

probably user wasn't cached, should emit if you have the User partial enabled

frosty epoch

that'd be Partials.GuildMember?

snow onyx

No, it would be Partials.User

the event doesnt emit with a guild member object

frosty epoch

always learning something

mystic bobcat
steel trail

All "autoarchive" does is remove it from the sidebar in the UI. There is no actual change to the channel, everyone can still read and write. What you can check is the timestamp of the last message sent and compare it to the autoArchiveDuration of the parent channel

mystic bobcat

Alr then, thank you

iron void

Please any one fix it

marsh furnace

How to hide thread so that no one including admin can see it

dense jackal

if not you have to do it yourself with the advice I give you

dense jackal
iron void
dense jackal

people with Administrator permissions have access to every channel

marsh furnace
iron void
dense jackal

we are not working for you

steel trail
iron void
dense jackal

that doesn’t change my point

steel trail

But looks like you tried to use a section without an accessory

dense jackal

yeah, use a text display component instead if you don’t need any accessory

steel trail

A section needs an accessory. If you just want a textdisplay then don't put it in a section🐌

sharp ginkgoBOT

guide Popular Topics: Display Components
read more

dense jackal

use this if you need assistance for any cv2 components ^^

iron void

Can anyone help me write it without an section?

dense jackal
wraith cedar

Any guides on the containers and seperaters etc everything

wraith cedar
sleek brook

Is it possible to filter a userSelectMenu such that only specific users show up in that menu

hallow mesa

No

dense jackal
halcyon vault

Failed to send dynamic message: TypeError: section.addTextDisplayComponents(...).setSelectMenuAccessory is not a function

snow onyx

you cant add select menus to a section

halcyon vault

Ohh. Got it!

somber dome

how i can add role in private thread?

const thread = await msg.channel.threads.create({
name: تذكرة-${msg.author.username},
autoArchiveDuration: ThreadAutoArchiveDuration.OneWeek,
type: ChannelType.PrivateThread,
reason: "فتح تذكرة"
}).then(async (thread) => {
await msg.channel.send({ content: <#${thread.id}>})
});

i want create ticket in thread system

dense jackal
somber dome

YES

somber dome

if added the user in thread, how give perms?

"The thread is read only"

crimson gale

threads don't have their own permissions

dense jackal

thats a seprate permission, you don’t need the “Send Messages” permission itself

crystal cargo

addAttachmentOption for the slashCommand
Can i upload txt files, or only media?

crisp finch

When i run shortly after the bot boots:

        const guild = await this.client.guilds.fetch(guildId);
        if (!guild?.channels) {
            this.logger.error(`Guild ${guildId} not found`);
            return;
        }
        return await guild.channels.fetch(channelId);

This error gets thrown every time. The bot is in the guild. Why does it error?

Is it because of caching? Should I use force? What implications will that have (if any)
this.client is of type Client, by the way

red coral

What error exactly

There’s basically no reason to fetch a guild, and little to no reason to fetch a channel. Guild.channels will never be null/undefined either unless you did something wrong

crisp finch
red coral

Where do you run this?

crisp finch
crisp finch

Say when I fetch /hello, I want the bot to say "Hello" in a specific channel in a specific server, I need to fetch that channel, now what's the best way to do that

red coral

client.channels.fetch, or just client.channels.cache.get, if you have the Guilds intent and the channel isn’t some thread channel then you can use the cache

shadow harness

Is there a method to create tables within a message?

red coral

Tables?

shadow harness

Rows and columns data structure in a message

red coral

Nothing djs can help you with, gotta make those yourself

shadow harness

😛 Suspected that. Alr, thanks

red coral

But imo I just wouldn’t since it’ll be super hard to do

crisp finch
red coral

Yh, but again if you got the guilds intent and it’s not a thread channel there’s no need to fetch. But fetch does check the cache first

shadow harness
red coral

40? I think, idk

shadow harness

Alrighty, thanks!

crisp finch
rose tangle

yes

fetch never returns undefined or null

if the resource doesn't exist it throws

a cache get does return undefined since it's just a map

somber dome

i can remove in mention add user to thread?

dense jackal
somber dome
dense jackal

if that is set to false only users with moderation permissions can add users to the private thread

somber dome

thanks

"moderation permissions" only administrators?

dense jackal

I have to say I have actually no idea to what permission that is bound, but if I had to make a guess I would say users with "Manage Threads" permission

tidal rune

Can someone help me understand what the heck is going on here??

I have a command that is setup in the exact same way as all of my other commands, and it DOES appear in the command list, and it even says its refreshing and reloaded 6 application commands. However, when I try to run the command, it says it wasn't found, and it says a WARNING when I deploy saying its missing "data" and "execute"

My deploy code is basically 1 to 1 from the guide, and all my other commands have gone in fine.

dense jackal

well how does your cancelMatch.ts file look like?

tidal rune
sharp ginkgoBOT

To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.

tidal rune

@dense jackal posted it

dense jackal

aka wherever you have console.log("[WARNING] ...") please console log the command object as well

tidal rune

Sure, one sec

nvm, I managed to fix it, I guess I was running code in the wrong order

dense jackal

cool!

abstract forge

I've added some new commands to my bot but they are only showing for myself and not others

They also don't show in the integrations no matter what

Anyone could help?

dense jackal
abstract forge

I've done most of the basic debug things

dense jackal

is it a user installed app? those don't show up in the integrations tab of any server

and ofc won't show up on anyone else their account except yours as you installed it on your account

abstract forge
dense jackal

but if they don't show up on the integrations tab then it didn't register them

abstract forge

weird

dense jackal

can you show like screenshots

abstract forge

First screenshot is my view, second one is from an alt which has administrator perms

Integrations tab just has all the previously registered commands that were added back in like 2024 except these new commands

dense jackal

can you show the integrations tab overview of your "Lakeside" bot too

abstract forge
dense jackal

does the command actually work from your end?

abstract forge
dense jackal

hm sorry then I have no idea, maybe someone else knows what's happening here

abstract forge

for anybody else if they are gonna help: i kicked and re-added the bot and that didn't fix anything

steel trail

Do you have your bot user-installed too? How many bots are on the server in question?

abstract forge

i also added an extra command and it appeared in dms, but not the server so it's def something to do with that

loud quartz

what contexts and integration types?

abstract forge
loud quartz

which is probably why it's behaving like it's behaving

abstract forge

i mean i've added commands before and never had this issue

rustic seal

Hello, on discord.js there is a possibility that the bot recognizes the tag that a user has and then gives a role for example.

loud quartz
rustic seal

thx

dense jackal
abstract forge
dense jackal

you don't, its just a very weird situation where you only be able to use a slash command that works like normal but doesn't show up on the integrations tab OR for other users

and since you have never heard of contexts or integration types as you said earlier, I doubt you have changed those two -- but we have to confirm that so I ask you to share the full command object of the punish command

loud quartz

they might not have changed

but discord defaults them to certain stuff

like integration types default to enabled install scopes

dense jackal

but its weird if they said the app is both user and server installable

dense jackal

yeah but that would mean they turned off server install

abstract forge

i only turned it off since it's a private bot

dense jackal

yeah don't do that

there is an option made for that, called "PUBLIC BOT" (Developer Portal > Bot tab)

if you turn that off no one except you can add the bot to servers

rustic seal

there is a date for the next update

bleak owl

no

abstract forge

could it possibly be due to how i register commands

dense jackal

but now you said you turned off "server install" which you shouldn't have done

if you want to make your bot private you only have to disable the "Public Bot" toggle I talked about earlier

abstract forge

so i basically set the punish command to unregister, then i set it to register again after a restart, which then somehow fixed it?
i also had to enable server install too

dense jackal

that should fix it yeah, as long as you have ticked "Server Install" on the dev portal (and saved changes)

shadow harness

How does one extract options from subcommands? The docs specify how to create subcommands, but not how to get options from them

sharp ginkgoBOT

guide Slash Commands: Advanced command creation - Subcommands
read more

guide Slash Commands: Parsing options - Subcommands
read more

shadow harness

So switch on which subcommand, and then extract options like normal?

vagrant blade

how do i properly extend Client and ensure it actually gets passed around (such as when accessing it from an interaction)? does this already happen under the hood, and typescript just can't represent it?

i see this note in the guide, but not sure exactly how to go about this without casting or augmenting (as it seems to imply you can):

For TypeScript users, we recommend extending the base Client class to add this property, casting, or augmenting the module type.

rose tangle

yeah it gets passed around

you can cast safely

vagrant blade

so it does need casting? as said, that section of the guide seems to imply typescript can infer this somehow but i'm not seeing how that can happen. or maybe i'm misunderstanding it

red coral
sharp ginkgoBOT

We highly recommend you extend the Client structure properly instead of just attaching custom properties like .commands to the regular discord.js Client instance.

red coral

Second link I believe

vagrant blade

that's module augmenting, right? if it's that simple i can look into that for sure

red coral

I believe so

rose tangle
tiny condor

Heya, does this bring the guild tags now?

unique shoal

what is "this"?

14.22?

If so yes, those are "user guilds" in the API - silly naming I know

tiny condor

😂 why that's very weird, is there an event for them?

Like a user equipping the user guild

dense jackal
unique shoal

Not that I know of. Might fall under a GuildMemberUpdate

pulsar marsh

What is the reason property mentioned in latest core release? Is this for audit log only for actions like archive thread?

unique shoal

Yes

pulsar marsh

Ty 🙏

vestal fulcrum

Guild tag are also documented in this version right ??

tardy sable

whats user collectibles?

dense jackal
tardy sable

avatar decoration?

dense jackal

thats one of them yes

vestal fulcrum
unique shoal

?

dense jackal
unique shoal

I dont know how you translated that haha

dense jackal

use the docs if needed

vestal fulcrum
dense jackal
unique shoal

Please keep user apps out of here, stick to #app-commands if you must

tardy sable

if a role has a hex color now. does it mean the role primary color is always populated with the roles hex color?

vagrant blade
tardy sable
dense jackal

what?

unique shoal

To... provide the colour in hex format?

Why would we remove that?

tardy sable

but hexcolor is always the primary color right?

unique shoal

It provides the primary colour in hex string format, yes

tardy sable

ok thanks

smoky grail

What is userguilds?

unique shoal

tags

smoky grail

What do you mean?

dense jackal
bleak owl

your MQHW tag is a userguild

dense jackal

-# can someone edit the announcement to replace "user guilds" with "server tags"

unique shoal

no

But maybe in addition to, explain it

smoky grail

Ohh

tardy sable

userguild is UserPrimaryGuild?

unique shoal

yeah

rare citrus

Is any documenation available for the role gradients?

tardy sable

what it means identityEnabled, i didnt know u could disable or enable your guild tag from showing?

dense jackal
sharp ginkgoBOT
tardy sable
unique shoal

I mean thats what the docstring says

"Whether the user is displaying the primary guild's tag"

bleak owl

if you look at the docs you can see what each property means

unique shoal

Though I dont know how to control that

I had to go looking for where you even set the tag, Ive never bothered to find it lol

tardy sable

was just confused with the primary naming that it could mean a specific guild

unique shoal

It does?

dense jackal

I think the name "primary" is because you selected one specific guild (server) out of all guilds you are in to be present next to your name in the form of a server tag

smoky grail
unique shoal

I didnt, the author did

tardy sable
smoky grail

Ohh okay

unique shoal

I'm not sure I understand the question, that seems like the least important prop to compare

dense jackal
smoky grail
dense jackal

if (guildId === identityGuildId)

no need for the identityEnabled property whatsoever

unique shoal

whether the user is displaying the primary guild's server tag. This can be null if the system clears the identity, e.g. the server no longer supports tags. This will be false if the user manually removes their tag.

So no, users cant decide on their own to show it or not

But can be null if the guild removes the tag while users have it selected as primary

I would have thought if the user removes the tag, the other props would also be removed

tardy sable

uh im just gonna test out and see

grizzled bison

is there any guide for the latest features of version 14.22.0?

bleak owl

the docs has everything you need. there's no need for a guide for that

if you have any questions related to the latest update, don't hesitate to ask

tardy sable

is there an equivalent of resolveColor() but number to hex?

unique shoal

We wouldnt bother, its just <number>.toString(16)

tardy sable

oh ok thanks

grizzled bison

// This is the code I'm testing with:
const user = await client.users.fetch('500293365494054932', { force: true });
console.log(user.primaryGuild); // Always logs 'null'

unique shoal

If your bot isn't also in that guild, the guild wont be in your cache

You will have access to its ID, and you may be able to fetch some minimal public data about it

humble fern

Is there any way for the bot to set the image as a 'thumbnail' when creating the topic?

teal obsidian

with 14.22 it should be <role>.colors right?

sharp ginkgoBOT
topaz bluff

Correct, it's colors with an s. color still exists but is deprecated

topaz bluff
sharp ginkgoBOT
torn orchid

node:30836) DeprecationWarning: The ready event has been renamed to clientReady to distinguish it from the gateway READY event and will only emit under that name in v15. Please use clientReady instead.
(Use node --trace-deprecation ... to show where the warning was created)
[2025-8-20 21:55:22] WARNING: DeprecationWarning : The ready event has been renamed to clientReady to distinguish it from the gateway READY event and will only emit under that name in v15. Please use clientReady instead.

what does this mean

wary coral
bleak owl

exactly as it says. the "ready" event will be renamed to "clientReady" in the next major version of discord.js

so it's best to migrate your code to the new event name now to prevent issues in the future when the next major version is released

torn orchid

so I should rename ready.js > clientReady.js?

topaz bluff

No ...

bleak owl

no

your event name, not the file

though, you can do that if you want

torn orchid

oh alr

bleak owl

it won't change the way the event functions

its just a name change, same functionality

junior sentinel

hi

bleak owl
junior sentinel

So i am new to node js and tried with gpt to make saphire commands but idk how to make correct

bleak owl

this is the discord.js server

that provides support for the discord.js library

what do you need help with?

torn orchid
junior sentinel

I want run command on node js but its dosent work

topaz bluff
bleak owl

no, you change your code to what the warning says to make the warning disappear

torn orchid

k

junior sentinel

like for example "npm install @sapphire/framework discord.js@14.x"

bleak owl
topaz bluff
topaz bluff
bleak owl
junior sentinel

But how i dowloand djs v14

From node js text -> "Welcome to Node.js v22.18.0.
Type ".help" for more information.

npm init
npm should be run outside of the Node.js REPL, in your normal shell.
(Press Ctrl+D to exit.)

"

bleak owl

in your project's directory, npm i discord.js

junior sentinel

._.

bleak owl

npm should be run outside of the Node.js REPL, in your normal shell.

unique shoal

I suggest you brush up on how to write a node application, if you don't know how to install a package

This falls well into the fundamentals we expect you to know

junior sentinel

Im lowkey and im new to development

unique shoal

I'm well aware

rose tangle

the guide also explicitly says you should first know that, and some resources in case you don't

junior sentinel

wdym

rose tangle

with what?

junior sentinel

npm should be run outside of the Node.js REPL, in your normal shell.

unique shoal

Yes. Do not run node

Use npm in the terminal

junior sentinel

But like i want make costume command for saphire that requires, djs 14 , node js even sapphire framework!

unique shoal

Yes

junior sentinel

Those program need be installed how bruh

i search up for 3 hours and find nun

unique shoal

The way you've been told multiple times, and seem intent on arguing with instead of following mmLol

junior sentinel
topaz bluff

Your code folder

junior sentinel

uh

bleak owl

do you know how to navigate the terminal to change directories?

if not, we cannot help you further

topaz bluff

#resources has places you can go to learn the fundamentals...if you try and skip that, you're going to have a bad time

junior sentinel
unique shoal

Definitely not in node

Get out of node

You do not run commands in node

junior sentinel
unique shoal

So you open a terminal, such as command prompt or powershell, navigate to your project folder in that terminal, and run commands

This is likely the first thing almost any Node.js application tutorial would teach you, and I'm going to ask you one last time to go and follow one instead of wasting the time and patience of our volunteers

junior sentinel

1 question that my english broke down

late torrent
junior sentinel you mean in c desk or in node?

It might seem like you are being unable to get it about what exactly people are endeavouring to mean to.

If you are already in NodeJS repl then type in that input ".exit" to terminate the repl and you will be available to access your terminal again. Then you have to run:

# If you have not initiated
npm init --yes
npm install <packages>
junior sentinel

I cant even understand terminal..

bleak owl

that is the first step to learning how to program

so please do your best to learn how to use the terminal before you do anything programming related

junior sentinel

Im so stupid

So

bleak owl

no you're not. you just need to put in some effort into learning this

junior sentinel

I found Command promp and says Your environment has been set up for using Node.js 22.18.0 (x64) and npm.

C:\Users\my name>

torn orchid

[DATABASE] Connection established, but the state is not 'connected'.

how to fix that

junior sentinel

correct or no

bleak owl

if you don't, we cannot help you further im sorry

neat nimbus

was this ever fixed

bleak owl

then you can figure out how to enter your projects directory, then proceed to install discord.js via npm

regal plinth

so i have testing bot.. and now i want to figured out how to clear old slash commands and made the new im testing appear

like this command is old one and the new one doesnt appear

topaz bluff

If you rest.put, it will add, update, and delete slash commands all in a single request

Make sure to restart your discord client after deploying commands for them to appear (Ctrl+R)

junior sentinel

So i have this problem and idk what do next

dim gulch

Soooo I have a question, will the userUpdate event also be fired when a user changes their server tag now?

clear garnet

I would presume so, per Discord's documentation:

Sent when properties about the current bot's user change. Inner payload is a user object.

woeful forge

how I can refresh the hash to get new attachment?

unique shoal

By fetching the source message again to get a new attachment url

or - not using discord for file hosting

unique mountain
    try {
        const bannerUrl = member?.banner || member?.user.banner;

        if (!bannerUrl) {
            await interaction.reply({
                content: "This user doesn't have a banner.",
                flags: MessageFlags.Ephemeral,
            });
            return;
        }

        const mediaGallery = new MediaGalleryBuilder().addItems(
            new MediaGalleryItemBuilder()
                .setURL(bannerUrl)
                .setDescription(`Banner of ${member?.user.username}`),
        );

I have a user that has a global but not server-specific banner, how can I gracefully fallback? 🤔

Here's my "member" btw

const member = options.member || interaction.member;

I keep hitting the early return message for users that do have a banner, just not server-specific

snow onyx

member.displayBannerURL() returns the members banner url, if they have one. Otherwise the global user banner.

null if they dont have one

unique mountain

Doesn't look like I have access to the property

snow onyx

what is member defined as

unique mountain

Here's full context, apologies

import {
    type ChatInputCommandInteraction,
    ContainerBuilder,
    MediaGalleryBuilder,
    MediaGalleryItemBuilder,
    MessageFlags,
} from "discord.js";

import {
    type CommandOptions,
    type CommandResult,
    createCommandConfig,
} from "robo.js";

export const config = createCommandConfig({
    description:
        "Fetch the server banner of the specified member, defaults to self",
    options: [
        {
            name: "member",
            type: "member",
            description: "The member to fetch the banner of",
            required: false,
        },
    ],
} as const);

export default async (
    interaction: ChatInputCommandInteraction,
    options: CommandOptions<typeof config>,
): Promise<CommandResult> => {
    const member = options.member || interaction.member;

    if (!interaction.inCachedGuild()) {
        await interaction.reply({
            content: "This command can only be used in a server.",
            flags: MessageFlags.Ephemeral,
        });
    }

    try {
        const bannerUrl = member?.banner || member?.user.banner;

        if (!bannerUrl) {
            await interaction.reply({
                content: "This user doesn't have a banner.",
                flags: MessageFlags.Ephemeral,
            });
            return;
        }

        const mediaGallery = new MediaGalleryBuilder().addItems(
            new MediaGalleryItemBuilder()
                .setURL(bannerUrl)
                .setDescription(`Banner of ${member?.user.username}`),
        );

        const container = new ContainerBuilder();
        container.addMediaGalleryComponents(mediaGallery);

        await interaction.reply({
            components: [container],
            flags: MessageFlags.IsComponentsV2,
        });
    } catch {
        await interaction.reply({
            content: "This user is not in the server.",
            flags: MessageFlags.Ephemeral,
        });
    }
};
snow onyx

put the const member =... below the inCachedGuild check

otherwise the member can be an APIInteractionGuildMember

unique mountain

ahh

I think the library I'm using types it as an APIInteractionGuildMember, I'll see if I can cast it

snow onyx

djs does that if you didn't use any typeguards

sweet flax

Does anyone know how I can get any message my bot sends weather it's ephemeral or not?

Because I want to make a system where I can just have a collection of message ID's and their respective interactable components inside it so I can check if weather or not that message ID and their components are valid or not (Like a timer before the component can be interactable or not)

steel trail
unique shoal
sweet flax

:O

sleek tundra

hello my brothers

do you have the documentation to understand how to get an USER TAG ?

Like, if i have DRGN TAG, i receive role.

sharp ginkgoBOT
dense jackal
unique mountain

I'm still having trouble when trying to fallback to their global banner 🤔

dense jackal

and what's what you have trouble with then?
with just code I can't really provide help

sleek tundra

for this advice.

Discordjs Voice is nice?

Can i do speak the bot?

sweet flax
unique shoal

What are you trying to capture?

And what makes that "sketchy" exactly?

unique mountain
dense jackal and what's what you have trouble with then? with just code I can't really provid...

The expected result of this command is to show the users server-specific banner or if they don't have one but do have a global banner, show that instead. For users with neither (non-nitro users or nitro users without a banner) show a graceful error message. My current issue is that nitro users with a global banner set (not guild specific) hit the same generic "You don't have a banner set" as non-nitro users.

sweet flax
unique shoal What are you trying to capture?

I want to have a system that handles the button or Menu dropdowns, etc that runs back to my module.export in my commands js file so i don't have to think about all the messy interaction between

I followed the DiscordJS guide for setting up a basic project that uses the uh commands and events folders to run the commands and initialize them and what not, and I want to just add onto the async execute idea they put into it, so I can like receive all my button interactions in that js file itself, so its all contained in the same area.

sweet flax
unique shoal And what makes that "sketchy" exactly?

like checking every interaction component that is ever ran through customId checks to see if contains the right format, and if it does then just reroute it based on the information or whatever

cuz I don't want to have to remember the formatting for a customId and just get confused why my interaction won't work

btw sorry if its confusing rn im just tired and im slowly processing information rn 🥀

on power save mode fr

dense jackal
dense jackal
sweet flax

Well yeah I know that, but I am trying to then get that interaction back to the command structure it was sent from

So in my case, if I use /test and it sends a button component and then I click it, from InteractionCreate it should detect what command it was sent from and then require the JS file to then send the appropriate function call, so I don't have to worry about random Interaction garbage that isn't even related to the button component I'm trying to check for

But now thinking about it, might it be easier to just really filter garbage? ugh idk

The only reason I wanted it to be clean was I was adding a Page System class so I could have clean pages with the new ComponentsV2 Containers
But detecting button interaction for that specific page instance is annoying to consider because you need to think about the Items in the page, and the information needing to be updated dynamically when editing the message and what not.

dense jackal
unique shoal
sweet flax
dense jackal is that button component in between `/test` and the correct function call needed...

Well it's from a ContainerBuilder so I don't have direct access to it unless I de-structure it into variables to have CollectionEvents or smth

Here is like an example of what Im trying to achieve basically ig
So you have the exampleButton being set in ButtonAccessory and then from the InteractionCreate event it should then call the onButtonInteraction function back into the command.js

So I don't have to care about the small stuff

unique shoal

I'd suggest using interaction ids as reference data and storing what you need alongside those

sweet flax
dense jackal

ye

unique shoal

Small amounts yeah

sweet flax

It just feels wrong to me 😭

unique shoal

A custom id like command_id_action is fine

If you need to store more information id do command_button_<unique id here> or whatever that I can then lookup in a Map

sweet flax

alr I guess I'll keep this in mind ty

sweet flax
unique shoal

It wouldnt, Collections are extended Maps

dense jackal

collection extends map afaik

unique shoal

Map is the core useful part allowing you to .get(id)

sweet flax

oh so it just has some extra funky functions

unique shoal

yeah

sweet flax

peak, ty again ❤️

unique shoal

Collections are a hybrid Map/Array basically, extending Map as the base structure

buoyant prawn

Hey all, quick question, since which version was .setDMPermission for the SlashCommandBuilder deprecated?

unique shoal

Dont know exactly but a while ago, why?

steel trail

Ever since discord deprecated it in the API and contexts and integration types were introduced

daring coral
buoyant prawn

I've been out of bot development, and just noticed it in one of my commands. Does any of you happen to know where I can find more information on these integration types and installation contexts?

sharp ginkgoBOT

discord Developing A User-Installable App - Step 2: Setting Up Commands
integration_types lets you control which installation contexts a command is supported (user, guild, or both). For example, the /link and /profile commands we'll be creating are only available when the app is installed to a user.
read more

guide Creating Your Bot: Creating slash commands
Integration with the Discord client interface.
read more

unique shoal

I think our guide is updated too

buoyant prawn

I'll take a look, thanks!

unique mountain
dense jackal

but I can't help you with just code and assumptions or imaginations, I need concrete values from a log statement

unique mountain
unique shoal

banner information is not sent in user/guild member events

You need to force fetch the user

dense jackal

ahh yeah i forgot

await guild.members.fetch(userId, { force: true });

sick rover

Hey i got a quick question, When retriving the payload from a componentv2 container, How would you edit the specific field using the ID that's set on it

Or is that even possible by chance

lyric moss

Can someone recommend the best strategy when I have periodic updates to perform in a status message embed on several hundred servers?
How do I best deal with potential rate limiting on one guild without blocking the update on others, for example?

red coral

Message edit rate limits are per channel I believe, not per guild

lyric moss

Yes, I know that 👍

But if for some reason one create or edit is rate limited, what is a good architecture to prevent that from blocking everyone else?

dense jackal
unique shoal

A "good architecture" wouldnt do this at all, since thats not what the Discord platform is really designed for

sick rover

Hey monbrey do you possibly know if components/containers can be fetched via payload in a thread

lyric moss
dense jackal its per channel so doesn’t matter?

If a loop over all messages that need editing encounters a rate limit the call will then return with a sync/await and block until it can continue, that's why I ask for a general architecture on how that could be done better🙂

lyric moss
unique shoal
unique shoal
sick rover
unique shoal

There is no compliant architecture which will avoid Discord rate limits. Webhooks are the only alternate rate limits available

unique shoal
sick rover

And that would overlap correct?

unique shoal

Overlap? It will replace the old components with the edit, yeah

dense jackal
sick rover

And there's no way to preserve those old components at all

steel trail

You include them in the edit payload

sick rover

though how would i do that, unless i retrieve the original content

steel trail

By retrieving the original content

That's what fetch is for

sick rover

and could i do that with getting the payload of the components or no

steel trail

Yes, components are included in the message payload you can fetch

sick rover

So then if i take a interaction from the button interaction, and then do interaction.client.channels.fetch(thread.id)

and then take the payload from the top message of that channel, it should supply me with everything in that payload

Then when i am editing it, all i do is use a new containerBuilder to basically overlap it

crimson gale

if the button is on said message you don't need to do that step it'll be in the inner interaction message from the button press

sick rover

Yeah but i want to make sure that the buttons get removed after the interaction p much from inside the container*

crimson gale

then you respond to the button press with an update and supply the components you want to be present after the edit

unique shoal

You can pass an old container to a new container builder

I think is what you're asking?

sick rover

Yeah like passing most of the content from the old container, to the new container and just editing:

  • One of the fields that i want to edit
  • Changing the color of the container
  • Removing the buttons from the container

that's all i want to do

slender sorrel

what the upload size limits

loud quartz

same as for regular users or members

slender sorrel

oh so in lvl 3 boost server 100mb

loud quartz

yeah

slender sorrel

is it possible to get more than 100

dense jackal

no

why would a bot even send 100MB+ files

slender sorrel
dense jackal

150mb gif??

loud quartz

buy nitro

but bots can't do that

so they cannot send that

case closed

slender sorrel

thx

dense jackal

use some compression on the gif lol

slender sorrel
dense jackal

how high quality gif you have for it to be 150 mb

slender sorrel

the frames depends to multiple

dense jackal

a game in discord? you really should use Discord Activities instead

slender sorrel
dense jackal

then compression it is shrug

slender sorrel

yes i will

loud quartz

pretty sure those aren't mutually exclusive things

slender sorrel
wooden carbon
slender sorrel

so yeah thx guys

loud quartz
wooden carbon

stake's crash thing?

loud quartz

stop

wooden carbon

huh what?

loud quartz

not a channel for such questions

wooden carbon

k

proud arrow

This is not a job board, please take it somewhere else

burnt orbit

Is there a method for looking up the mutual servers/guilds between a user and the bot? Or should I just call GuildMemberManager:Class#fetch in every guild the bot is in?

unique mountain

If I try to use force I'm getting this in my IDE

dense jackal

mixed up the client.users.fetch() with this fetch method

-# idk why thats even different in params but sure

polar karma
burnt orbit

The mutual guild lookup would only be run on a specific interaction, so not regularly per se, I'd imagine caching does a lot of work as well (possibly with Redis in front)

polar karma

If you have the guild members intent, you could fetch members once, then the cache would be populated and updated as new events are received

burnt orbit

Default d,js cache is memory based right?

halcyon vault

Did container can send in private message, i mean flag 64
-# on interaction.

unique mountain
dense jackal ah my bad, should be `fetch({ user: member.id, force: true });`
discord:event - Received slash command interaction: /user server banner
(node:50491) Warning: Supplying "ephemeral" for interaction response options is deprecated. Utilize flags instead.
(Use `node --trace-warnings ...` to show where the warning was created)
User banner fetched: null
discord:event - Event received: messageCreate
discord:error - Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.

Now apparently I'm replying twice (one instance)

Thinkeng

dense jackal
sharp ginkgoBOT
  • DiscordAPIError: Interaction has already been acknowledged
  • [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.

You have already replied to the interaction.

  • Use <Interaction>.followUp() to send a new message
  • If you deferred reply it's better to use <Interaction>.editReply()
  • Responding to slash commands / message components
halcyon vault
loud quartz
grizzled bison

hello How to make a nameplate into an image like a banner?

unique mountain

@wary coral i appreciate the attempt to point me to documentation, but in my case I haven't yet sent a reply or deferred so I can only imagine I'm hitting the 3 second interaction window? Did you look at my source beforehand?

dense jackal
snow onyx

if you catch your errors properly with stacktrace we could pinpoint where

but now its just a lot of guessing

dense jackal

this

unique mountain

that's fair - apologies I'm cut short for time, thanks nonetheless

merry cedar

hi i need many bots in my server but i keep hitting rate limit i want to ask what is the rate limit how long it lasts and how many bots i can create in 24 hours

polar karma

That's not related to d.js, you can try asking in ddevs

merry cedar

okay thx

tropic yoke

Is it possible to connect bot in dms call ?

tropic yoke

thx

waxen venture

Hi :) I'm having some trouble sending new container components with d.js and i get this error:

data.components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).```

This turns up whenever I try to put a container in a components argument (it seems like it's expecting only action rows still?) I've tried `npm update discord.js`
rose tangle

sounds like you're not sending the IsComponentsV2 flag

btw DiscordAPIError means that discord itself sent the error, not djs

it's usually a payload issue, not something in djs side (eg an outdated version)

waxen venture

Yeah I assumed so which only made things more confusing (:
what is this flag i need to send

sharp ginkgoBOT

dtypes v10: MessageFlags - IsComponentsV2
read more

rose tangle

send it on flags: in your message options

sharp ginkgoBOT

guide Popular Topics: Display Components - Container
read more

rose tangle

the example shows exactly how

waxen venture
unique mountain
sharp ginkgoBOT

tag suggestion for @unique mountain:
To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.

rose tangle
unique mountain
rose tangle

well it explicitly says "auto-defer your replies if things are taking longer than 250ms"

so indeed, it's a matter of timing

I'd recommend reading the docs I linked

and asking robojs' support their recommendations and whatnot

unique mountain

but it's working consistently after the first use since bot startup

unique mountain
unique mountain
rose tangle

you could just disable that feature or use it like it's intended to be used

odd crown

Anyone know of anything going on with discord at the moment? I keep getting errors indicating my application didn't respond, but I verified the bot is up and running.

red coral

Network instability? Doesn’t have to be discords side but who knows, if there’s nothing on the status page then no

odd crown
red coral

Just reply quicker

unique mountain

can you add images via the mediaGallery in sections side by side?

not to be confused with multiple images in the same gallery

i want two instances of the mediaGallery next to each other basically

rose tangle

why? multiple images in the same gallery show side by side

there's no way to do what you're asking but it sounds like it's not necessary

unique mountain
rose tangle

it isn't possible

late pelican

Hey guys, Is it possible to get the guild tag from the guild ID?

dense jackal

lol what I can't find it on the guild object

seems reasonable to have that there as well but sure, then its only accessible through the user object

late pelican

I mean I can probably check if "identity_guild_id" matches my guild id, then it should mean they probably have my guild tag active?

bleak owl

it is however available in the api

late pelican

<3

dense jackal

ahh gotcha

somber dome
if (i.channel.isThread()) {
            await i.channel.members.add(member.id);
   }

error:

uncaughtException:  DiscordAPIError[50001]: Missing Access
    at handleErrors (C:\Users\shong\m92-ticket\node_modules\@discordjs\rest\dist\index.js:749:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (C:\Users\shong\m92-ticket\node_modules\@discordjs\rest\dist\index.js:1150:23)
    at async SequentialHandler.queueRequest (C:\Users\shong\m92-ticket\node_modules\@discordjs\rest\dist\index.js:981:14)
    at async _REST.request (C:\Users\shong\m92-ticket\node_modules\@discordjs\rest\dist\index.js:1294:22)
    at async ThreadMemberManager.add (C:\Users\shong\m92-ticket\node_modules\discord.js\src\managers\ThreadMemberManager.js:115:5)
    at async Client.<anonymous> (file:///C:/Users/shong/m92-ticket/index.js:619:13) {
  requestBody: { files: undefined, json: undefined },
  rawError: { message: 'Missing Access', code: 50001 },
  code: 50001,
  status: 403,

why?

dense jackal
rose tangle

how do you know?

somber dome

bot have administrator

and "ManageThreads" in a parent channel

rose tangle
sharp ginkgoBOT

guide Popular Topics: Permissions (extended) - Missing permissions
read more

rose tangle

make sure that all the cases in that guide are covered

somber dome

uncaughtException: DiscordAPIError[50001]: Missing Access
at handleErrors (C:\Users\shong\m92-ticket\node_modules@discordjs\rest\dist\index.js:749:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\shong\m92-ticket\node_modules@discordjs\rest\dist\index.js:1150:23)
at async SequentialHandler.queueRequest (C:\Users\shong\m92-ticket\node_modules@discordjs\rest\dist\index.js:981:14)
at async _REST.request (C:\Users\shong\m92-ticket\node_modules@discordjs\rest\dist\index.js:1294:22)
at async ThreadMemberManager.add (C:\Users\shong\m92-ticket\node_modules\discord.js\src\managers\ThreadMemberManager.js:115:5)
at async Client.<anonymous> (file:///C:/Users/shong/m92-ticket/index.js:621:13) {
requestBody: { files: undefined, json: undefined },
rawError: { message: 'Missing Access', code: 50001 },
code: 50001,
status: 403,
method: 'PUT',
url: 'https://discord.com/api/v10/channels/1408213624505372726/thread-members/805456030582439936'
}

I gave it permissions but it doesn’t work.

unique shoal

Well then no, you didnt

It does not have permissions

somber dome

What should I give it?

unique shoal

Missing Access usually implies not having permissions over the thread at all, suggesting its the parent channel

rose tangle

can you console.log(i.channel.permissionsFor(i.guild.members.me).serialize()) and show the output

lean sail

how would i get the number of bots in my server?

rose tangle

you'd need to fetch all members and filter in the resulting collection

sharp ginkgoBOT
somber dome
rose tangle can you `console.log(i.channel.permissionsFor(i.guild.members.me).serialize())` ...

{
CreateInstantInvite: true,
KickMembers: true,
BanMembers: true,
Administrator: true,
ManageChannels: true,
ManageGuild: true,
AddReactions: true,
ViewAuditLog: true,
PrioritySpeaker: true,
Stream: true,
ViewChannel: true,
SendMessages: true,
SendTTSMessages: true,
ManageMessages: true,
EmbedLinks: true,
AttachFiles: true,
ReadMessageHistory: true,
MentionEveryone: true,
UseExternalEmojis: true,
ViewGuildInsights: true,
Connect: true,
Speak: true,
MuteMembers: true,
DeafenMembers: true,
MoveMembers: true,
UseVAD: true,
ChangeNickname: true,
ManageNicknames: true,
ManageRoles: true,
ManageWebhooks: true,
ManageEmojisAndStickers: true,
ManageGuildExpressions: true,
UseApplicationCommands: true,
RequestToSpeak: true,
ManageEvents: true,
ManageThreads: true,
CreatePublicThreads: true,
CreatePrivateThreads: true,
UseExternalStickers: true,
SendMessagesInThreads: true,
UseEmbeddedActivities: true,
ModerateMembers: true,
ViewCreatorMonetizationAnalytics: true,
UseSoundboard: true,
CreateGuildExpressions: true,
CreateEvents: true,
UseExternalSounds: true,
SendVoiceMessages: true,
SendPolls: true,
UseExternalApps: true
}

lean sail
dense jackal
rose tangle
somber dome

regular member

rose tangle

maybe they don't have permissions to be in the thread?

no idea how that works

you could ask in ddevs #useful-servers given it's more of an api question

lean sail

why is it saying bots are 0 when there are bots?

bleak owl

you need the GuildMembers intent

lean sail
bleak owl

please show that you do

lean sail
polar karma

Why are you doing .values.length? Did doing .size return 0?

.values() is also a method but you didn't use it as such, that code should have returned undefined

-# you also should just fetch on ready and use the cache data because it still be updated with new events. Discord recently announced a stricter fetch ratelimit for that endpoint

uneven crater

Which would explain why they see 0 even if they do have the intent.

polar karma

Oh, I'm certainly no js expert mmLol

Anyway, using the size property would be better

frosty epoch

modal fields headers can only be 45 chars long?

polar karma

The API docs should list any relevant limits

sharp ginkgoBOT
frosty epoch

such a short limit is a crime

rain forum

guys what different bytown

interaction.isChatInputCommand()
and
interaction.isCommand()

uneven crater
bleak owl

the former is for slash commands, the latter is for both slash commands and context menus

rose tangle

also entry point commands

unique mountain

is there a place where I can see what error types are thrown for example, when a guild doesn't have an icon? A source of truth for error return types

rose tangle

there's no error? it just returns null

unique mountain

hm i see

what about a generic permission error from the user side trying to use a command that their permissions are too low for

rose tangle

there's no error for that either, it just doesn't show the command

assuming you mean the default permissions you can set from the slash command builder/data

unique mountain

i didn't even know that was a thing, i kept my permission logic bundled with the command logic, that's neat

anyway my aim is to throw my own errors similar to discord to then catch them in a global error handler that replies with generic error messages

rose tangle

if they're your own then that's entirely on your side to handle

unique shoal

You'll probably find that JS isnt a particularly good language for doing that in

unique mountain

what path do you suggest for global error handling in that case?

rose tangle

djs doesn't have an error handling system if that's what you're asking, apart from the Client#error event which is a thing inherited from the (async) EventEmitter

unique shoal

Catching errors locally and passing them off to some utility, like logger.handleError or whatever, then you can pass your own info object to it also

unique mountain

a prime example, "This is not your interaction" for button interactions

rose tangle

you're free to do whatever implementation you'd like

unique mountain
rose tangle

djs just handles the discord connection part

sharp ginkgoBOT
rose tangle

@sudden grove please use #app-commands or the hide option for personal docs usage

cosmic burrow

wrong channel?

bleak owl

i was about to answer, you're in the right place for that err

the guild id you put is not an actual id. did you put the id as a number or a string

cosmic burrow
bleak owl

can you show that you did?

cosmic burrow
const { Routes } = require('discord-api-types/v10'); // You'll also need this for the Routes class
const { clientId, guildID,  token } = require('./config.json');
const fs = require('node:fs');
const path = require('node:path');

const commands = [];
const foldersPath = path.join(__dirname,  'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders)  {
  const commandsPath = path.join(foldersPath, folder);
  const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));

  for (const file of commandFiles) {
      const filePath = path.join(commandsPath,  file);
      const command = require(filePath);
      if ('data' in command && 'execute' in command)  {
          commands.push(command.data.toJSON());
      } else {
            console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
        }
    }
}

const rest = new REST().setToken(token);

(async () => {
    try {
      console.log(`Started refreshing ${commands.length} application (/) commands.`);
      const data = await rest.put(
        Routes.applicationGuildCommands(clientId, guildId),
        { body: commands },
      );

      console.log(`Successfully reloaded ${data.length} application (/) commands.`);
    } catch (error) {
      // And of course, make sure you catch and log any errors!
      console.error(error);
    }
})();```
bleak owl

what did you put as the guildID in your config.json?

cosmic burrow
bleak owl

that's not what i asked

i was asking what you put

cosmic burrow
bleak owl

i see the problem

you misspelled it

cosmic burrow

where is it?

bleak owl

one is guildID, one is guildId

cosmic burrow

Oh

bleak owl

your import is probably incorrect, so check your config.json to see what you defined it as

cosmic burrow

i just fixed it already

bleak owl

just a minor fix you should do,

const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v10');

these should be one import directly from discord.js as shown,

const { REST, Routes } = require('discord.js');
cosmic burrow

i just fixed to prevent being mispelled

i changed it const { REST, Routes } = require('discord.js');

bleak owl

looks good

dense jackal
odd moon

I'm running into a strange problem currently where my bot seems to be connecting to voice channels and playing sounds correctly, however, when I try and test it myself it appears that the bot is giving an error when connecting to the voice channel. Any idea what could be going on? This is pretty strange.

I'm just getting this: Connect Error: {}

The issue appears to occur in both the latest @discordjs/voice version and the one before it. For reference, I upgraded to @discordjs/voice and the latest discord.js and then reverted cause I thought that the update caused the problem but then I notice it was occuring on an untouched build as well.

loud quartz

what does "test it myself" mean here

your bot works and doesn't work at the same time?

odd moon

Like I'm not getting any user complaints about audio playback failing, yet when I run it myself in voice channel it is not working the same way

@loud quartz I suppose to rephrase for simplicity. Bot was joining the voice channel and playing audio just fine on commnand trigger. Now randomly, despite no code changes, that has stopped working.

Apologies, I figured out the issue, was not Discord related 👍

grim sinew

Hey how do I send a embed directly in an interaction reply again? Any help appreciated very much

upbeat bough

14.22.0

sharp ginkgoBOT
unique shoal
upbeat bough
unique shoal

Looks like a version mismatch. Can you please run npm ls discord-api-types and show the full output

upbeat bough
unique shoal

yup. .2 and .21

We might need to fix that

Let me get back to you on that

upbeat bough

ok thx

upbeat bough
unique shoal

Thats just plain wrong. Might need to restart the editor/TS server

upbeat bough

thx it fix

golden laurel
upbeat bough
golden laurel Can you copy + paste that code here please
import { REST, RESTPostAPIChatInputApplicationCommandsJSONBody, Routes } from "discord.js";
import config from "./config";
import { readdirSync } from "node:fs";
import { Command } from "./utils/Discord";

const rest = new REST({ version: "10" }).setToken(config.token);

let commands: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [];
let commandsDev: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [];
readdirSync(`${__dirname}/commands`).forEach((folder) => {
    readdirSync(`${__dirname}/commands/${folder}`)
        .filter((file) => file.endsWith(`.js`))
        .forEach((file) => {
            const CommandClass = require(`${__dirname}/commands/${folder}/${file}`).default;
            const command = new CommandClass() as Command;
            if (command.getOwner()) {
                commandsDev.push(command.applicationCommands().toJSON());
            } else {
                commands.push(command.applicationCommands().toJSON());
            }
        });
});

console.log(commands);
console.log(commandsDev);

const clientId = atob(config.token.split(".")[0]);

rest.put(Routes.applicationCommands(clientId), { body: commands })
    .then(() => console.log(`Successfully registered ${commands.length} application commands`))
    .catch(console.error);

rest.put(Routes.applicationGuildCommands(clientId, config.guild_dev), { body: commandsDev })
    .then(() => console.log(`Successfully registered ${commandsDev.length} application commands for dev guild`))
    .catch(console.error);
golden laurel

Can you nuke your lockfile and node_modules and install again? I think the error will go away

grim sinew

Is there anyway to have a button collector last forever? Like when I turn off the bot and turn it on again the button collector will still be able to collect?

snow onyx

yes, its called the interactionCreate event xD

dense jackal
grim sinew
dense jackal

you probably using them already in ur project

client.on(“interactionCreate”, () => { … }); is a gateway event listener

toxic moat

How do I detect if a person wears the server tag

sharp ginkgoBOT
grim sinew
dense jackal

so you know that only button interactions go through, you can then filter on custom id

if (interaction.customId === “myButton”)

stuff like that, you’re basically free in how you approach it

use the docs if you need assistance with button interactions

sharp ginkgoBOT
granite lion

do messageUpdate events fire for pins as well

loud quartz

it's pretty trivial to check yourself

you'll have the most up to date information

queen vale

Anyone know a way to not have the commands button be shown in bot dms?

pulsar spindle

can we fetch a servers's tag (the guild tag) info?? to check if its enabled or not (pls reply with a ping)

loud quartz

if you're in dms with a bot, discord just shows that button by default first

literally all there is to it

queen vale

pain