#djs-help-v14

78874 messages · Page 61 of 79

rose tangle

reply(), deferX() and update() are acknowledgements/replies

you can only acknowledge/reply once

after that you can only followUp or editReply

rose tangle
subtle girder

oh, I see :)
tysm [hard to choose an emoji]

waxen walrus
export const data = new SlashCommandBuilder()
    .setName(`ping`)
    .setDescription(`Replies with bot latency`)
    .setContexts([InteractionContextType.BotDM, InteractionContextType.Guild, InteractionContextType.PrivateChannel]);

export const execute = async (client: Client, interaction: ChatInputCommandInteraction) => {
    await interaction.reply({
        embeds: [newEmbed().setDescription(`Current latency is ${Date.now() - interaction.createdTimestamp}ms.`)],
        flags: MessageFlags.Ephemeral,
    });
};

I have a simple command that I want to use in dms using the bot as an installable app for accounts, but despite having deployed it like this and having refreshed multiple times, the ping command does not seem to show up in my account, what am I doing wrong?

sharp ginkgoBOT
unique shoal

You might also need to set this

indigo storm

Hello, i have discord bot with 15 slash command but the bot don't have slash commands tag what i need to do?

novel mauve

the commands need to be global for the badge_commands to show

keen monolith

how do I update an channel's parent, that has been created by the bot?

steel trail

Do you want to move a channel to another category? Or edit the parent channel's properties?

keen monolith

move it to another category

sharp ginkgoBOT

method GuildChannel#setParent() discord.js@14.25.1
Sets the parent of this channel.


// Add a parent to a channel
message.channel.setParent('355908108431917066', { lockPermissions: false })
  .then(channel => console.log(`New parent of ${message.channel.name}: ${channel.name}`))
  .catch(console.error);

keen monolith

tysm!! btw what is lockPermissions?

steel trail

Or in the create call itself you can pass parent:

sharp ginkgoBOT
keen monolith

I see tysm!!

okay. I am still a bot confused so here is my code

if (customId === "report") {
                type = "report";

                openingMessage = `
thank you for wanting to report someone and keeping chonsa safe!  
Before continuing please select one of the following buttons:

for reporting owners : please dm holly (yejin.luvs)

:tedz: : reporting staff (all roles except owner)  
:cinnabuun: : reporting members  

_ _
`;
                const reportButtons = new ActionRowBuilder().addComponents(
                    new ButtonBuilder()
                        .setCustomId("report_staff")
                        .setEmoji("1440509194477502525")
                        .setStyle(ButtonStyle.Secondary),

                    new ButtonBuilder()
                        .setCustomId("report_member")
                        .setEmoji("1440509196083921017")
                        .setStyle(ButtonStyle.Secondary)
                );

                const channel = await interaction.guild.channels.create({
                    name: `${type}-${interaction.user.username}`,
                    type: ChannelType.GuildText,
                    parent: '1440591960116166767',
                    permissionOverwrites: [
                        { id: interaction.guild.id, deny: ['ViewChannel'] },
                        { id: interaction.user.id, allow: ['ViewChannel', 'SendMessages', 'ReadMessageHistory'] },
                        { id: '1442258475408294061', allow: ['ViewChannel', 'SendMessages', 'ReadMessageHistory'] },
                    ],
                });

                await interaction.reply({
                    content: `Your **${type}** ticket has been created: ${channel}`,
                    ephemeral: true
                });

                await channel.send({
                    content: `<@${interaction.user.id}>\n${openingMessage}`,
                    components: [reportButtons],
                });

                return;
            }```
if (customId === 'report_member'){
                await interaction.reply(`Thanks for selecting member! Now in your own words please describe the reasoning behind your report and any proof you may have.`)
            }

            if (customId === 'report_staff'){

                await interaction.channel({
                    parent: `1442207807393890374`,
                    permissionOverwrites: [
                        { id: interaction.guild.id, deny: ['ViewChannel'] },
                        { id: interaction.user.id, allow: ['ViewChannel', 'SendMessages', 'ReadMessageHistory'] },
                        { id: '1442258475408294061', deny: ['ViewChannel'] },
                    ],
                    
                })

                    await interaction.reply({
                    content: `Ticket moved`,
                    ephemeral: true}),

                    await channel.send({
                        content: `Thanks for selecting staff! This ticket has been moved to the founder section so only they and owners can view. Now in your own words please describe the reasoning behind your report and any proof you may have.`
                    })
            }
        }
    },
};
loud quartz

interaction.channel()?

steel trail

interaction.channel is the channel, not a method. You need to call .edit() on it

keen monolith

OH EDIT

tysm

it's now saying channel isn't defined but it is? no?

steel trail

No, you never defined a variable by that name

interaction.channel is

keen monolith

so how would I send the message?

steel trail
keen monolith

oh okay ty

simple coral

guys

is there a way to check whether a user is wearing a server tag of a specific server

sharp ginkgoBOT
untold skiff

Heya, I cleared my sqlite db and now when I run my commands, it says "The Application did not respond" but if I run the command again, it then works as intended. Why is this?

polar karma

What's the code?

untold skiff

Of?

wary coral

Of your program

untold skiff

Of the command, of the db? What exactly lol

rose tangle

of your command, that's the one replying to the interaction

untold skiff
rose tangle

you're most likely getting an unknown interaction error

but there's no way to tell since you catch errors and ignore them when replying

you should not do that, and defer at the beginning so you can modify the db and not worry about the interaction lifetime

azure forge

Mhm; may I have a quick question on how message fetches works? I lost my database (silly me, I didn't do backup) and I am trying to fetch every message in the server which is fairly small (around 280k messages), and I did the command 3 times but weirdly enough it always stops at 80k messages.

median ferry

is not possible to display custom emojis in embed footers? it appears raw

steel trail
azure forge
sharp ginkgoBOT

Ratelimits are dynamically assigned by the API based on current load and may change at any point.

  • The scale from okay to API-spam is sliding and depends heavily on the action you are taking
  • Rainbow roles, clock and counter channels, and DM'ing advertisements to all members are all examples of things that are not okay
steel trail

The first sentence is what I intended to show you. Djs handles the waiting for rateLimits to pass for you. You don't have to add any wait yourself to do so

azure forge

But ultimately is... it won't stop right? It will be hold (paused) if I understood you correctly?

Yes, I have checked now, it was hold, silly me, I thought it stopped.. I am so stupid. Oh well, 4th and last time to do the command.

bleak tangle

Hi 👋

In my command, I create a modal with text inputs whose values will be included in an embed post. Now I also want to give users the option to notify certain roles with their post. As far as I can see, I can't ping any roles within embeds, and no role suggestions appear when I type @ in the text inputs. So I guess the only way to ping roles in the resulting post is to pass roles as command options, so they can be included in the post content (instead of embed)? Or am I missing a better approach?

wary coral
bleak tangle
bleak tangle

My modal already has 5 inputs, which is the maximum amount of input a modal can have as far as I know. So I guess I have to somehow split up my inputs into 2 modals so I can add the role select menus

shell girder

Hi, do you know if the use of number input components is available yet? Or has it not been officially released yet?

wary coral

It that case I would recomed that you add is as a command option then pass it to the modal like in the custom id or via an other method

wary coral
shell girder

What would be the method for using it? If you know, could you please help me?

topaz bluff
ruby bane

p sure thats a concept image from the discord api docs PR for more modal components

shell girder

Yes, I saw it on GitHub and I thought it was documented.

topaz bluff

It was not. The GitHub discussions are all community posts. That image is a concept image from many years ago when they asked for more modal components. It does not exist

There's only TextInput, FileInput, and SelectMenu components

shell girder

I understand, thank you very much for the information. 😉

median ferry

button ids can't be tampered with, right? I guess theres any server side checks. Because I'm doing a report system and it saves the report id in the button to be accessed from buttoninteraction but I'm not sure at all if a user can just tamper it with devtools or something weird

median ferry
tardy sable
obtuse laurel
tardy sable

if thats the case, no, others cant edit someones else message

obtuse laurel
crimson gale

can repost the link if you want, i'm not enitrely sure why that filter was in place but prob. connected to some scam/phishing shenanigans

median ferry
crimson gale

did you try to post a link that was caught in our filters? if so, maybe, if not, probably not

median ferry

oh okay sorry, I didn't understand the message firstly so I was a bit out of my place

median ferry

how do I extend modal reply time? becasue deferUpdate already closes it

steel trail

yes, that's intended. the modal should get closed as soon as the submission is received

you still get 15 minutes after your defer

median ferry

oh okay, thanks

fierce jolt

Hello, I was coding a config that change my bot avatar. The code was working but now it isn't working (it's the same code that i used before). Does anyone know what is the problem?

steel trail

without seeing your code and knowing what "not working" means: no

fierce jolt

The problem isnt the code because its the same that worked before


module.exports = {
  data: new SlashCommandBuilder()
    .setName("config")
    .setDescription("Configures the bot")
    .addStringOption((option) =>
      option
        .setName("username")
        .setDescription("Defines bot username")
        .setRequired(false)
    )
    .addStringOption((option) =>
      option.setName("avatar").setDescription("Sets the bot avatar")
    )
    .addStringOption((option) =>
      option.setName("activity").setDescription("Defines bot activity")
    )
    .addStringOption((option) =>
      option
        .setName("status")
        .setDescription("Sets bot status")
        .addChoices(
          { name: "online", value: PresenceUpdateStatus.Online },
          { name: "idle", value: PresenceUpdateStatus.Idle },
          { name: "donotdisturb", value: PresenceUpdateStatus.DoNotDisturb },
          { name: "invisible", value: PresenceUpdateStatus.Invisible }
        )
    ),
  async execute(interaction: any) {
    const username = // Leave the "??" otherwise code won't work
      interaction.options.getString("username") ??
      interaction.client.user.username;
    const avatar =
      interaction.options.getString("avatar") ??
      interaction.client.user.avatarURL();
    const activity = interaction.options.getString("activity");
    const status = interaction.options.getString("status");
    await interaction.client.user.setUsername(username);

    if (!avatar) {
      await interaction.client.user.setAvatar(avatar);
    }

    await interaction.client.user.setActivity(activity);
    await interaction.client.user.setStatus(status);
  },
};
steel trail

that code never could've changed your avatar. so I definitely doubt that

fierce jolt

Why it worked then?

steel trail

remove the !in your if and it might

also please don't use any, why use typescript at all then? in your case you'd want ChatInputCommandInteraction as type

fierce jolt

If i remove the ! the if won't do anything, I use TypeScript because I always used it and the thing is that my code isn't the problem because it worked, I cloned my repo with all the last modification that worked and it won't work, so its just strange because the code worked and then it stopped working

rose tangle

like Qjuh said, you'd need to share what "not working" means

does it error, does it not change the avatar, does it change when it shouldn't...

fierce jolt

what my code is doing is: when you do nothing it doesnt change the avatar because if you leave the option blank it put the same image but reload it, so if you use the command in a limited time, there is gonna be an error like youre changing the avatar too fast, but if you put an image link, then the image will change

rose tangle

and what is it supposed to do?

also that doesn't sound like what it does, it's always setting the avatar, regardless of whether you did input something

fierce jolt

Like i said change the avatar if you put a link to an image but if you leave it blank then do nothing

fierce jolt
rose tangle

you meant "what my code is supposed to do"?

fierce jolt

I've said what its supposed to do but my code is actually doing nothing

rose tangle

maybe you're ratelimited then?

steel trail

and I told you why. read your code again. it is wrong

rose tangle

also is that command supposed to change the global settings?

given there's now per guild avatar

maybe that's what you wanted instead?

fierce jolt
fierce jolt
steel trail

You only ever call setAvatar with a falsey value. So no, that code CAN'T work. And typescript would even tell you so if you didn't silence it with any. Good luck arguing your errors, I'm out

fierce jolt
rose tangle

it seems weird to me to let other people change the nick or avatar of your bot

fierce jolt
rose tangle

but if that's what you want then you do you ig

fierce jolt
rose tangle

permissions like what?

if you mean discord permissions then I could just invite your bot to my guild where I'm admin

and I can now change your bot's avatar and nick

and status

fierce jolt
rose tangle

and what would a "normal member" be

rose tangle

I want to know whether you coded what you wanted

fierce jolt
fierce jolt
rose tangle

if only a specific member can then yeah that makes sense

well anyways if nothing seems to be working, place some logs and see where it stops

then you can find the root of the issue

sharp ginkgoBOT

If you aren't getting any errors, try to place console.log checkpoints throughout your code to find out where execution stops.

  • Once you do, log relevant values and if-conditions
  • More sophisticated debugging methods are breakpoints and runtime inspections: learn more
fierce jolt
rose tangle

if you don't want it to do anything if they don't set anything then just don't do the ??

otherwise it'll always be something

also you want if (avatar) then, not if (!avatar)

otherwise it reads "if they didn't choose an avatar, set the avatar", the opposite of what you want

lost mason

what is the best way to reset the options previously picked in a selectmenu

tardy sable

if youre working with embeds you can also do suppress embeds to false

rose tangle
sleek mural

How can u edit a container without it showing "edited"?

rose tangle

you can't

sleek mural

I swear I seen @astral prism do that after you click "solved". It makes the "solved" button disabled and it doesnt show edited

proud arrow

It varies between app clients

rose tangle

the button isn't disabled, the thread is just closed

you can't click buttons on a closed thread

proud arrow

But in essence they are edited

normal flare

is deleting messages 1 by 1 faster than channel.bulkDelete(msgIds)?

wary coral
stable sun

Deleting individually is more likely to run into rate limits since it’s multiple requests

tiny condor
normal flare

I remember reading here that we should delete 1by1 instead of channel.bulkdelete, could be wrong

stable sun

The only cases you can’t use bulk delete is when the message is too old or ur in DMs

normal flare
sharp ginkgoBOT
main axle

how can I check a message in messageCreate is came from a DM?

tardy sable
main axle
sharp ginkgoBOT
tardy sable

theres DM and GroupDM

sharp ginkgoBOT
rose tangle
tardy sable

oh okay good to know

median ferry

setChannelSelectMenuComponent doesn't have a setdefault/setvalue?

sharp ginkgoBOT
median ferry

the thing is that the s kinda confuses me

tardy sable
median ferry

oh, so I can select multiple channels?

tardy sable

yup

median ferry

ohh okay thank you

tardy sable
median ferry

okayy. I guess max is 1 by default because I can't select multiple yet. Also, if the default channel doesn't exist it just ignores it or it will throw an error?

loud quartz

you can easily test that out

median ferry

yea I was about to say that, it was kinda a stupid question...

tardy sable
meager meadow

I have a question about what we receive from member.presence The documentation says that only desktop, mobile, and web, but I checked the console log (member.presence.clientStatus) and it showed me that there is also { embedded: "online" }, What is this?

clear garnet

It's generally known that embedded is for those using Discord through gaming consoles such as Xbox or PlayStation. Discord themselves have not documented that value though so thus d.js will not document any support for it either until then

jagged rock

the executor of moving a user from vc it just shows the member that was moved it doesnt seem to show executor

rough flax

Hello I want to know is it possible to use yt dlp to stream music to a voice channel?

rough flax
bleak owl

it’s discord that doesn’t allow it

rough flax

I did not realise that becuase it works on discord py so i assumed I could use it for my private discord js bot

rough flax
bleak owl

it’s not that it won’t work, it’s discord that doesn’t allow you to stream youtube, which breaks the tos.

we won’t help you here with that, sorry

rough flax
rough flax
shadow violet

Hey I have seen in many bots that we can edit the icon and description of that bot in a special guild, so can anyone tell me how is work and How should I put it in my bot

sharp ginkgoBOT
shadow violet
low spear

do buttons have a maximum customid length

dense jackal
shadow violet
stable sun Yes

Hey When I change the bot's nick, an issue arises.
TypeError: Cannot read properties of undefined (reading 'emitWarning')

Also bio or avatar is not being edited using ``guild.members.editme().

stable sun

I’d guess it’s coming from a member.edit(…) or member.setNickname(…) where you are trying to edit the bot’s nickname

Not sure why you don’t have emitWarning of undefined tho

shadow violet
stable sun I’d guess it’s coming from a `member.edit(…)` or `member.setNickname(…)` where y...
if (sub === "bio") {
  const bio = args.slice(1).join(" ");
  if (!bio) return message.reply("⚠️ | Please provide a bio text.");

  await guild.members.me.edit({ bio: bio }).catch(err => {
    return message.reply("❌ | Bio update failed.\n```" + err + "```");
  });

  return message.reply(`✅ | Bio updated!\nNew Bio: **${bio}**`);
}

if (sub === "avatar") {
  let imgURL =
    args[1] ||
    (message.attachments.first()
      ? message.attachments.first().url
      : null);

  if (!imgURL) {
    return message.reply("⚠️ | Provide an image URL or attach an image.");
  }

  try {
    const buffer = await DataResolver.resolveImage(imgURL);

    await guild.members.me.edit({
      avatar: buffer
    });
  } catch (err) {
    return message.reply("❌ | Avatar update failed.\n```" + err + "```");
  }

  return message.reply("✅ | Avatar updated for this guild!");
}

if (sub === "banner") {
  let imgURL =
    args[1] ||
    (message.attachments.first()
      ? message.attachments.first().url
      : null);

  if (!imgURL) {
    return message.reply("⚠️ | Provide image URL or attach image.");
  }

  try {
    const buffer = await DataResolver.resolveImage(imgURL);

    await guild.members.me.edit({
      banner: buffer
    });
  } catch (err) {
    return message.reply("❌ | Banner update failed.\n```" + err + "```");
  }

  return message.reply("✅ | Banner updated for this guild!");
} ```

