#archive-github-djs

1 messages ยท Page 7 of 1

heavy crowBOT
#

Please describe the problem you are having in as much detail as possible:
Im having issue with registering commands or interactions.
The code runs without errors but /ping command doesnt show up in / commands.

Include a reproducible code sample here, if possible:

// index.js
const {Client, Intents} = require('discord.js');
const { token } = require('./config.json');


const client = new Client({
	intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES...
heavy crowBOT
#

I was suggesting using the same logic but for the button's URL. I know you can have the same URL in different buttons but I don't see why anyone would do that. You could also add a warning saying it will return the first button with the given URL if a URL is passed.
Alternatively I think you should add some sort of note saying LINK buttons will not work as they do not have customIds

#

Please describe the changes this PR makes and why it should be merged:
Following the PR that added the setFields method for MessageEmbeds, this PR adds two new methods: setOptions for MessageSelectMenu and setComponents for MessageActionRow.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don'...
heavy crowBOT
#

applicationCommandCreate doesnt fire when Guild Command is created
Havent tried Delete and Update but my guess is the same issue

According to Docs and Discord Developer it should fire for both Guild and Client Command Applications

client.on('applicationCommandCreate', async command => {
    console.log(command)
});

Further details:

  • discord.js version: 13.1
  • Node.js version: 16.6.2
  • Operating system: x64 win 10
heavy crowBOT
#

Please describe the changes this PR makes and why it should be merged:
This PR removes applicationCommand events as a Discord developer said they were not meant to be sent to bots (https://github.com/discord/discord-api-docs/issues/3690#issuecomment-902915187). This can be a semver minor since the events never fired anyway.
Upstream PR:

Status and versioning classification:

  • Code changes have been tested against the Disc...
#
#

Please describe the changes this PR makes and why it should be merged:

This PR starts the work of adding support for GuildEvent structure:

  • discord/discord-api-docs#3586

Todo:

  • [x] Add GuildEvent class
  • [ ] Define all properties of the GuildEvent class
  • [ ] Add Complete Documentation
  • [ ] Add Complete Typings
  • [ ] Get List of guild events in a guild
  • [ ] Post Create a guild event
  • [ ] Get List of guild events available to the bot
  • [ ] Get A guild even...
heavy crowBOT
heavy crowBOT
#

I can reproduce something to this effect, where whenever a thread is created both the threadCreate event and messageCreate events are emitted. The message object in the messageCreate event seems to have a content string that is the same as the name of the thread created. This repo reproduces what appears to be causing this bug.

It looks like whenever you thread on a cached message, a message event is emitted with no content, and whenever you ...

heavy crowBOT
heavy crowBOT
#

Please describe the changes this PR makes and why it should be merged:
Adds support for friend invites:

To be non-breaking, this PR adds a supportFriendInvites ClientOption: by default, it is false, and fetching a friend invite will continue to throw an error. If it is set to true, fetching a friend invite will return an Invite with channel as null.

The guide should recommend setting supportFriendInvites to true.

*...

#

Please describe the changes this PR makes and why it should be merged:
This PR adds the missing parameter called resolved in CommandInteractionOptionResolver that was introduced in #6384 but not added in the typings.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating
heavy crowBOT
#

Is your feature request related to a problem? Please describe.
I wanna create user information command and cant get banner/accent color

Describe the ideal solution
Add banner and accent color property for users

Describe alternatives you've considered
No alternative solutions

Additional context

const banner = .bannerURL
heavy crowBOT
heavy crowBOT
#

Please describe the changes this PR makes and why it should be merged:

Adds the defaultValue parameter for getBoolean, getString, getInteger, and getNumber in cases when the option is optional.

I'm not sure whether it's worth adding this parameter for the rest of the options, so for now I've stopped only on the "primitive" ones.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how ...
heavy crowBOT
#

Please describe the changes this PR makes and why it should be merged:

Closes: #6379

Fixes a bug in typings that didn't pass the allowable thread types properly for news channels since this relies on it.

โš ๏ธ The invitable field in the thread creation endpoint does not seem to be respected at the moment, it is supported here, but the API does not utilize it, always setting true.

Status and versioning classification:

  • Code changes have been tested against the Discord A...
heavy crowBOT
heavy crowBOT
#

Please describe the changes this PR makes and why it should be merged:
The type of the type property in this typedef was set to string|number which is misleading since this is actually supposed to be a ChannelType, so this PR fixes that.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • This PR only includes non-code changes, like changes to documentation, README, etc.
heavy crowBOT
#

Please describe the problem you are having in as much detail as possible:
My discord bot keeps getting timed our randomly, i have no idea why. Its a lavalink music bot running along another bot of mine which does not crash. the vps is given 4gb ram and 2vCore CPU
image

Include a reproducible code sample here, if possible:

const app = express();
const port = 2...
heavy crowBOT
heavy crowBOT
heavy crowBOT
#

Is your feature request related to a problem? Please describe.
I noticed that d.js doesn't implement Guild-specific Identities. User.displayAvatarURL() only retrieves the user's default avatar. Discord's newest feature, Server Identities, allows people to change their nickname and avatar for specific Guilds.

Describe the ideal solution
I think d.js could implement GuildMember.identity, where identity is of type GuildMemberIdentity, thereby also moving `GuildMember...

heavy crowBOT
#
getString('field', false, 'default')

is longer than

getString('field') ?? 'default'

so this doesn't seem very useful

Yes, it's true.

However, in TypeScript, the solution you are talking about is unsafe, because with this operator you can assign a string to getInteger and it will not cause an error.

And the current implementation looks more expensive:

// Current implementation.
const x = getInteger("x") ?? "5"; // no er...
heavy crowBOT
#

Please describe the problem you are having in as much detail as possible:
A bot is able to create a Webhook just fine, but the promise for creating a Webhook and the promise for fetching a Webhook is never resolved or rejected.
Include a reproducible code sample here, if possible:

client.on('ready', () => {
    console.log('ready');
    const channel = client.channels.cache.get('123');
    channel.createWebhook('MyFancyWebhook').catch(err => {
        console.log(err);...
#

getString('field', false, 'default')

is longer than

getString('field') ?? 'default'

so this doesn't seem very useful

Yes, it's true.

However, in TypeScript, the solution you are talking about is unsafe, because with this operator you can assign a string to getInteger and it will not cause an error.

And the current implementation looks more expensive:

...
heavy crowBOT
#

However, in TypeScript, the solution you are talking about is unsafe, because with this operator you can assign a string to getInteger and it will not cause an error.

Typescript will evaluate the type to number | string in the example you gave. Even if someone does this in their code, you won't be able to use the type number | string as a number or string without casting at some point to a number or string. If you get a union type composed of two orthogonal types it's pre...

heavy crowBOT
heavy crowBOT
#

The Problem:
I'm attempting to create a bot using typescript. So far, I've basically been following the tutorial provided. When I try to register slash commands (either globally or per guild), I encounter the issue below:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in ...\node_modules\discord-api-types\package.json
    at new NodeError (node:internal/errors:371:5)
    at throwExportsNotFound (node:int...
heavy crowBOT
heavy crowBOT
#

Please describe the changes this PR makes and why it should be merged:

This allows users to mark media as spoilers before sending them to Discord's API. The motivation behind this is for convenience, as in, users not needing to place the SPOILER_ string.

You'll see a validation if the given argument is false, as it's possible to have the spoiler string inside the string itself, hence removing the title users would expect. I have adapted this from #6473 but I didn't make it an ...

heavy crowBOT
#

Please describe the problem you are having in as much detail as possible:
I was updating my bot's pfp and I had my bots console opened cuz I was updating it. Just when i updated the bot's pfp, the bot crashed giving out an error.

Error:

/home/container/node_modules/discord.js/src/client/actions/UserUpdate.js:11
    const oldUser = newUser._update(data);
                            ^

TypeError: Cannot read property '_update' of undefined
    at UserUpdateAction.hand...
heavy crowBOT
#

๐Ÿ‘ Completely break commando and any bots that use Structures properly.

Sounds a great plan to me :D

Commando is deprecated, and doesn't support V13, it is recommended that you use Sapphire instead.

As stated in the original description, they are impossible to maintain, unpredictable, and still can be easily implemented using databases. Using structures is a personal preference, and complicates support.

heavy crowBOT
#

Please describe the changes this PR makes and why it should be merged:

When the UserManager cache is disabled, updating the client user will result in a crash. The user update action gets the old state of the user via the UserManager cache, even if it's the client user. However, when it's disabled, nothing is being returned and so newUser._update throws a type error.

This fix makes the code get client.user if client.user.id and data.id are equal.

**Status and versioni...

#

๐Ÿ‘ Completely break commando and any bots that use Structures properly.

Sounds a great plan to me :D

Commando is deprecated and doesn't support V13, it is recommended that you use Sapphire instead.

As stated in the original description, they are impossible to maintain, unpredictable, and still can be easily implemented using databases. Using structures is a personal preference, and complicates support.

"Using structures is a personal preference" - BRUH...

#

I found somewhat of a better solution to the absence of the Structures class which works with typescript too.

import { Message, MessageEmbed } from "discord.js";
import { Xenus } from "..";

type ExtendedMessage = {
  embed: MessageEmbed;
  sm(content: string, specialType?: "err" | "base"): Promise<Message>;
} & Message;

function extendMessage(this: Xenus, message: Message): ExtendedMessage {
  const embed = new MessageEmbed().setTimestamp();
  const sm = (content: string...
heavy crowBOT
#

After deleting a channel using the bot, the desktop client (windows) still shows the channel in the side panel, but the channel was deleted, so it can't be accessed

Refreshing the client gets rid of the problem. I thought it was a problem on the client's side, but now that it passed years and the problem is still there, it signals me that there's something else

Recently I encountered this problem for voice channels, though probably it happens to text ones too. I have to mention that I c...

#

This reads very much like a client bug: The channel is actually gone and the client still shows it until reloading it.

You can report those in the Discord Testers Discord Server (I don't know if they are open again), or though the Bug form.
If it's an api bug, you can report it here: [discord/discord-api-docs#api-bug-report](https://github.com/discord/discord-api-docs/issues/new?assignees=&labels=bug&template=api-bug-report...

heavy crowBOT
#

Please describe the problem you are having in as much detail as possible:
.threadMembersUpdate has the possibility of emitting the same Collection for both the oldMembers & newMembers parameters.

This is achieved by the following:

  1. Join a thread
  2. Restart your bot to ensure reproducibility. Do not fetch active threads!
  3. Leave the thread

Upon leaving the thread, oldMembers and newMembers will emit the same Collection. Needless to say, this is quite......

heavy crowBOT
#

Please describe the changes this PR makes and why it should be merged:

This one is for @almostSouji. Can't post a screenshot of prof chat but y'all can find it there.

Status and versioning classification:

  • Code changes have been tested against the Discord API (by Souji, as far as I can tell), or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating
heavy crowBOT
#

i would personally go for this approach

const isSpoiler = this.name.startsWith("SPOILER_");
if (spoiler != isSpoiler) {
  if (spoiler) {
    this.name = `SPOILER_${this.name}`;
  } else {
    this.name = this.name.slice(8);
    // or
    this.name = this.name.replace(/^SPOILER_/, '');
  }
}
return this;

or at the least putting the this.name.startsWith(...); in a variable instead of calling it twice, and using an else if statement below

heavy crowBOT
#

This is a bit strange now. If a user runs .setSpoiler(), the attachment will be marked as a spoiler that is yet to be sent. If they decide to run the .spoiler getter to see if it's been marked as a spoiler, it'll throw an error because it's expecting a URL. Right now it's valid only for received messages... maybe it should be adjusted for to-be messages also?

Tbh it shouldโ€™ve been like that from the beginning, and itโ€™s as simple as adding ?? this.name inside the Util.basename call

heavy crowBOT
#

I'd argue that this suggestion's code feels hacky, and does the same steps.

  • If Snowflake -> Get ?Role -> permissionsFor(Role?)
  • Get Role -> If Role -> permissionsFor(Role)

Only difference is that permissionsFor(Snowflake)'s return type is nullable (because the case of invalid role IDs) whereas permissionsFor(Role) is not, so in the event when we rewrite to TypeScript, this would be one nullish assertion operator less.

Also, in the event Discord ever changes the `...

heavy crowBOT
heavy crowBOT
#

In Discord.js V12 it was possible to set an array of strings in an embed description or a message, this was very handy to keep the code clean instead of 1 crazy long string with \n to break.

Here is an example of the string array:

name: `โ€”โ€”โ€”โ€”โ€”โ€”[ Settings ]โ€”โ€”โ€”โ€”โ€”โ€”`,
value: [
        `${data.antiinvite ? '' : ''} | AntiInvite`,
        `${data.antistaffping ? '' : ''} | AntiStaffPing`,
        `${data.antispam.enabled ? '' : ''} | AntiSpam`,
        `${data.antiswear.enabled ? ...
#

Why can't you just do this?

[
  `${data.antiinvite ? '![On](https://cdn.discordapp.com/emojis/838758070632054814.webp?size=128 "On")' : '![Off](https://cdn.discordapp.com/emojis/838758070615146526.webp?size=128 "Off")'} | AntiInvite`,
  `${data.antistaffping ? '![On](https://cdn.discordapp.com/emojis/838758070632054814.webp?size=128 "On")' : '![Off](https://cdn.discordapp.com/emojis/838758070615146526.webp?size=128 "Off")'} | AntiStaffPing`,
  `${data.antispam.enabled ? '![On](https://cdn.discordapp.com/emojis/838758070632054814.webp?size=128 "On")' : '![Off](https://cdn.discordapp.com/emojis/838758070615146526.webp?size=128 "Off")'} | AntiSpam`,
  `${data.antiswear.enabled ? '![On](https://cdn.discordapp.com/emojis/838758070632054814.webp?size=128 "On")' : '![Off](https://cdn.discordapp.com/emojis/838758070615146526.webp?size=128 "Off")'} | AntiSwearing`,
  `${data.levelsystem ? '![On](https://cdn.discordapp.com/emojis/838758070632054814.webp?size=128 "On")...
heavy crowBOT
#

IIRC, discord sometimes reorders things, and reordered options / choices do not actually get taken into account.
I used for...of for two reasons

  1. return directly from the loop (its one less op too!)
  2. make it clear that the loop stops as soon as it hits a non-equal option
    Bonus 3. If for some reason any of the functions need to be async in the future, we don't need to rewrite the loop
heavy crowBOT
#

Hmm, it does take it into account, but not everything is deployed in the order provided (client side that is, API still has the correct order) E.g. subcommand groups are always displayed before subcommands on the same level.

Its hard to say which behavior would be more confusing given that. I imagine most people store the command definition somewhere in their code, but if you were to reconstruct a command from the way the client displayed it (again, you could just fetch it to be sure ...

heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT