#djs-help-v14

79229 messages · Page 80 of 80 (latest)

tardy sable
#

whats the image youre sending?

jaunty urchin
tardy sable
jaunty urchin
#

it must this as url?

delicate pike
#

Is there a way to get the original message from this setup?

Message with buttons --(button click)--> Interaction --(button click)--> edit the message with buttons

ionic lance
sharp ginkgoBOT
delicate pike
#

Oh, didn't realize that. Thanks

wary coral
#

If you're looking to edit the original message, you should use <ButtonInteraction>#update()

topaz bluff
#

If you don't get a response, either wait or make a #986520997006032896 post so that it doesn't get lost in the chat...

tardy sable
cobalt valley
#

Is there a way to disconnect the bot (itself) from a voice channel without needing any permissions?

loud quartz
#

Just end the voice connection

cobalt valley
#

okay, also is the guild.members.me.voice.channel is always in cache?

stable sun
#

Yes, as long as you don’t influence it otherwise

#

You shouldn’t be messing w/ any channels cache anyways

cobalt valley
#

Yes, I was just trying to access that, assuming it will be in cache always!

somber dome
#

CombinedError (2)
Received one or more errors

1 ExpectedValidationError > s.instance(V)
| Expected
|
| Expected:
| | [Function: ButtonBuilder]
|
| Received:
| | undefined

2 ExpectedValidationError > s.instance(V)
| Expected
|
| Expected:
| | [Function: ThumbnailBuilder]
|
| Received:
| | undefined

at _UnionValidator.handle (C:\Users\shong\Kick - BOT\KickBot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:1965:23)
at _UnionValidator.parse (C:\Users\shong\Kick - BOT\KickBot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:90)
at SectionBuilder.toJSON (C:\Users\shong\Kick - BOT\KickBot\node_modules\@discordjs\builders\dist\index.js:2536:37)
at C:\Users\shong\Kick - BOT\KickBot\node_modules\@discordjs\builders\dist\index.js:2237:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (C:\Users\shong\Kick - BOT\KickBot\node_modules\@discordjs\builders\dist\index.js:2237:35)
at C:\Users\shong\Kick - BOT\KickBot\node_modules\discord.js\src\structures\MessagePayload.js:151:46
at Array.map (<anonymous>)
at MessagePayload.resolveBody (C:\Users\shong\Kick - BOT\KickBot\node_modules\discord.js\src\structures\MessagePayload.js:150:49)
at ChatInputCommandInteraction.reply (C:\Users\shong\Kick - BOT\KickBot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:191:56)

(node:10972) Warning: Supplying "ephemeral" for interaction response options is deprecated. Utilize flags instead.

wary coral
#

likely line 131-140

candid spindle
#

is there a way to "mute" someone in a regular voice channel without server muting them or changing channel permissions or giving roles?

#

a bot i know does it but can't work it out so i'm asking if theres an official way of doing it

topaz bluff
candid spindle
wary coral
#

like the self mute? I don't think a bot can do that to user, only server mute

candid spindle
# tardy sable isnt that just server mute?

theres server mute but then theres a different kind of mute, I think the bot i described uses some illegal means of doing it but basically it literally looks like you muted yourself on my end but you didn't the bot prevents you from unmuting but theres no visible channel permission or role permissions that were changed.. its weird

loud quartz
#

server muting someone in voice is not a permission or a role change

feral skiff
# somber dome CombinedError (2) Received one or more errors 1 ExpectedValidationError > s...