And error = ❌ | Unable to update nick.
TypeError: Cannot read properties of undefined (reading 'emitWarning')

stable sun

Add console.error(error) in the catches

You should be using guild.members.editMe(…), not .members.me.edit(…)

That should fix your errors. If not, the logs should give a full error w/ stack trace

stable sun

You can pass direct URLs to the banner

stable sun
shadow violet

For the 1st error

You should be using guild.members.editMe(…), not .members.me.edit(…)

You should also convert the bio Promise.catch to a try catch block

You will otherwise be sending a fail and success message when it fails

stable sun
stable sun

That baseballs

It’s just a bun problem then

You should’ve gotten a warning that appeared in console instead of the emitWarning error

rough flax

Hello is it difficult to implement a command into my bot that generates apexcharts.js spline graphs to output to the chat based on user provided datahttps://apexcharts.com

halcyon bison
rough flax
halcyon bison
subtle girder

What is CombinedPropertyError?

stable sun

I can tell you what it means if you provide the full error with stack trace and code

subtle girder

yea I think value: null or value: undefined will get this error

toxic latch

What's the difference between setting rest.url to proxy URL that's running @discordjs/proxy vs setting rest.agent like here?

steel trail

The former expects the url to point at an API that respond to all endpoints like Discord does. The latter uses any proxy server to simply relay the request to the actual discord.com API

untold skiff
tardy sable
untold skiff
tardy sable

or can you see in the console youre receiving the interaction?

untold skiff

No errors no nothing

tardy sable

might be a stupid question then but is your bot even online then?

topaz bluff

Is your bot receiving events at all? Can you add a console.log to the beginning of your interactionCreate event listener to see if it's logging at all?

If it doesn't log, then there's something wrong with your script to load event files

untold skiff
polar karma

What's your code for interactionCreate event

polar karma

on line 7, before the whole try block, add a console.log('interaction received') and see if anything shows up when you use a slash command or button

sharp ginkgoBOT

If you aren't getting any errors, try to place console.log checkpoints throughout your code to find out where execution stops.

  • Once you do, log relevant values and if-conditions
  • More sophisticated debugging methods are breakpoints and runtime inspections: learn more
untold skiff
polar karma

then keep adding in checks at each step of your event's logic - if statements, etc

find out where it's stopping

untold skiff

It doesn't find the command which is the issue

cobalt plover

is it intentional that you pass client to your command functions?

rose tangle

it's probably not loading your commands correctly then, or you don't have a command file for that command name

tardy sable
untold skiff
rose tangle

Thonk but unless you do define client.SlashCmds somewhere, that should've thrown an error

and if you do define them, why have two properties with very similar names but different purposes

ivory plinth

Hello, is /applications/{application.id}/emojis implemented in Discord.js?

Like directly in the client

sharp ginkgoBOT
rose tangle

that's on client.application.emojis ^^

safe wigeon

I'm a bit confused about spliceComponents. If I want to replace a component, should deleteCount be 0 or 1?
E.g. spliceComponents(2, 1, newComponent) or spliceComponents(2, 0, newComponent) to replace the component in index 2?

wary coral
untold skiff
tardy sable
hybrid fable

hey people, I have a button and when the user presses it, I would like to ask for some additional information (a simple string input), would prefer it to be "private"

afaik I could either use

  • a modal to retrieve this
  • use dm's to handle this

is there a way I am missing?
I feel like it would be simply prompting the user a question and getting the answer cat_think

wary coral

A modal would be the best way to get that additional string input

hybrid fable