"Þ¥¿????舐╟ اŮñâmå•©ðsžšåÞя╟ ▀????Þ¥¿???? ©Ř§Ů— £╟舐—� ¶????½ ©舐¶—舐—ðsžšåÞя舐 £▀ا٩ñâmå•ا٩¶Ř§Ů½ æØ¢Ã 舐Þ¥¿Ř§Ů—. ▀ðsžšåÞяا٩ —舐Þ¥¿Þ¥¿ðsžšåÞя©. ▀????½ 舐¶ £½ —舐 ▀????Þ¥¿????� اŮ£¶ðsžšåÞяÞ¥¿Ř§Ů© ½ 舐¶� æØ¢Ã£☒اŮ▀£ £¶� ¶ðsžšåÞя©ðsžšåÞя© Ř§Ů½ � 舐????©. ╟£ðsžšåÞяا٩ ☒舐©—اٻðsžšåÞяÞ¥¿ðsžšåÞя╟� 舐Þ¥¿Ř§Ů© 舐— 舐æØ¢Ã舐©—£© ðsžšåÞяÞ¥¿Þ¥¿Â£╟¶ ????ñâmå•舐� ñâmå•ðsžšåÞяðsžšåÞя© ½ اٻ‚� ☒舐‚�اٶðsžšåÞяÞ¥¿Â£ ©舐╟� 舐ðsžšåÞя 舐æØ¢Ã舐©—£© £½ —舐 ½ Ř§Ů©Þ¥¿ ½ ????½ áÍÞæðsžšåÞя©—????. ðsžšåÞя©¶舐 —Ř§Ů½ ¶Ř§Ů▀ðsžšåÞя½ —� Þ¥¿????舐╟ ½ 舐☒ ▀£ñâmå•اٻðsžšåÞя© ¶????½ ©舐¶—舐—ðsžšåÞя舐� Þ¥¿舐???? ????¶Ř§Ů ╟????Þ¥¿Þ¥¿Ř§Ů© اŮñâmå•©ðsžšåÞя╟� 舐æØ¢Ã舐— ©ðsžšåÞя©¶Ř§Ůñâmå•اٗ 舐????© ñâmå•ðsžšåÞяðsžšåÞя© Ř§Ů½ £½ —舐."

#
  • wise words from discordjs
dapper scarab
#

where did MessageFlags and ApplicationCommandOptionType go? it was there just a month ago...

jagged rock
dapper scarab
jagged rock
steel trail
dapper scarab
steel trail
#

What doesn't work about it? Do you get errors or does your IDE simply believe it can't find them?

dapper scarab
steel trail
#

Restart ts-server if that's VSCode. If it's webstorm or a different IDE from the same company: they have issues with finding re-exported stuff in djs. If the error doesn't exist when you run the code you know it's an IDE issue

dapper scarab
cinder shale
#