hmmmm, I would have somehow hoped I could maybe trigger a slash command from the interaction, or send an ephermal embed that has some kind of input?
but I guess neither those things exist omegaflushed

modal seems a bit "aggressive" for the use case is the only reason really, but might be the best choice

tardy sable

i dont think you would want something as triggering a slash commands. modals are the best way for that

hybrid fable

alright thanks guys wellLove

steel trail
hybrid fable
hybrid fable

thanks guys I will give it a try and see if that works PogU

empty hinge

Hello, I have a rather strange problem!
I'm using FileUploadBuilder in a modal to allow users to upload files. But when uploading a large file, instead of just one, I can get multiple identical messages with files and an error after the Nth one.

const message = await channel.send({content: `...`, embeds: [embed], components: [row]});
const proofs = interaction.fields.getUploadedFiles('proofs');
if(proofs && proofs.size>0){
    try {
        const attachmentsToSend = Array.from(proofs.values());
        await message.reply({ 
            content: `Proofs (${attachmentsToSend.length}):`, 
            files: attachmentsToSend
        });
    } catch (error) {
        console.error(error);
        await message.reply({ content: ":x:" });
    }
}
DOMException [AbortError]: This operation was aborted
     at new DOMException (node:internal/per_context/domexception:53:5)
     at AbortController.abort (node:internal/abort_controller:395:18)
     at Timeout.<anonymous> (/root/discord-bot/node_modules/@discordjs/rest/dist/index.js:715:47)
     at listOnTimeout (node:internal/timers:573:17)
     at process.processTimers (node:internal/timers:514:7)

In this case, it sent proofs three times, and then triggered an error.
I hope someone can help me with this, maybe they've encountered this before? Thanks in advance!
discord.js@14.25.1

steel trail

You probably want to use nonce to make sure discord dedupes those messages in case an upload takes that Long that it causes an abort error while still succeeding in sending. Which is probably what happened here

sharp ginkgoBOT
empty hinge
fierce jolt
light ibex

I don't understand why this problem is occurring?

i tried my best to get how it works but it still the same

with old versions of discord.js it works perfectly

unique shoal

Youve enabled an entry point command in the dev portal, but arent providing one when deploying commands

This is a Discord API error and would happen no matter which version of discord.js you use

light ibex

so what should i do now ?

unique shoal

Do you intend for your bot to have a primary entry point to launch an activity?

light ibex

yeah maybe

unique shoal

Then you need to define a Primary Entry Point command

Its not really a "maybe" kinda question though

light ibex

can i show you what i did for the command Event ?

unique shoal

...is it a command or an event?

unique shoal
light ibex yeah maybe

I suspect the correct answer here would have actually been "no", so I'm not sure why you enabled activities

light ibex

so idk why but this is the stupidest problem I've ever seen.

when i changed the c.user.id to c.application.id it worked

hybrid fable

hmm, I have an embed and the embed has a placeholder for a lobby code (some arbitrary string)

I use a button + modal to provide the lobby code some time after the embed was sent

I just realized: how am I getting the lobby code into the embed?

the embed uses "a lot of data" which I don't have at the point where I react to the button / modal

is there a reasonable way to replace a placeholder in an embed, or should I just create a second, simpler embed below and "repost" that one?

tardy sable
unique shoal
hybrid fable

oh that's great, I might just use the footer for the code PogU

tardy sable
light ibex
hybrid fable
unique shoal

is there more than 1 embed?

hybrid fable

cause I dont see any id for embeds, or way to set them

is there more than 1 embed?
no Foxy_Flushed

unique shoal

then [0] is fine, theres nothing else to find it from

hybrid fable

thanks that was my question 🙏

keen monolith

how do I make my bot say "made by yejin.luvs"??

bleak owl

where do you want to do that exactly?

keen monolith

in the activity like these

bleak owl
keen monolith

it says unknown

bleak owl

click it

keen monolith

ah ok ty

I am getting this error

clear garnet

Seems like you're trying to set the presence before the client is actually logged in

You can either:
A) Move that code into an event listener that would emit when the client is ready
B) Use the presence option in the Client constructor instead to specify the presence to have upon login

keen monolith

Alright! I'll give that a go!

uhhh now it's saying client not defined

faint basalt