with discordjs/ws, when should i use

      parentPort?.postMessage({
        type: 'dispatch',
        shardId: shard.id,
        event: payload,
      });``` and when should i use
```ts
      redis.publish(
        'worker',
        JSON.stringify({
          type: 'dispatch',
          shardId: shard.id,
          event: payload,
        }),
      );```
-# basically im asking when its good to send events w redis pub/sub and when the normal parent port way is already enough
jagged rock
cinder shale
jagged rock
cinder shale
# jagged rock 👌

ig its also worth to ask when i should have the dispatch as a event to forward and when i should have it on the shardCallback

jagged rock
candid spindle
# loud quartz

I know, but what i'm talking about looks like the folloowing image but doesn't change the channel permissions or give the user role, or actually server mute them, its not red but it mutes the person via the bot, was wondering if this was actually possible via discord.js or not because a bot i know actually does do this

cinder shale
jagged rock
#

in ur case gateway worker gets event > forward to main > main calls client.emit

#

if the worker is only receiving gateway dispatches and your main process is the thing that turns them into client.emit then you should forward them back to the main process f

#

anything else u need lmk

cinder shale
# jagged rock anything else u need lmk

something thats not very related to workers now, how should I make a resharding system with discordjs/ws? i never made one before so im quite clueless
-# not asking for u to make the code for me, just wondering on how exactly i should make it

cinder shale
loud quartz
#

Because the only way to mute yourself is to mute yourself, and besides you doing it manually it's possible to do it via RPC, but it's not that simple as "just do it differently"

loud quartz
#

we have #1081585952654360687 for things like that, and keeping it in the server allows more eyes to look at the issue

jagged rock
tardy sable
jagged rock
modern shell
#

How can I access my client.emit() function from a separate file I am requiring my client from?

app.js

const client = { /* intents & partials */ }
module.exports = client;

streams.js

const client = require('../app');
client.emit('message', 'a message');

message.js

module.exports = {
  name: 'message',
  async execute(msg) { /* logic */ };
};

TypeError: client.emit is not a function

tardy sable
modern shell
tardy sable
modern shell
tardy sable
#

oh ok i see now you edited the message. does that work now?

modern shell
#

It does not 😐

tardy sable
modern shell
worthy drift
modern shell
worthy drift
#

Uhh, you do module.exports in your streams.js and then require it inside your app.js 😅

candid spindle
worthy drift
# modern shell I'll give it a try 👍 I changed my exports to `module.exports = (client) => { c...

like

//app.js
const { Client } = require('discord.js');
const client = new Client({/*pass your options...*/});
require('./file.js')(client);

//streams.js
module.exports = (client) => {
  //your code here...
  client.emit();
}

i would suggest you to wrap everything in a function attached to client like client.yourfunction = function() {/*your code...*/ client.emit()}. that way you basically init your file, its attached to the client and you can call it whenever and whereever you want as long as you have access to the client.

modern shell
loud quartz
#

Long before interactions have started existing

#

Tbf I'm curious what are you actually describing, but at this point it's not d.js related

candid spindle
loud quartz
#

I mean, d.js is just using discord's bot API

#

To figure out if you can do it via d.js, first thing is to figure out what it's doing

candid spindle
#

yeahhhh.. no idea whats its doing cos it isn't changing permissions nor adding roles nor server muting so its some funky thing going on haha

wraith stone
#

I'm trying to make an app and it says Missing Access?

#

thank you 🙏 jfc

wraith stone
#

But I've found this to be a pretty knowledgable server about apps, so maybe I'm wrong?

tardy sable
wraith stone
#

What more info is there to give?

tardy sable
wraith stone
#

Yes

tardy sable
wraith stone
#

im banned from that server
and i dont know any alternative

#

if there's any other server besides the one you linked lmk

tardy sable
#

well i cant unfortunately help you better with this cuz thats not enough info to help you

wraith stone
#

okay hold up you want like an image?

tardy sable
#

anything that gives more info

wraith stone
#

okay so ill get you an image rq

stable sun
#

Where does it say this?

wraith stone
#

The dev portal

stable sun
#

Is ur email verified?

wraith stone
#

yes?

#

if you dont verify your email your account is automatically deleted after a bit i think

stable sun
#

Can’t think of why else you can’t create an app

wraith stone
#

should I try my alt?

#

(i do feel like this is the wrong channel for this type of question still)

stable sun
#

Well, it’s the wrong server

wraith stone
#

Is there any alternative that isn't ddevs?

stable sun
#

Dapi prob

wraith stone
#

I was considering that one

#

lowkey

#

I was also considering trying town hall
But I'd probably get ejected to DDevs if I ask there

stable sun
#

Never heard of town hall tbh

wraith stone
#
  1. it was recent. like. recent. literally today
  2. it was very justified imo. they wouldnt let me back in for at least a while
#

not going into this here, this is absolutely not the place for this type of discussion

#

either way, ill go to dapi. thank you!

sleek mural
#

Does booster role return "managed" as true?

stable sun
#

Role update fires for each role that was affected

#

I don’t think the Discord app can create a role with a raw position

narrow gazelle
#

ah okay i just leave as that for now

stable sun
#

Bots can, but even then usually opt not to since it’s easier just to update the raw positions to match the desired ones

stable sun
odd stirrup
#

can i get a modal submit field value without it erroring if the modal doesnt have that field

tardy sable
steel trail
steel yacht
#

Hi,

263 |         }
264 |       };
265 |       const timeout = setTimeout(() => {
266 |         this.client.removeListener(Events.GuildMembersChunk, handler);
267 |         this.client.decrementMaxListeners();
268 |         reject(new DiscordjsError(ErrorCodes.GuildMembersTimeout));
                     ^
error: Members didn't arrive in time.
 code: "GuildMembersTimeout"

      at <anonymous> (/home/debian/wheel-discord-bot/node_modules/discord.js/src/managers/GuildMemberManager.js:268:16)

Bun v1.3.1 (Linux x64)
```What causes this error ?
Thanks
astral prismBOT
# steel yacht Hi, ``` 263 | } 264 | }; 265 | const timeout = setTimeout(()...

Discord introduced a rate limit on requesting all guild members (once per 30s per guild).

  • You will have to update your code accordingly to make sure this doesn't affect your app.
  • Look for instances of guild.members.fetch() with no user ids.
  • Starting in version 14.25.0, discord.js rejects the returned Promise and exposes details in error.data.
    -# If you confirmed this cannot be the reason, you can find other caveats in our guide djsguide.
dry flame
#

Is there any test framework for Discord bots out there? Couldn't find anything that's somewhat maintained

loud quartz
#

Are you intending on testing the discord api, or your bot's code

#

The former makes no sense, and so there isn't much stuff to test bots as a whole

tardy sable
#

just make a test server to test your bot @dry flame

dry flame
#

@loud quartz @tardy sable I am looking to test my own bots, not the API itself. I think it would be useful as an integration test suite

tardy sable
dry flame
tardy sable
#

no i dont think theres some automation for it and tbh its always better to see the testing for yourself

loud quartz
#

You're not trying to test if your bot makes the api request correctly and if discord api responds to you correctly

#

All you're trying to test is if your bot's code generates correct response for the given input

#

It's easier to do that if you don't have your Command.execute() send responses directly, but have it only generate content for the response, that is then sent by the command handler or whatever

#

This way you merely check the execute method, like it's supposed to be

dry flame
cunning thunder
#

quick question:
with channel.send(..), can i send a message containing mentions that wont ping?

sharp ginkgoBOT
#

tag suggestion for @cunning thunder:
You can control which entities receive notifications via the allowedMentions option. You can:

{ ..., allowedMentions: { parse: ["users", "roles"] } }
cunning thunder
#

so this should be the thing i want?
channel.send({ message: "message", allowedMentions: { } }) ? correct me if i am wrong please

#

(since all are optional)
or would i need to parse an empty array here?

cunning thunder
#

tysm!

tardy sable
#

how to get the command name from a slash command response, cant find it in MessageInteractionMetadata

wary coral
sharp ginkgoBOT
#

Please add the following code to your code base outside of any other event listeners and provide the full log output relevant to your issue.

client
    .on("debug", console.log)
    .on("warn", console.log)
  • Note: if you initialize your Client as bot or other identifiers you need to use these instead of client
  • If the output is too long to post consider using a bin instead: gist | sourceb.in | hastebin
bleak owl
narrow gazelle
#

way to combain these into one then spearate files

bleak owl
#

i dont really suggest combining them

narrow gazelle
#

is so i dont have 30-50 files in one folder lol

bleak owl
#

you can split the files up into categories, which you can then adjust you event handler to work with after

sharp ginkgoBOT
#

guide Event Handling
Node.js uses an event-driven architecture, making it possible to execute code when a specific event occurs. The discord.js library takes full advantage of this. You can visit the Client documentation to see the full list of events. This page assumes you've followed the guide up to this point, and created your index.js and individual slash commands according to those pages. At this point, your index.js file has listeners for two events: ClientReady and InteractionCreate.

bleak owl
#

!

#

what are you confused about?

narrow gazelle
#
fs.readdirSync("./src/events").forEach(function (f) {

  if (fs.statSync(`./src/events/${f}`).isDirectory()) {
    return fs.readdirSync(`./src/events/${f}`).forEach(function (x) {
      bot.on(
        x.split(".")[0],
        require(`./events/${f}/${x}`).bind(null, bot, con, cfg)
      );
    });
  }

  bot.on(
    f.split(".")[0],
    require(`./events/${f}`).bind(null, bot, con, cfg)
  );

});```
this fine
bleak owl
#

i personally recommend the guide.

#

especially for organizing your files better for events

narrow gazelle
#

Your Talking About this

const { Events } = require('discord.js');
module.exports = {
    name: Events.ClientReady,
    once: true,
    execute(client) {
        console.log(`Ready! Logged in as ${client.user.tag}`);
    },
};```
bleak owl
#

no?

#

i don’t know what you’re referring to

narrow gazelle
bleak owl
#

ah, youre referring to the guide then?

#

i recommend you use the guide’s event handler for better organizing your event files

#

that’s my point

narrow gazelle
#

so thatconst eventsPath = path.join(__dirname, 'events'); const eventFiles = fs.readdirSync(eventsPath).filter((file) => file.endsWith('.js')); for (const file of eventFiles) { const filePath = path.join(eventsPath, file); const event = require(filePath); if (event.once) { client.once(event.name, (...args) => event.execute(...args)); } else { client.on(event.name, (...args) => event.execute(...args)); } }

bleak owl
#

yes

narrow gazelle
#

whats the diffrence dont see much

bleak owl
#

it’s completely different than your handler, i’m saying to use what the guide has for organizing your files

#

it’s your choice though since you asked about combining events, which i don’t recommend.

#

this is just my recommendation

narrow gazelle
#
  if (fs.statSync(`./src/events/${f}`).isDirectory()) {
    return fs.readdirSync(`./src/events/${f}`).forEach(function (x) {
      var event = require(`./events/${f}/${x}`);
      bot.on(event.name, function (...args) {
        event.run(bot, con, cfg, ...args);
      });
    });
  }
  var event = require(`./events/${f}`);
  bot.on(event.name, function (...args) {
    event.run(bot, con, cfg, ...args);
  });
});```this works great for my use
bleak owl
#

okay if it works then thats great!

narrow gazelle
#

dont really see any different on docs to that so should be fine

bleak owl
#

if you read the code you'll see the difference

narrow gazelle
#

what one lol more then one haha

bleak owl
#

what?

#

i dont quite understand you, i think there's some language barrier here

narrow gazelle
#

nvm

#

your talking about the client.once and client.on(?

bleak owl
#

from the guide, yes

narrow gazelle
# bleak owl from the guide, yes

so this then

fs.readdirSync("./src/events").forEach(function (f) {
  var event = require(`./events/${f}`);
  if (event.once) {
    bot.once(event.name, function (...args) {
      event.run(bot, con, cfg, ...args);
    });
  } else {
    bot.on(event.name, function (...args) {
      event.run(bot, con, cfg, ...args);
    });
  }
});```
bleak owl
#