Hi, anyone else had issues where subtext (-#) in an embed description seems to randomly truncate on some occasions - not always?

It just cuts off so far through the text, and not always at the same position and sometimes not at all. It’s as if the embed is sometimes being sent before it’s fully created (I know this won’t be the issue but just helps to understand what’s happening)

tardy sable
bleak owl
keen monolith

by defining client

bleak owl

right

keen monolith

but just confused on why it's undefined that's all

bleak owl

you said it wasn't defined, not undefined

keen monolith
bleak owl

its not

can you show your code please?

keen monolith
const { ActivityType, Client } = require('discord.js');

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

client.user.setPresence({
    activities: [{
         type: ActivityType.Custom,
         name: "made by yejin.luvs",
         state: "💕"
    }]
})```
bleak owl

i thought you said the error says "client is not defined" ?

just put the presence inside the client constructor

keen monolith

I did

bleak owl

either you didn't save your code, or something else is wrong

keen monolith

But i fixed it after you told me to define it 😭

sorry I'm new to discord.js so i am confused

keen monolith

like this?


const { ActivityType, Client } = require('discord.js');

const client = new Client({ intents: [
    GatewayIntentBits.Guilds, 
    GatewayIntentBits.GuildMembers,
    GatewayIntentBits.MessageContent,
    GatewayIntentBits.GuildMessages,
setPresence({
    activities: [{
         type: ActivityType.Custom,
         name: "made by yejin.luvs",
         state: ":two_hearts:"
    }]
] });```
sharp ginkgoBOT
keen monolith

huh? Sorry that confused me more

topaz bluff

ClientOptions is the things you put in the new Client() constructor. presence is just a new value you can add, and the docs show you what is allowed there

bleak owl

replace setPresence with presence: {...}

keen monolith

Tyyyy

wary coral
keen monolith

okie

const client = new Client({ intents: [
    GatewayIntentBits.Guilds, 
    GatewayIntentBits.GuildMembers,
    GatewayIntentBits.MessageContent,
    GatewayIntentBits.GuildMessages,
    presence: {    
    activities: [{
         type: ActivityType.Custom,
         name: "made by yejin.luvs",
         state: ":two_hearts:"}
] });```
bleak owl

you set the presence inside the intents array

move it outside the array

keen monolith

ohhhhhhh I am so stupid

so it would be

const client = new Client({ intents: [
    GatewayIntentBits.Guilds, 
    GatewayIntentBits.GuildMembers,
    GatewayIntentBits.MessageContent,
    GatewayIntentBits.GuildMessages,
]
    presence: {    
    activities: [{
         type: ActivityType.Custom,
         name: "made by yejin.luvs",
         state: ":two_hearts:"}]}
});```
bleak owl

try it

keen monolith
bleak owl

you forgot a comma after the array

this is really basic js stuff

keen monolith

sorry I am really new to coding 😭

thanks so much tho 😭

wary coral

Are you using Integrated Development Environment(IDE) like VSCode?

keen monolith

Yes normally I do, but I am coding inside of my hosting service rn as I am on my friend's pc and they don't have it

hybrid fable

hmm, do mentions not work in embed footers?

    const fixedEmbed = EmbedBuilder.from(embed).setFooter({
      text: `✅ ${lobbyCode} - setup by <@${interaction.user.id}>`
    });
bleak owl

they do not

hybrid fable

bummer rooBlank
ty

wary coral
sharp ginkgoBOT

guide Display Components
While you might be familiar with embeds in Discord, there are more ways to style and format your apps messages using display components, a comprehensive set of layout and content elements. To use the display components, you need to pass the IsComponentsV2 message flag (in docs: MessageFlags) when sending a message. You only need to use this flag when sending a message using the display components system, not when deferring interaction responses.

hybrid fable
wary coral

Yes mentions work in Text Display components.
You can also use subtext(-#) markdown in the Text Display to get a footer like text

hybrid fable

is there a way to only have 2 inline fields next to each other?
I was looking through the display component doc expecting to find a solution there, but didn't 👀

I need to display 5 elements and showing 2 next to each other would like nice, while 3 looks awful

wary coral

Inline field do not exist in components V2

hybrid fable

hmm and embeds probably can only do 3 in a row?

wary coral

correct also they are not displayed in line on mobile at all

hybrid fable

thanks for the help 👍

hybrid fable
tiny condor

What is this error due to;

DiscordAPIError[50035]: Invalid Form Body
components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).

https://pastebin.com/uTbbVTtX

wary coral
tiny condor
wary coral

your missing the cv2 flag

warm charm
sharp ginkgoBOT
tiny condor

Thanks :)

wary coral

that did not send like I wanted but IDK it is MessageFlags#IsComponentsV2

tiny condor

One more thing, does pinging a role inside of a component ping the members and if so how do you disable it again? crySparkle

sharp ginkgoBOT
tiny condor

Thanks again

Why can't I use the send method on a channel I fetched?

warm charm
tiny condor

I did

clear garnet

Ideally don't do that - use the proper typeguards

sharp ginkgoBOT
warm charm

am using it lol

tiny condor

Well no I just used isTextBased, however there is no send method on the channel apparently

const rewardChannel = await client.channels.fetch(config.rewardChannelID);

if (rewardChannel && rewardChannel?.isTextBased()) {
      await rewardChannel.send();
    }

clear garnet
warm charm am using it lol

Yea, and that'll break as soon as you get a channel that's not actually a TextChannel - you're effectively lying to TS

tiny condor

It just says .send doesn't exist

clear garnet
tiny condor

ohh <3

warm charm

oh ok

its good rn?

nvm i fixed ts

tiny condor
tardy sable
tiny condor

so I need to specifically set it to empty for it not to reply

tardy sable
tiny condor

thanks guys

warm charm

why we didnt think about ts

tiny condor

WAIT, can a bot wear a guild tag? 😭

bleak owl

no

tiny condor

awe

warm charm
wary coral
tiny condor

What was the format to mention a command again?

clear garnet
tardy sable
wary coral

I don not know it can return null tho

clear garnet

It'll throw an error of CommandInteractionOptionInvalidChannelType

warm charm

im lazy to read the whole docs lol

spiral dagger

Is MessageManager#fetch() able to get more than 100 at once or not?

spiral dagger

Alright, ty

drifting pecan

I can't figure out why I'm getting can't send empty message error - I'm sending a component and I've sent component only before. Log also shows that I have a component when using console.log

        const selectedGuide = interaction.options.getInteger('search');
        const componentOutput = getComponentsV2Output(guides[selectedGuide]);
        console.log(componentOutput);
        await interaction.reply({
            conponents: [componentOutput]
            , flags: [MessageFlags.IsComponentsV2]
        });
    },```
```function getComponentsV2Output(data) {
    const container = new ContainerBuilder().setAccentColor(3890348);
    const guideText = new TextDisplayBuilder().setContent(data.output);
    const guideButton = new ButtonBuilder().setLabel(data.name);
    guideButton.setStyle(ButtonStyle.Link);
    guideButton.setURL(data.output);
    const guideSection = new SectionBuilder().addTextDisplayComponents(guideText).setButtonAccessory(guideButton);
    container.addSectionComponents(guideSection);
    container.addSeparatorComponents(separator => separator.setSpacing(SeparatorSpacingSize.Large));
    const feedback = new TextDisplayBuilder().setContent(`-# If you have any questions, feel free to ask in https://discord.com/channels/332595657363685377/400499160094212097\n-# If you have any suggestions, feel free to leave one in https://discord.com/channels/332595657363685377/1060257606217773057`);
    container.addTextDisplayComponents(feedback);
    return container;
}```
drifting pecan
polar sun

Is it possible to fetch a user's bio? Turns out they aren't exposed in the API to a bot

stable sun

That is correct

warm charm

make ur bot request https://discord.com/api/v9/users/<ID>/profile with GET method (need user token, not BOT token)

and discord will return ts

{'user': {'id': '1412061438088056884', 'username': 'ui3gyyruiwhebr', 'global_name': 'strange', 'avatar': 'cf4aa61698971c1f92a81845aaa32a9c', 'avatar_decoration_data': {'asset': 'a_74b145b3ce94b0a728ee24d1724848b1', 'sku_id': '1441168457424048150', 'expires_at': None}, 'collectibles': None, 'discriminator': '0', 'display_name_styles': {'font_id': 10, 'effect_id': 2, 'colors': [16095292, 15031015]}, 'public_flags': 0, 'primary_guild': None, 'clan': None, 'flags': 0, 'banner': None, 'banner_color': None, 'accent_color': None, 'bio': 'nothing here.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\ngo away'}, 'connected_accounts': [{'type': 'domain', 'id': 'nstore.lol', 'name': 'nstore.lol', 'verified': True}], 'premium_type': 2, 'premium_since': '2025-11-10T22:50:21.886422+00:00', 'premium_guild_since': '2025-11-10T22:52:26.570000+00:00', 'profile_themes_experiment_bucket': 4, 'user_profile': {'bio': 'nothing here.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\ngo away', 'accent_color': None, 'pronouns': '', 'profile_effect': None, 'banner': None, 'theme_colors': None, 'popout_animation_particle_type': None, 'emoji': None}, 'badges': [{'id': 'premium', 'description': 'Subscriber since Nov 10, 2025', 'icon': '2ba85e8026a8614b640c2837bcdfe21b', 'link': 'https://discord.com/settings/premium'}, {'id': 'guild_booster_lvl1', 'description': 'Server boosting since Nov 10, 2025', 'icon': '51040c70d4f20a921ad6674ff86fc95c', 'link': 'https://discord.com/settings/premium'}, {'id': 'quest_completed', 'description': 'Completed a Quest', 'icon': '7d9ae358c8c5e118768335dbe68b4fb8', 'link': 'https://discord.com/discovery/quests'}], 'guild_badges': [], 'widgets': [], 'mutual_guilds': [{'id': '1341051489233403944', 'nick': None}, {'id': '684293554918391815', 'nick': 'YunaSoCool'}, {'id': '1432362610052829297', 'nick': None}, {'id': '806501704702754846', 'nick': None}], 'legacy_username': None} 

and you can get the user bio rn

polar sun
warm charm
clear garnet

This is also against Discord's developer ToS which does not allow any sort of automation of user accounts their tokens

warm charm
keen monolith

This is my code and this is what I get

if (customId === 'other'){
                type = 'other';
                openingMessage = 'Thank you for opening a ticket! Please state the reason for you opening this ticket.';

                const channel = await interaction.guild.channels.create({
                    name: `${type}-${interaction.user.username}`,
                    type: ChannelType.GuildText,
                    parent: '1440591960116166767',
                    permissionOverwrites: [
                        { id: interaction.guild.id, deny: ['ViewChannel'] },
                        { id: interaction.user.id, allow: ['ViewChannel', 'SendMessages', 'ReadMessageHistory'] },
                        { id: '1442258475408294061', allow: ['ViewChannel', 'SendMessages', 'ReadMessageHistory'] },
                    ],
                });

                
                await interaction.reply({
                    content: `Your **${type}** ticket has been created: ${channel}`,
                    ephemeral: true
                });
                
                await channel.send({
                    content: '<@${interaction.user.id}>\n${openingMessage}',
                    components: [closeButton],
            });

                return;
            }```
stable sun
stable sun
keen monolith

oooh mb

keen monolith
keen monolith

umm sorry I just got this massive error

stable sun

You provided an invalid value for setDefaultMemberPermissions

Don’t wrap the Permission/BigInt in an array

keen monolith

ohhh damn okay tysm!!!

stable sun

Use the pipe (binary or operator) if you want to combine multiple

keen monolith

alrighty!!!

also my deploy-commands.js won't deploy this command for some reason

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

module.export = {
    data: new SlashCommandBuilder()
    .setName('mail')
    .setDescription('send mail to the mail channel')
    .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
    .addStringOption((option) => option.setName('content').setDescription('what do you want to send as mail?').setRequired(true))
    .addUserOption((option)=> option.setName('staff').setDescription('who is sending the mail?').setRequired(true)),

    async execute(interaction) {
        const client = interaction.client;
        const channel = client.channels.cache.get('1445290740640120902');
        const content = interaction.options.getString;
        const staff = interaction.options.getUser;

        await interaction.reply({
            content: `message sent!`,
            ephemeral: true,
        })

        await channel.send({
            content: `
            # :1000049622: NEW MAIL

            ${content}

            Thank you,
            ${user}

            [<@&1441432047934509186>]
            `
        })

    }
}```
keen monolith

no it just keeps reloading my other 2 and not including this new one

oh wait nvm there is

stable sun

You misspelled exports

module.exports = …

keen monolith

ohh my god, i feel stupid. I am so tired... tysm again 💕

ummm help 😭 I didn't wanna come back but whatttt

waittttt is it cus i am missing js interaction.reply()

short granite

u use or u want bot reply u use interaction.reply not use send in channl
``` content: "t"

keen monolith

oh okk

keen monolith
short granite
keen monolith
short granite

exaple:

        .addChannelOption((option) =>
            option
                .setName("channel")
                .setDescription("The channel to use for broadcasts")
                .setRequired(true)
        )
      .addUserOption((users) => users
            .setName('staff')
            .setDescription('who is sending')
            .setRequired(true)
        ),

execute(...) {
            const chatInputInteraction = interaction as import("discord.js").ChatInputCommandInteraction;
            const channel = chatInputInteraction.options.getChannel("channel") as TextChannel
            const staff = chatInputInteraction.options.getUser('staff')
            
}
short granite

remove as ......

keen monolith

it still didn't work 💀 dogeHaHa OMEGAlul alotOfPings

clear garnet

What is it doing vs what you actually want it to do? What's your current code?

keen monolith
const { 
    SlashCommandBuilder,
    PermissionFlagsBits,
    ChatInputCommandInteraction,
 } = require('discord.js')

module.exports = {
    data: new SlashCommandBuilder()
    .setName('mail')
    .setDescription('send mail to the mail channel')
    .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
    .addStringOption((option) => option.setName('content').setDescription('what do you want to send as mail?').setRequired(true))
    .addUserOption((option) => option.setName('staff').setDescription('who is sending the mail?').setRequired(true))
            .addChannelOption((option) =>
            option
                .setName("channel")
                .setDescription("where is the mail going?")
                .setRequired(true)
),
            

    async execute(interaction) {
        const client = interaction.client;
        const content = interaction.options.getString;
        const staff = interaction.options.getUser;
        const chatInputInteraction = interaction;
        const channel = chatInputInteraction.options.getChannel("channel")

        await interaction.reply({
            content: `message sent!`,
            ephemeral: true,
        })

        await channel.send({
            content: `
            # :1000049622: NEW MAIL

            ${content}

            Thank you,
            ${staff}

            [<@&1441432047934509186>]
            `
        })

    }
}```

my current code and what it's doing

I just want it to send a message to the mail channel and reply with the options

clear garnet

You aren't calling the methods

You're doing it for getChannel, so I don't know why you wouldn't also do it for getUser and getString

keen monolith

oh cus @short granite helped me

short granite
keen monolith

yh I got it tysm

sorry for the trouble 😭

flint pier

How can I track user voice time every minute?

warm charm
flint pier
fallow finch

Discord doesn't send when they joined a voice channel if they left that channel so you'll need to track it on your own logic

sharp ginkgoBOT
gaunt inlet

Is creating a Guest Invite to a voice channel not allowed for bots to do at all?

(status 400 Bad Request): {"message": "Invalid Form Body", "code": 50035, "errors": {"flags": {"_errors": [{"code": "GUILD_INVITE_CANNOT_CREATE_GUEST_INVITE", "message": "Cannot create a guest invite for this server"}]}}}
flint pier

I use interval and see which user is on voice then add to map like that but it is not optimized

fallow finch

You can use voiceStateUpdate to hold when they joined a channel and when they leave you use that data to calculate how long they were in that channel

crimson gale
gaunt inlet

very sad, redundant limitation

crimson gale

oh, that's not temporary, right
guest immediately removes them when they leave the VC?

gaunt inlet

Yesss, that's the one

crimson gale

what's the precondition for that to be available anyways? don't think that ever rolled out widely

gaunt inlet

It also prevents them from reading any @ everyone channels, which is very enticing and a very cool feature overall

The idea is to give members a guest invite bot so I don't have to give them full invite permissions

crimson gale

what's that looking like in the ui?

Filter: Server does not have a vanity URL and Server member count is in range 1 - 200
i see

gaunt inlet

Invite as Guest. It only shows up when you invite someone directly to a voice channel

crimson gale

wait, but my test server should have that firHmm

gaunt inlet

My plans foiled by the API once more firThump

crimson gale

ah, now i can repro, yeah, indeed, seems to be disabled for bots

what a shitty error

love how you cannot tell in the UI either...

gaunt inlet

Tried something to no avail, seems to literally only work on the Discord client itself. TRASH

Oh well, trashing that idea :3

crimson gale

or how it generates an invite when you just open the menu and then generates another one if you click on edit invite
i would've thought this has become less jank over the past.. what... 3* years since i looked into invites in depth

nkoYikes

gaunt inlet

Yeah you always end up with double invites, dumb. Anyway thanks for the talk have a nice day <3

empty hinge
tardy sable
cobalt solstice

djs v15?

steel trail
steel trail
cobalt solstice
warm charm

wow we have djs v15 before gta6

bleak owl

please keep unnecessary comments to yourself

empty hinge
steel trail You also need enforceNonce: true

Now nothing has been sent at all...
The problem only occurs with large files.

const nonce = Date.now().toString();
try {
    const attachmentsToSend = Array.from(proofs.values());
    await message.reply({ 
        content: `Proofs (${attachmentsToSend.length}):`, 
        files: attachmentsToSend,
        nonce: nonce,
        enforceNonce: true
    });
} catch (error) {
    console.error(error);
    await message.reply({ 
        content: ":x:"
    });
}
[AbortError]: This operation was aborted
     at new DOMException (node:internal/per_context/domexception:53:5)
     at AbortController.abort (node:internal/abort_controller:395:18)
     at Timeout.<anonymous> (/root/discord-bot/node_modules/@discordjs/rest/dist/index.js:715:47)
     at listOnTimeout (node:internal/timers:573:17)
     at process.processTimers (node:internal/timers:514:7)
stable sun
empty hinge
stable sun

Does the guild have lvl 2 boost?

empty hinge
stable sun

You could increase the timeout in ClientOptions.rest.timeout

Default is 15000 ms (15 seconds)

new Client({…, rest: { timeout: … } })

empty hinge
tardy sable

?

pulsar spindle

Is there a way to track user's primary guild changes? Like a event or something like that

pulsar spindle
bleak owl

<@&839912195994812420>

polar bridge

Working with the messageUpdate event and I see it often doesn't emit on old messages. I found that it will only emit for messages that were sent AFTER the bot started.

I'm guessing this is something with caching and the partials but is there any way I can get around this restriction?
I know discord doesn't send message data unless explicitly fetched unfortunately so I think my options are really slim, but that would be a massive turn off if you restart the log bot and then you miss a bunch of edit events, even some potentially important ones for moderation

To clarify, I don't care if oldMessage is not in cache, I just want to know IF a message was updated

rose tangle

partials are how you get around the restriction

polar bridge

Ah, thought those were only used for missing data, like messages in DMs lol

rose tangle

well you have missing data, the old one

polar bridge

That's fair lol

urban nimbus

Odd question but what event triggers first on a user ban in a guild, guildBanAdd or guildMemberRemove?

unique shoal

Generally speaking there isn't a "first"

Event sequencing isn't a guaranteed thing

urban nimbus
unique shoal

Everything has rate limits, yes

But the GuildBanManager does have a cache, so you should only need to fetch once

tiny condor
unique shoal

Do you have User partials enabled? discord.js wont always know the previous state of a user's tag (and wouldnt know in a partial either, but at least it would emit)

tiny condor

I do have it indeed

Should I change something about how I check it?

unique shoal

The only reliable, complete user object you have is the new one

So if they change it you should know what its set to, but not what it was before

tiny condor

I do have it saved as a value on my database so I could just check if they have it claimed already ig

Okay thanks didn't actually know that

unique shoal

You'd only know what it was pre-update if the user was previously cached

So you need to consider that in your checks

tiny condor

I'll just check the new user and compare it to my data

dry flame

I've made my app user installable, and I've set a command to be used within a DM, as such:

builder.setContexts(InteractionContextType.Guild, InteractionContextType.PrivateChannel, InteractionContextType.BotDM)

However after installing the app at the user level, I can't see any commands when interacting with it via DM

Oh nevermind, it's because the command is not global, but rather scoped to a specific guild

dry flame

Do I need anything else other than setting the GatewayIntentBits.GuildMembers intent and enabling it in the developer portal in order to receive guildMemberUpdate events?

rose tangle

the Guilds intent

and I think that's about it

also partial if you didn't have the member cached beforehand

vast nymph
steel trail
vestal sun

i have a question about userselects in interactions in a guild are those getting fetched automatically or could they be just partially there ?

loud quartz

Discord sends resolved data along the interaction like that

tiny condor
jagged rock

[EVENT] guildMemberAdd error: SocketError: other side closed
at TLSSocket.<anonymous> (/home/container/node_modules/undici/lib/dispatcher/client-h1.js:701:24)
at TLSSocket.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'UND_ERR_SOCKET',
socket: {
localAddress: 'IP',
localPort: 46922,
remoteAddress: undefined,
remotePort: undefined,
remoteFamily: undefined,
timeout: undefined,
bytesWritten: 56546,
bytesRead: 19794470
}

djs module errors

http client error for discordjs

loud quartz

Nothing caused by discord.js

tiny condor

ye

flint pier

Which sharding is good for discord jsv14v?

polar karma

Internal sharding is good to start out with because you don't really have to change your code, but traditional sharding is recommended when your bot gets to 10k guilds because of the resources needed

unique geyser

Does someone know how to make the bot "on mobile"? I know it never was documented, but does someone know how?

unique geyser

no it's not that

dense jackal

you need to find out yourself or ask elsewhere

unique geyser

i mean the mobile status

wary coral
wary coral

It is incorrect uses of the API

Therefore it is left it undocumented and unsupported by discordjs

unique geyser
wary coral

That is not relevant. To where djs supports it.

jagged rock
sharp ginkgoBOT

Errors such as ECONNRESET, ConnectTimeoutError, SocketError: other side closed indicate a network issue

  • Free or shared hosting providers often come with significant limitations
  • Another indication of these issues are 'Unknown Interaction' errors.
cunning ember

Is there an alternative to learning to DJs?

steel trail

The alternative to learning would be not learning but then you won't know how to use djs

cunning ember

sorry, thanks for the response

vernal schooner

Hello guys, i want to ask how can i get member about me

topaz bluff

That information is not available to the bot api

vernal schooner
bleak owl

it’s not available in the api at all

vernal schooner
loud quartz

Not discord.js

mellow frigate

how to view the tag of user

like mine is GOAT

sharp ginkgoBOT
pulsar spindle

How can I track post creations in a **forum ** channels? Is it the thread create event or channel create or none

sharp ginkgoBOT
tardy sable
clear garnet

forum channels are not threads, they're channels that hold threads

pulsar spindle

So all the posts in a forum channel are treated as threads? Thanks

clear garnet

Yes

delicate needle

It is possible to use ChannelSelectMenuBuilder in a specific guild ?

tardy sable
topaz bluff

an alternative is using a StringSelectMenu to allow the option to choose channels (as a string) from a specific guild

delicate needle
loud quartz

you cannot provide channels to the channel select

topaz bluff

you could always just use the ChannelSelectMenu in the server in question rather than in another server / DM

loud quartz

it's auto populated

with channels from the current context - the guild it's used in

at best you can specify the channel types

delicate needle

Yeah, it was to be sure

toxic latch

I'm getting an error when using interaction.awaitModalSubmit:

TypeError: undefined is not an object (evaluating 'next.components.forEach')

Code:

    const modal = buildFilterModal(type, currentFilters);
    await interaction.showModal(modal);

    const modalSubmit = await interaction
      .awaitModalSubmit({
        filter: i => i.customId === `filter_add_${type}`,
        time: 900_000, // 15 minutes
      })

Am I doing something wrong? Modal shows correctly, but it breaks when I try to click "Submit"

rose tangle

what does your modal look like and what djs version are you on

npm ls discord.js

rose tangle

the new modal components were supported on 14.23.0

update to latest

I assume you're using them

toxic latch
rose tangle

also in case buildFilterModal uses @discordjs/builders (since you can't import them from djs, labels don't exist on your version), you should import from discord.js instead

sharp ginkgoBOT

discord.js includes multiple sub-packages, installing these separately can mess with internal code:

npm uninstall discord-api-types @discordjs/rest @discordjs/builders
yarn remove discord-api-types @discordjs/rest @discordjs/builders
pnpm remove discord-api-types @discordjs/rest @discordjs/builders
toxic latch

@rose tangle updating the package fixed the problem, thank you! Now I get different errors, but they actually make sense so time to fix my code 😄

fleet chasm

would anyone know why my context menu command works in all channels but one for my server? i have ensured that its allowed under the integration permissions for that channel, but when my users go to use it, it just says "no commands available"

steel trail

Did you deny the "use application commands" permission on that channel?

fleet chasm

^ that worked! not sure why it matters for only that channel,,,

steel trail

Probably because you either allow it on those others directly or at category level or because you deny it for that channel or category for some role they have (could also be everyone role)

devout depot

Hi waveBoye I have a interaction.reply like this

const replyMessage = await interaction.reply({ content: GreetingHelper.generalChannelGreeting(interaction.channel as TextChannel, interaction.user, interaction.targetMessage), embeds: embeds, files: files ?? [], components: [row], withResponse: true, });

I'd really like to add a space between the content and the embed. I've tried adding a new line (\n\n) to the string returned from generalChannelGreeting, and also tried adding the newline directly to the end of the content: property using string interpolation with no joy.

keen monolith

is it possible to ping a role every 6hrs (example a revive ping)??

velvet cipher
keen monolith

Not sure just wanted to double check

unique shoal

Sounds annoying as fuck but its possible

keen monolith

How would I do this? Also how come would it be annoying?

velvet cipher

Just start an interval that sends a message to ping the role

velvet cipher
unique shoal

I'm not sure I can explain why being pinged every 6 hours would be annoying if that isnt already completely obvious to you

4 pings a day, I'm going to be sleeping for at least one, working during at least one

keen monolith

Oh it's a revive role that you can get... it's optional and tbh yh maybe 6hrs is bad. 12hrs could be better or every 24hrs

velvet cipher

Keep in mind that notification fatigue is a real thing. If you get pinged consistently you're eventually going to stop caring about said ping. It's an issue with most "reminder"-type things in software.

keen monolith

ah okay. This was a valuable lesson. thanks! Maybe I won't use it then :3

unique shoal

I'm not sure I understand the "revive role" concept, is it a way to like, force people to talk?

if its opt in then I guess its their own doing and its fine?

velvet cipher

I'm guessing it's like, pinging people in a chat to "revive" it if it's been dead for a while. But me personally I would not start chatting somewhere just because a bot pings me

keen monolith

Yh a revive role is where you have it, you get reminded to revive the chat

Sometimes it works great

velvet cipher

in that case it might be better to just set a wait period in the chat itself, like if no message has been sent for x amount of hours, then send the ping. Otherwise the bot might ping people when it's not needed.

unique shoal

Interesting, I feel like it would just encourage low quality chat rather than there being something interesting that I want to engage in

keen monolith

Anyway while I'm here. Would it be possible to create a command to delete a channel and send a transcript to the person who opened it without options

unique shoal

Should be, yeah

velvet cipher

Most things are possible, it's just about implementing them in a way that makes sense within the borders of Discord

and abiding by rate limits and such

keen monolith

Okay! I am guessing it would include variables?

velvet cipher

I mean... every program does?

keen monolith

Well yeah sorry I meant custom

velvet cipher

Depends. If it's just for your own server you can hardcode values. If it's per-server you'd need some kind of database to store server settings that can be changed.

keen monolith

Alright! If it's just for my own server. How would I do it. This is how it works so far:

  • when a button is pressed a channel is created (ticket system)
  • includes a close button
  • includes a close slash command which sends a dm with transcript (only the person who opened can use)

However I want to make a close command that staff can use to close the ticket with a reason --> then sends the transcript and reason for closing the ticket to the person who opened it

velvet cipher

I mean you basically described the implementation yourself. A command that takes a reason as an argument, extracts a transcript and then sends said transcript along with the reason to the person. Keep in mind that if the person has disabled DMs from the server your bot won't be able to DM them either.

keen monolith

Yh that's not a problem. I just don't know how to send it to the person w/o using the user option

velvet cipher

You'll need some way for the bot to remember who created the ticket then. Either store the ID/User object in a map with the channel ID, or if you want persistence, use a database.

keen monolith

database?

velvet cipher

Some way to store data outside of your bot's code/memory. Like MongoDB or PostgreSQL.

Otherwise the data will be lost when your bot restarts. But I'm assuming you're a beginner, so a database might be a foreign concept and hard to grasp initially.

Basically if you want to save data persistently in any program, a database is the way to go. Technically you could just use files to read and write to, but that's a very unstable way of doing it. Databases handle a lot of things for you like concurrency, data validation and corruption prevention.

keen monolith
keen monolith
velvet cipher

Yes, so on a very basic level it'd be something like

// when the user creates a ticket
storeCreator(channelId, userId);
// Maps channel ID and user ID somehow

// ...
// when an admin closes the ticket
const creator = getCreator(channelId);
// send a DM to the creator...
keen monolith

ahhh tyyyysm!! So all I would need to is setup a database?

velvet cipher

You can give it a shot. I'd recommend either MongoDB or SQLite since those are fairly easy to wrap your head around. SQLite maybe even more since it's just a file and doesn't require another service to run alongside your bot.

But it takes time to learn and understand, it's not something you'll totally get right away or within a week

keen monolith

oh okayyy my hosting service I have also has this?

velvet cipher

No idea what that is, but maybe

keen monolith
velvet cipher

Up to you

keen monolith
keen monolith
velvet cipher

I mean it doesn't matter where you put anything in your code, it's just about structure and intent

keen monolith

alr

tysm again --> you've been a big help 💕

sorry me again..

would this be correct?

const creator = getCreator(channelId);

await channel.delete(creator);```
rose tangle

there's no channel.delete

and what is "creator"

what are you trying to do exactly?

keen monolith
keen monolith

i thought channel.delete cus of interaction.channel.delete

rose tangle

or well, there is but it doesn't take a "creator"

it deletes the channel

on that message you quoted there's a lot of things, I'm not sure which part you're doing

keen monolith

trying to use database to grab userID who created the ticket so staff can close ticket and still send transcript to them

rose tangle

what exactly are you trying to achieve with that code, so I can suggest whether it looks right

keen monolith

delete the channel created and send transcript to who opened the ticket

lemme grab my whole command so far

rose tangle

djs doesn't do transcripts

you'll need some other package for that

keen monolith

no I added smth

onst { SlashCommandBuilder, AttachmentBuilder } = require('discord.js');
const creator = getCreator(channelId);

module.exports = {
    data: new SlashCommandBuilder()
        .setName('close')
        .setDescription('close current ticket')
        .addStringOption((option) => option.setName('reason').setDescription('What is the reason of closing?')),

    async execute(interaction) {
        const logChannel = interaction.client.channels.cache.get('1442221654343417918');
        const user = interaction.user;

        const messages = await interaction.channel.messages.fetch({ limit: 100 });

        const transcriptText = messages
            .reverse()
            .map(m => `[${m.createdAt.toLocaleString()}] ${m.author.tag}: ${m.content ?? '[No content]'}`)
            .join("\n");

        const attachment = new AttachmentBuilder(Buffer.from(transcriptText), {
            name: `transcript-${interaction.channel.name}.txt`
        });

        await logChannel.send({
            content: "New Transcript:",
            files: [attachment]
        });

        await user.send({
            content: "Here is your ticket transcript - from chonsa~",
            files: [attachment]
        }).catch(() => {
            console.log("User has DMs closed.");
        });

        await channel.delete(creator);

        
    }
};
rose tangle

is that copied incorrectly or why is the const creator at the top

keen monolith

nope I put there

I am used to putting const at tops 😭

bleak owl

that doesn’t make sense because channelId isn’t defined in that scope

neither is getCreator

rose tangle

plus you'd only want to get the creator when the command is executed, not when that .js file loads

keen monolith
keen monolith
bleak owl

you have to import that. it doesn’t define itself

keen monolith

oh oki

how would I do that 😭

rose tangle

I'd recommend defining it in another file and then make both depend on that

keen monolith

I know how to do it when it's not in a folder bu this file is

rose tangle
rose tangle

you add a ../

keen monolith
rose tangle

I'm not sure whether you wrote that code yourself since you seem to be lacking js/node fundamentals, we don't advise writing bots without knowing that or you'll have a hard time

keen monolith

I wrote some of it myself. Some was with help of a tutorial

rose tangle

if you know js/node and a bit of djs you should be able to write that command without the need of one

velvet cipher

Having a good grasp of js and node basics is really essential before writing a bot, otherwise you're just going to guess your way to a half-working solution and you won't understand most answers given to you here.

keen monolith

Alrighty!

keen monolith
cunning ember

What databases are good for Discord.js?

bleak owl

any

stable sun
safe karma

I use sqlite for dev and MySQL for prod, so yeah, anything is good

cunning ember

okay, thanks

velvet cipher
solid snow

hi is there a link to a repo with the template from the guide including the handler and everything?

bleak owl

it’s on github

but you can easily follow the guide on event and command handling

solid snow

not even

bleak owl

it’s been archived

it’s best to follow the guide since that is the most updated

solid snow

i see, thank you

bleak owl

i don’t know why it’s been archived to be honest, but i guess i’ll find out at some point

solid snow

yeah only archived very recently

got a general idea when v15 might get a stable release?

could be related if that's expected soon

wispy nimbus

what's the messages.fetch count limit, 100?

topaz bluff
topaz bluff
sharp ginkgoBOT

discord Messages Resource - Get Channel Messages GET channels/{channel.id}/messages
Retrieves the messages in a channel. Returns an array of message objects from newest to oldest on success. If operating on a guild channel, this endpoint requires the current user to have the VIEW_CHANNEL permission. If the channel is a voice channel, they must also have the CONNECT permission. If the current user is missing the READ_MESSAGE_HISTORY permission in the channel, then no messages will be returned.

wispy nimbus

splendid thank you x

topaz bluff

bongocatheart

keen monolith

nvm

rose tangle

you defined that inline function but you're not calling it

and that isn't related to djs

keen monolith

oops really mb

topaz bluff

typically speaking...if something is not logging at all, then it's a JS issue, not a DJS issue

DJS does not silently error in any way...you will always get some kind of error message if something goes wrong

low spear

what if my djs is shy

viscid shuttle

Buy it dinner

topaz birch

I'm new to this if Ive created script for a bot how exactly to I get it onto my discord server?

sharp ginkgoBOT

guide suggestion for @topaz birch:
guide Adding Your App
After you set up a bot application, you'll notice that it's not in any servers yet. So how does that work? Before you're able to see your bot in your own (or other) servers, you'll need to add it by creating and using a unique invite link using your bot application's client id.

topaz birch

I don't know how to find that or get a bot token

topaz bluff

Then go back one page on the guide

topaz birch

I'm trying to figure it out lol first timer.

normal flare

context menu commands don't take options like slash commands do right?
you have to build action rows in the reply of context menu commands
so if I already have logic for a slash command (handling the options part), I would need to re-make that for the context menu command

stable sun
normal flare
stable sun

Yea

fluid cedar

how to create embed like this?

sharp ginkgoBOT

guide Display Components
While you might be familiar with embeds in Discord, there are more ways to style and format your apps messages using display components, a comprehensive set of layout and content elements. To use the display components, you need to pass the IsComponentsV2 message flag (in docs: MessageFlags) when sending a message. You only need to use this flag when sending a message using the display components system, not when deferring interaction responses.

crimson gale

a container with no accent color
text component (heading, code block markdown)
separator
section with text + disabled button (secondary style)
media gallery with 1 image
separator
text component (subtext markdown)
separator
actionrow with link button

bleak seal
 const sound = await guild.soundboardSounds.fetch(targetId!).catch(() => null);
   console.log(sound);
            
if (sound) {
 await sound.delete(
      `Shield - Unauthorized SoundBoard Sound Creation by ${executorId}`
    ).catch((err) => { });
};

doesnt work

tardy sable
wary coral
bleak seal
tardy sable
bleak seal
if (sound) {
                try {
                    await sound.delete(`Shield - Unauthorized SoundBoard Sound Creation by ${executorId}`);
                    console.log('Worked');
                } catch (err) {
                    console.log(err);

                };
            };

response:

Collection(6) [Map] {
'1429181132556996760' => SoundboardSound {
soundId: '1429181132556996760',
available: true,
name: 'bombo'.......

Worked

I think the fetch function is broken :/

Because 6 data are coming, all the sound panels on the server are rotating, there is a type error as far as I understand

polar karma

your sound is a collection, not an individual SoundboardSound

collection does have a delete method, but it's not async, thus your error

bleak seal

solved, the targetId was coming as null in the audit log, which was ridiculous. I got the id from the changes section.

steel trail

Don't assert something as non-null if you don't 100% know it isn't. Else it leads to things like these

bleak seal
steel trail

Your code tells me nothing about how targetId is defined, so can't really answer that

bleak seal

blobreach

tardy sable

how would i check if a user has no avatar because displayAvatarURL will always show url. do i use user.avatar instead?

crimson gale

yes

tardy sable

thanks

rigid crest

its probs been asked but will the display name style be accessible? or will it come with V15?

clear garnet

As of right now, the intention of v14 is to support all API features when able

unique shoal

We will provide it if/when Discord documents it in the API

eternal drift

How many nested sub commands can you have in a command?
Can you do this:

Command
  Sub1
    Sub1.1 fieldA fieldB fieldC
    Sub1.2 fieldX fieldY fieldZ
  Sub2
    Sub2.1 fieldA fieldB fieldC
    Sub2.2 fieldX fieldY fieldZ
```Or does it only extend to 1 sub-command
bleak owl

you can use subcommandgroups

command

  • subgroup
    • subcommand
    • options

but nothing more than that

eternal drift

That's fine, that's what I'm showing above, I'm pretty sure, and that's all I'll need. ty

elfin scroll

Can bots check something on GuildMember to get the info about if they agreed to the server rules popup? is it something i can get with djs?

tardy sable
sharp ginkgoBOT
scenic berry

hello i am creating a trascript for ticket, using discord-html-transcript. and how can i mention a member that created the ticket after closing the ticket channel?

i have tried memberOverwrite.username but it sent a undefined. and without it, it is a object.

const overwrites = channel.permissionOverwrites.cache;

const memberOverwrite = overwrites.find(po =>
    po.type === 1 && // 1 = Member (User)
    po.allow.has('ViewChannel')
);

const rawTranscript = await discordTranscripts.createTranscript(channel);
const container = new ContainerBuilder()

container.addTextDisplayComponents(
 new TextDisplayBuilder().setContent(`${interaction.user.username} has closed ${memberOverwrite}'s tเᥴkꫀt.`),
 new TextDisplayBuilder().setContent(`— thank you for᥉hꪮρρเᥒg @ kᥲᥣkᥡ’᥉ !`)
)```
elfin scroll
tardy sable
scenic berry
tardy sable

also youd usually wanna work with a db for these kind of stuff (the overwite wont exist if user leaves for example)

scenic berry
warm charm
scenic berry
tardy sable
warm charm
scenic berry
clear garnet
sharp ginkgoBOT
warm charm

oh i see lol

scenic berry

ohhh thank you @tardy sable, its working now.💝 11658pepepray

const overwrites = channel.permissionOverwrites.cache;

const memberOverwrite = overwrites.find(po =>
 po.type === 1 && // 1 = Member (User)
 po.allow.has('ViewChannel')
);

const channelOwner = interaction.guild.members.cache.get(memberOverwrite.id);

channelOwner.user.username

@clear garnet @warm charm thanks for the assist too.

tardy sable
scenic berry

for sql im using supabase right now.

tired hazel

Hi everyone, I am calling client.user.setPresence but that isn't setting the presence of the bot. I also tried calling setStatus and setActivity individually but same outcome there aswell.

 client.user.setStatus(PresenceUpdateStatus.Online);
    client.user.setActivity({
      name: `${answeredCount} answered, ${remainingCount} remaining`,
      type: ActivityType.Watching,
    });

the bot shows up as offline no matter what

scenic berry
tired hazel
scenic berry

Is there a error on logs? You can remove the status, when the bot has logged on. Its automsticaly set to online.

tired hazel

nope, no error but the bot continues to work

but this bot is only for personal usage so I guess I can deal with offline status

fallow finch
hushed kraken

Hi,
i want to use a Button in a followUp message.

const { ActionRowBuilder, ButtonBuilder, ButtonStyle, ButtonInteraction, SlashCommandBuilder } = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder().setName('test').setDescription('neuer Unsinn'),
    async execute(interaction) {
        
        await interaction.reply('Frosch?');
        const butt = new ButtonBuilder().setCustomId('b1').setLabel('ClickMe').setStyle(ButtonStyle.Secondary);
        const row = new ActionRowBuilder().addComponents(butt);

        response = await interaction.followUp({content: "Hi" ,components: [row], withResponse: true, });

        const collectorFilter = (i) => i.user.id === interaction.user.id;
    try {
        const confirmation = await response.resource.message.awaitMessageComponent({ filter: collectorFilter});
        await interaction.deferUpdate();

           if (confirmation.customId === 'b1') {
            await interaction.followUp( "Ho" )
        }

    } catch (error) {
    console.log(error);
    }


    },
};

When klicking the Button i get this Error

    at Object.execute```
warm charm
tardy sable

fetchReply is deprecated

withResponse is the good way

polar karma

Create the collector directly on the InteractionResponse object

sharp ginkgoBOT
polar karma

You should refer to the docs to see what properties and methods actually exist

hushed kraken

sorry, i am new and work mostly with the guide

calm elm

I am running a DIscord Bot on an AWS server that only has ip v6. I am aware that I can not directly connect to Discord with my bot using only v6. I have been using warp (which is working) but looking for something lighter. I am going to create a cloudflare tunnel for handling tcp traffic using socks5. Would I modify the client as follows:

const discordProxy = new SocksProxyAgent('socks5://127.0.0.1:4000');
const httpsAgent = new https.Agent({ 
  keepAlive: true,
  lookup: discordProxy
});

const client = new Client({
  intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent],
  rest: {
    agent: httpsAgent
  }
});```
trail spindle

Hello, any help would be greatly appreciated. TIA.

I'm currently writing a verification modal that will send a message to a selected channel, however I've come into an issue where the targeted channel.send() is not a function.

code:

await interaction.showModal(verifyMessage);

        const filter = (interaction) =>
            interaction.customId === `${interaction.guild.id}-verifyMessage`
        interaction
            .awaitModalSubmit({ filter, time: 600_000 })
            .then(async (modalInteraction) => {
                const verifyValue = modalInteraction.fields.getTextInputValue(`${interaction.guild.id}-verifymsg`);
                const verifyEmbed = new EmbedBuilder()
                    .setAuthor({ name: `${interaction.guild.name} | Verification System`})
                    .setColor('Green')
                    .setTimestamp()
                    .setFooter({ text: `${interaction.guild.name}`, icon: interaction.guild.iconURL })
                    .setDescription(`${verifyValue}`)


                const sendVerify = modalInteraction.fields.getSelectedChannels(`${interaction.guild.id}-verifychannel`);

                console.log(sendVerify);

                modalInteraction.reply({ content: `Verification message sent.`, flags: MessageFlags.Ephemeral })
            });

Logging the sendVerify shows the collection map, but I can't get past this part.

hallow mesa
tiny condor

Hey I'm a bit confused on something, can I efficiently check if a user's guild tag was updated without having to check my database if they had it previously or not?

Apparently it emits both guildmemberupdate and userupdate, depending on if the user is cached, but sometimes the old user's tag can be null eitherway, so how am I supposed to know if they had my tag and removed it

trail spindle
hallow mesa
tiny condor
hallow mesa

UserUpdate would fire. I'm not sure whether GuildMemberUpdate does as well but it would be redundant at best

tardy sable

GuildMemberUpdate doesnt fire this event

tiny condor

I am not getting consistent results with user update, neither with guildmemberupdate

I have a command people can run if the bot didn't detect them but for the majority I want it to be automatic

hallow mesa

Can you expand on the inconsistency? Both events have the same limitation that old data is pulled from the cache. It's not provided by the API

tiny condor

Well it just doesn't fire sometimes, I have only used UserUpdate and tried GuildMemberUpdate once, user update is more consistent but isn't firing all the time, guild member update didn't fire in any of my tests

I would also rather not checking my database twice for one user because both events fire together

hallow mesa

I see that above you said you have the User partial. Do you have the GuildMember one as well?

calm elm
hallow mesa

I'm not sure why neither event would emit if you have the right intents and partials. As far as handling your database, you could dedupe requests or cache your responses

calm elm
sharp ginkgoBOT
molten summit
bleak owl
hybrid fable

Hey, I need to reference a channel "from earlier" and I am saving the ID to find it again

I would do a client.channels.fetch() and be done with it, but from what I read, the channel should be in some kind of cache?

Should I just execute fetch because it will look into the cache, or do I have to use some other method?

I am using the "Guilds" intent, whatever that means, but I read cache is somewhat related to that

stable sun

Can it a thread channel?

Particularly an archived one

hybrid fable

No this is only going to be an actual channel

stable sun

client.channels.cache.get(…) is sufficient

hybrid fable

Thanks, I am not sure yet if I will need it, but if it was a thread, I should fetch it instead then, I gather?

I plan on creating a thread but not sure if I need to reference it later, don't think so from the current design

stable sun

Only DMs/Group DMs and archived threads aren’t guaranteed to be cached

Other guild channels are guaranteed to be cached upon ready w/ Guilds intents

hybrid fable

Thanks

vocal garnet

is it possible for a bot to pause invites for a server with discord.js?

sharp ginkgoBOT
vocal garnet

ohhh thank youu

wary coral

I also think setIncidentActions can be used but am unsure

vocal garnet

tysm ill try it

stiff plover
        if (guild.iconURL()) {
            container.addMediaGalleryComponents(mg =>
                mg.addItems(
                    new MediaGalleryItemBuilder()
                        .setURL(guild.iconURL({ size: 128}))
                )
            )
        }```

is there a way to get this guild icon to act as a thumbnail like in an old embed, like move it to the top right corner or something
sharp ginkgoBOT

guide suggestion for @stiff plover:
guide Thumbnail
A Thumbnail is a display component that is visually similar to the thumbnail field inside an embed. Thumbnails are added as accessory inside a Section component, support alt text for accessibility, and can be marked as a spoiler. You can use the ThumbnailBuilder class to easily create a Thumbnail component: For more information about using attachments in components refer to the guide on attaching images in embeds.

stiff plover

omg 💔 thanks

tardy sable

why is it that the guildmemberadd event sometimes get triggered twice? i know theres also still the bug with dupe discord system welcome messages. is there a way to prevent this anyway?

tiny condor

@steel trail even though guild member doesn't have the tag property, are you sure GuildMemberUpdate event fires if the user isn't cached and changes their tag?

or if anyone else knows, but he is the only one that said that

tiny condor

It seems to work fine apart from the fact that it still doesn't detect the first update or maybe some

halcyon bison
tiny condor or if anyone else knows, but he is the only one that said that

you'd need the GuildMember partial, but yeah that'd make sense to me
djs's userUpdate event isn't the same as the gateway user update, but rather is extrapolated from other events such as guildMemberUpdate, the event by which discord sends updates to member's user objects
so as qjuh mentioned, if it isn't previously cached, djs won't know the user was updated, so only guildMemberUpdate emits

tiny condor

I got the same code under both the events

crimson gale

we cannot emit the before state if we don't have it cached, discord just sends the "after update" state

if you opt into member (and potentially user) partials that should make those instances emit (but obviously still won't have the before data)

upper zealot

How many textInput I can attach to a Modal? Not sure where to find the limit on the documentation

bleak owl

5

tiny condor

Yeah I opted into both, I just check if the user is partial and instead check my own data to see if the user had their reward already, should be fine hopefully, I have a /tag command just in case for users to update their own status

subtle girder

there is a MessageCreate listener
when user mentions a user
the message content should be <@userid> or <@!userid>?

tardy sable
long laurel

https://discordjs.guide/legacy/additional-features/cooldowns

Can someone explain this part for me "The previous user check serves as a precaution in case the user leaves the guild."

I believe it's referring to if (timestamps.has(interaction.user.id)) in this snippet:

    const expiredTimestamp = Math.round(expirationTime / 1_000);
    return interaction.reply({
        content: `Please wait, you are on a cooldown for \`${command.data.name}\`. You can use it again <t:${expiredTimestamp}:R>.`,
        flags: MessageFlags.Ephemeral,
    });
} 

timestamps.set(interaction.user.id, now);
setTimeout(() => timestamps.delete(interaction.user.id), cooldownAmount);```
wary coral
tardy sable

oh ok i thought silent pings or something

subtle girder

cool, thx :D

tardy sable
flint pier

Can ban user ip?

unique shoal

no

Regular bans are supposedly IP bans though

loud quartz

they are, but it's completely managed by discord without any way to access it directly, and only applies to joining. mildly annoying when you need to unban an ip

pine plover

Overnight, all the bots are somehow different! And they're giving lots of errors! Has something happened?

crimson gale

you def. need to elaborate on that

"different" and "lots of errors" does explain absolutely nothing

pine plover

I am using discord.js 14.17.3

crimson gale

once more: what does "not work" mean
what are said errors?

trail spindle

Good morning, I come asking questions.

I am building a Modal that'll collect 3 channels and 2 roles independently from labels (reference screenshot).

Is it possible to collect and pull the channel IDs and role IDs respectively, in one collector, in order to add it to a db for per-guild configurations? or will I be mapping per label?

unique shoal

It will be a single modal submit interaction

warm charm

hi, did ComponentV2 have timestamp feature

shell girder

Something like this?

warm charm

yeah

little pebble
shell girder

^^

warm charm
shell girder
const mainContainer = new ContainerBuilder()
  .setAccentColor(0x0099ff)
  .addTextDisplayComponents(
  new TextDisplayBuilder().setContent(`
        ${new Date().toLocaleString()}
      `)
);

await interaction.reply({
        flags: MessageFlags.IsComponentsV2,
        components: [mainContainer],
      });

It's as they told you, just add a separator and a TextrDisplay.

steel trail

That's not a discord timestamp though. Use time() instead

warm charm

<t:${Math.round(Date.now() / 1000)}:F>

im using this 💀

sharp ginkgoBOT
warm charm

btw thanks yall for the help

shell girder

🙂

fathom warren

hello, does anyone know how can I set rules channel to another existing ( or newly created ) channel? because when I try to do so, newly created channel gets yeeted and nothing changes

and don't blame me, cause methods djs provides seems to not work at all

sharp ginkgoBOT

guide Channel overwrites
Permission overwrites control members' abilities for this specific channel or a set of channels if applied to a category with synchronized child channels. As you have likely already seen in your desktop client, channel overwrites have three states: - Explicit allow (true, green ✓) - Explicit deny (false, red X) - Default (null, gray /)...

fathom warren

dude, i meant community channels

steel trail
wraith cedar
.addSectionComponents(
                new SectionBuilder()         
                    .addTextDisplayComponents((textDisplay) =>
                        textDisplay.setContent(
                            `${target.user.displayName || target.user.globalName || target.user.username} has **${netInvites}** invites
                                > ![DB_spark](https://cdn.discordapp.com/emojis/1274709483796562020.webp?size=128 "DB_spark") Joins: **${inviteData.joins || 0}**
                                > ![DB_spark](https://cdn.discordapp.com/emojis/1274709483796562020.webp?size=128 "DB_spark") Left: **${inviteData.leaves || 0}**
                                > ![DB_spark](https://cdn.discordapp.com/emojis/1274709483796562020.webp?size=128 "DB_spark") Fake: **${inviteData.fakes || 0}**
                                > ![DB_spark](https://cdn.discordapp.com/emojis/1274709483796562020.webp?size=128 "DB_spark") Bonus: **${inviteData.bonusInvites || 0}**
                                > ![DB_spark](https://cdn.discordapp.com/emojis/1274709483796562020.webp?size=128 "DB_spark") Rejoins: **${recentRejoins}**`
                        )
                    )
                    .setThumbnailAccessory((thumbnail) =>
                        thumbnail
                            .setURL(target.user.displayAvatarURL({ size: 512 }))
                            .setDescription(`${target.user.displayName}'s avatar`)
                    )
            )```
can i do smth about the gap in bw?
dense jackal
fathom warren

or just use >>>, if u really need to

dense jackal

that won't fix the gap

wraith cedar
dense jackal
fathom warren

if not then why tf is it documented?
anyway it doesnt seem to work :>

cause if i want to delete an old one i get this

error: Cannot delete a channel required for community servers

even tho i set channel for it

i just want to do damn backup loading which involves clearing all channels including (old) community ones and then setting them back

is that discord API issue or mine, cause im beginning to wonder

dense jackal

if that happened and on deletion it still throws that error then you should report it as bug on the discord-api-docs github page

sharp ginkgoBOT

method Guild#setRulesChannel() discord.js@14.25.1
Edits the rules channel of the guild.


// Edit the guild rules channel
guild.setRulesChannel(channel)
 .then(updated => console.log(`Updated guild rules channel to ${guild.rulesChannel.name}`))
 .catch(console.error);

steel trail

You're using this one?

fathom warren

yep

fathom warren
fathom warren
dense jackal

including the .then()

steel trail
fathom warren

it just keeps old channel never changes to channel which you parse

new channel name is temp-rules

@steel trail

i do not force fetch anything nor read cache cause i dont need to, i want just two problematic channels to be cleared, retrieve them from database where all of necessary data was saved and set everything back as it was b4 backup

looks like im all by myself with that

steel trail
fathom warren

then snippet is kind of useless i guess wut

oh LMFAO it doesnt work with community enabled KEKWXD

i have to disable community feature for this methods to work, hillarious

so basically what i need to do for backup load to work is

  • disable community
  • let backup module do its thing
  • set back channels which had their respective meanings
  • prompt user to enable community feature manually

LMAO im gonna laugh so hard if it will work

tribal birch

Can I have /invites as root command then add and remove subcommands so /invites, /invites add, /invites remove

wary coral
sharp ginkgoBOT

discord Application Commands - Subcommands and Subcommand Groups
For those developers looking to make more organized and complex groups of commands, look no further than subcommands and groups. Subcommands organize your commands by specifying actions within a command or group. Subcommand Groups organize your subcommands by grouping subcommands by similar action or resource within a command. These are not enforced rules. You are free to use subcommands and groups however you'd like; it's just how we think about them.

steel trail
eternal drift

How can I easily check the resource type of an ID; user, role, channel etc

wary coral
fathom warren

I'll investigate further with new guild once im back to my PC

jagged rock

where can i find specfic log types and what i can recieve from them

gentle imp

how to make this appear on my bot

vast nymph

if it says unknown, click it and it will take you to the channel

fathom warren
sharp ginkgoBOT
olive torrent

Guys I am getting UND_ERR_CONNECT_TIMEOUT error. Is there a fix?

eternal drift
wary coral
sharp ginkgoBOT

tag suggestion for @olive torrent:

Errors such as ECONNRESET, ConnectTimeoutError, SocketError: other side closed indicate a network issue

  • Free or shared hosting providers often come with significant limitations
  • Another indication of these issues are 'Unknown Interaction' errors.
eternal drift
steel trail
jagged rock

nm

tardy sable
obtuse crystal

Hey all, I'm sure I'm making a simple mistake but I could really use some help.

I've just created a new bot and added it to my guild.
config.serverID is defined (confirmed by the error in logs).

There's no "Could not find the specified guild!" but I still receive:

Failed to push commands: DiscordAPIError[10004]: Unknown Guild

What am I doing wrong?

const pushCommands = async () => {
            try {
                const guild = await this.#client.guilds.fetch(config.serverID);
                if (!guild) {
                    throw new Error("Could not find the specified guild!");
                }

                // Set all commands to the specific guild
                await guild.commands.set([...guildCommands, ...developerCommands]);
                console.log(`All commands have been registered to "${guild.name}"`);
            } catch (error) {
                console.error("Failed to push commands:", error);
            }
        };
Failed to push commands: DiscordAPIError[10004]: Unknown Guild
2025-12-06 16:12:32     at handleErrors (/app/node_modules/@discordjs/rest/dist/index.js:762:13)
2025-12-06 16:12:32     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2025-12-06 16:12:32     at async SequentialHandler.runRequest (/app/node_modules/@discordjs/rest/dist/index.js:1163:23)
2025-12-06 16:12:32     at async SequentialHandler.queueRequest (/app/node_modules/@discordjs/rest/dist/index.js:994:14)
2025-12-06 16:12:32     at async _REST.request (/app/node_modules/@discordjs/rest/dist/index.js:1307:22)
2025-12-06 16:12:32     at async GuildManager.fetch (/app/node_modules/discord.js/src/managers/GuildManager.js:276:20)
2025-12-06 16:12:32     at async pushCommands (/app/dist/Structure/Classes/Handler.js:74:31) {
2025-12-06 16:12:32   requestBody: { files: undefined, json: undefined },
2025-12-06 16:12:32   rawError: { message: 'Unknown Guild', code: 10004 },
2025-12-06 16:12:32   code: 10004,
2025-12-06 16:12:32   status: 404,
2025-12-06 16:12:32   method: 'GET',
2025-12-06 16:12:32   url: 'https://discord.com/api/v10/guilds/1437478894725894314?with_counts=true'
2025-12-06 16:12:32 }
wary coral

Your bot is not able to fetch the guild

So it's two options that come to mind for me. Either your bot is not able to fetch the guild information or your ID is wrong

obtuse crystal

I'll try to look more into this, brb, ty

Wow. I must have copied the wrong server's ID. Completely stupid mistake facepalm Thank you

torn sparrow

I need to set a member's roles using <guildmember>.roles.set(), but I'm getting an error because some members have roles like “booster.” If a member has a “booster” role or an unmanaged role, is there a way to set their roles without touching those roles?

unique shoal

I forget which but you either need to filter them out of the ones you're trying to apply, or make sure they're in the list you're trying to apply

It might be the second one, make sure they're still in the set, so it doesn't try to remove them and error

cobalt plover

cant you use <guildmember>.roles.add()?

oh nvm you want to specifically set them

torn sparrow

yep