that's not what the guide is suggesting. that's your own code

#

if you don't want to listen to my suggestion, that's fine. you can do whatever you want

#

im just trying to suggest ways you can organize your code better

sharp ginkgoBOT
narrow gazelle
bleak owl
bleak owl
#

we’re really going in circles here

narrow gazelle
bleak owl
#

please use whatever you want

narrow gazelle
#

no saying that just dont see the change in what you mean

bleak owl
#

seems like you edited your message to match what the guide has, which is what i was suggesting

#

so, please use whatever code you want, i can only suggest so much

narrow gazelle
narrow gazelle
bleak owl
#

i didn’t say there was a problem

#

i’m sorry, i can’t assist anymore.

narrow gazelle
#

thats fine works any way and wont need change so its fine

bleak owl
#

but you didn’t seem to listen to my suggestion based on your original question, this is why can’t help anymore. good luck!

shell girder
#

In the TextInput Style class of modals, in the short and paragraph fields, do they have a character limit?

shell girder
#

Ty.

steel galleon
#

i hope i understand all of this soon

#

😭

#

i dont understand a single word rn

bleak owl
#

do you have a question about discord.js?

steel galleon
#

k now i do nvm

#

thx

pearl hazel
#

i can do

  const overwrites = channel.permissionOverwrites.cache.get(guild.id);
  const allow = overwrites.allow
  const deny = overwrites.deny

but how to check the null ?

#

if it's not allow or deny

polar karma
#

it won't be present in either of those bitfields

rigid crest
#

uh oh

stable sun
#

inherit = ~allow & ~deny

rigid crest
stable sun
#

Oh

#

Mb then

ivory wasp
#

What's the AVATAR_RATE_LIMIT?

#

avatar[AVATAR_RATE_LIMIT]: You are changing your avatar too fast. Try again later.

tardy sable
ivory wasp
#

Thanks

jolly cypress
#

In the slash commands docs, can someone tell me where the execute method comes from? I cant find anything about it

wary coral
#

execute is a user built function it is not part of the library

#

it is in the guide but not the library

jolly cypress
sharp ginkgoBOT
#

guide Creating Slash Commands
Discord allows developers to register slash commands, which provide users a first-class way of interacting directly with your application. Slash commands provide a huge number of benefits over manual message parsing, including: - Integration with the Discord client interface. - Automatic command detection and parsing of the associated options/arguments. - Typed argument inputs for command options, e.g. "String", "User", or "Role". - Validated or dynamic choices for command options. ...and many more!

wary coral
#

You should re read this page of the guide

halcyon bison
jolly cypress
#

No key:value pair confused me.