discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.46k stars 3.97k forks source link

TypeError in GuildDeleteAction.handle when Destroying Voice Adapter #10299

Closed prineec closed 6 months ago

prineec commented 6 months ago

Which package is this bug report for?

discord.js

Issue description

When handling the 'guildDelete' event in a Discord bot using Discord.js, a TypeError occurs in the GuildDeleteAction.handle method. The error arises when attempting to destroy the voice adapter associated with the guild. This happens because the client.voice.adapters object is either undefined or lacks the get method.

path: F:\xyz\node_modules\discord.js\src\client\actions\GuildDelete.js

Error Stack:

TypeError: Cannot read properties of undefined (reading 'get')
    at GuildDeleteAction.handle (/home/ubuntu/node_modules/discord.js/src/client/actions/GuildDelete.js:29:29)
    at module.exports [as GUILD_DELETE] (/home/ubuntu/node_modules/discord.js/src/client/websocket/handlers/GUILD_DELETE.js:4:30)
    at WebSocketManager.handlePacket (/home/ubuntu/node_modules/discord.js/src/client/websocket/WebSocketManager.js:353:31)
    at WebSocketManager.<anonymous> (/home/ubuntu/node_modules/discord.js/src/client/websocket/WebSocketManager.js:237:12)
    at WebSocketManager.emit (/home/ubuntu/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:282:31)
    at WebSocketShard.<anonymous> (/home/ubuntu/node_modules/@discordjs/ws/dist/index.js:1103:51)
    at WebSocketShard.emit (/home/ubuntu/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:282:31)
    at WebSocketShard.onMessage (/home/ubuntu/node_modules/@discordjs/ws/dist/index.js:938:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

basically you guys missed a ?. in very short Skill Issue.

Code sample

'use strict';

const Action = require('./Action');
const Events = require('../../util/Events');

class GuildDeleteAction extends Action {
  handle(data) {
    const client = this.client;

    let guild = client.guilds.cache.get(data.id);
    if (guild) {
      if (data.unavailable) {
        // Guild is unavailable
        guild.available = false;

        /**
         * Emitted whenever a guild becomes unavailable, likely due to a server outage.
         * @event Client#guildUnavailable
         * @param {Guild} guild The guild that has become unavailable
         */
        client.emit(Events.GuildUnavailable, guild);

        // Stops the GuildDelete packet thinking a guild was actually deleted,
        // handles emitting of event itself
        return;
      }

      for (const channel of guild.channels.cache.values()) this.client.channels._remove(channel.id);

      // Destroy the voice adapter associated with the guild if it exists
      client.voice.adapters?.get(data.id)?.destroy();

      // Delete guild
      client.guilds.cache.delete(guild.id);

      /**
       * Emitted whenever a guild kicks the client or the guild is deleted/left.
       * @event Client#guildDelete
       * @param {Guild} guild The guild that was deleted
       */
      client.emit(Events.GuildDelete, guild);
    }
  }
}

module.exports = GuildDeleteAction;

Versions

discord.js above v14.12.0, node.js version: v20.13.1, windows 11

Issue priority

Medium (should be fixed soon)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

Guilds

I have tested this issue on a development release

No response

Jiralite commented 6 months ago

I do not see how this is possible. It is instantiated with the property:

https://github.com/discordjs/discord.js/blob/a468ae8bb5a9de9cb34d40493c59693e84c2812a/packages/discord.js/src/client/Client.js#L99

ClientVoiceManager is also instantiated with the property:

https://github.com/discordjs/discord.js/blob/a468ae8bb5a9de9cb34d40493c59693e84c2812a/packages/discord.js/src/client/voice/ClientVoiceManager.js#L22

We should have a lot of reports regarding this since 14.12.0 (the version you claim), but there are none.

Are you modifying internal behaviour? Can you share a reproducible sample?

Qjuh commented 6 months ago

I‘d wager a guess and assume you do have client.voice = … somewhere in your code, overwriting the ClientVoiceManager in the process.

prineec commented 6 months ago

I‘d wager a guess and assume you do have client.voice = … somewhere in your code, overwriting the ClientVoiceManager in the process.

no man

Qjuh commented 6 months ago

I‘d wager a guess and assume you do have client.voice = … somewhere in your code, overwriting the ClientVoiceManager in the process.

no man

Easy to find out: console.log(client) and show the result at the point in time the error would/could occur

prineec commented 6 months ago

I‘d wager a guess and assume you do have client.voice = … somewhere in your code, overwriting the ClientVoiceManager in the process.

no man

Easy to find out: console.log(client) and show the result at the point in time the error would/could occur

no trace of client.voice

Qjuh commented 6 months ago

Let’s make this short then: either show an actual reproducible code sample showing the issue, show the actual log output of that console.log or (if you choose to be non-cooperative) this doesn’t look like a library issue.

prineec commented 6 months ago

Let’s make this short then: either show an actual reproducible code sample showing the issue, show the actual log output of that console.log or (if you choose to be non-cooperative) this doesn’t look like a library issue.

<ref *1> Bumblebee {
  _events: [Object: null prototype] {
    shardDisconnect: [Function (anonymous)],
    ready: [ [AsyncFunction (anonymous)], [Function (anonymous)] ],
    messageCreate: [
      [AsyncFunction (anonymous)],
      [AsyncFunction (anonymous)],
      [AsyncFunction (anonymous)],
      [AsyncFunction (anonymous)],
      [AsyncFunction (anonymous)],
      [AsyncFunction (anonymous)],
      [AsyncFunction (anonymous)],
      [AsyncFunction (anonymous)]
    ],
    guildMemberAdd: [AsyncFunction (anonymous)],
    error: [Function (anonymous)],
    guildCreate: [AsyncFunction (anonymous)],
    guildDelete: [AsyncFunction (anonymous)],
    voiceStateUpdate: [ [AsyncFunction (anonymous)], [AsyncFunction (anonymous)] ],
    interactionCreate: [
      [AsyncFunction (anonymous)],
      [AsyncFunction (anonymous)],
      [AsyncFunction (anonymous)],
      [AsyncFunction (anonymous)]
    ],
    guildMemberUpdate: [AsyncFunction (anonymous)],
    channelDelete: [AsyncFunction (anonymous)]
  },
  _eventsCount: 11,
  _maxListeners: undefined,
  options: {
    closeTimeout: 5000,
    waitGuildTimeout: 15000,
    shardCount: 1,
    makeCache: [Function (anonymous)],
    partials: [ 2, 0, 3, 1, 4, 5 ],
    failIfNotExists: true,
    presence: {
      activities: [Array],
      status: 'idle',
      restRequestTimeout: 20000,
      user: [Object]
    },
    sweepers: { threads: [Object], messages: [Object] },
    ws: { large_threshold: 50, version: 10, presence: [Object] },
    rest: {
      agent: null,
      api: 'https://discord.com/api',
      authPrefix: 'Bot',
      cdn: 'https://cdn.discordapp.com',
      headers: {},
      invalidRequestWarningInterval: 0,
      globalRequestsPerSecond: 50,
      offset: 50,
      rejectOnRateLimit: null,
      retries: 3,
      timeout: 15000,
      userAgentAppendix: 'discord.js/14.15.2 Node.js/20.13.1',
      version: '10',
      hashSweepInterval: 14400000,
      hashLifetime: 86400000,
      handlerSweepInterval: 3600000,
      makeRequest: [AsyncFunction: makeRequest]
    },
    jsonTransformer: [Function: toSnakeCase],
    shards: [ 0 ],
    restTimeOffset: 2500,
    disableMentions: [ 'everyone', 'here' ],
    debugger: true,
    intents: IntentsBitField { bitfield: 33519 }
  },
  rest: REST {
    _events: [Object: null prototype] {},
    _eventCount: 0,
    _maxListeners: 10,
    _internalPromiseMap: Map(0) {},
    _wrapperId: 0n,
    agent: null,
    cdn: CDN { base: 'https://cdn.discordapp.com' },
    globalRemaining: 48,
    globalDelay: null,
    globalReset: 1716630705074,
    hashes: Collection(3) [Map] {
      'GET:/gateway/bot' => [Object],
      'GET:/guilds/:id/channels' => [Object],
      'GET:/applications/@me' => [Object]
    },
    handlers: Collection(3) [Map] {
      'Global(GET:/gateway/bot):global' => [SequentialHandler],
      'Global(GET:/applications/@me):global' => [SequentialHandler],
      'Global(GET:/guilds/:id/channels):718743348818739212' => [SequentialHandler]
    },
    hashTimer: Timeout {
      _idleTimeout: 14400000,
      _idlePrev: [Timeout],
      _idleNext: [TimersList],
      _idleStart: 569,
      _onTimeout: [Function (anonymous)],
      _timerArgs: undefined,
      _repeat: 14400000,
      _destroyed: false,
      [Symbol(refed)]: false,
      [Symbol(kHasPrimitive)]: false,
      [Symbol(asyncId)]: 5,
      [Symbol(triggerId)]: 2
    },
    handlerTimer: Timeout {
      _idleTimeout: 3600000,
      _idlePrev: [Timeout],
      _idleNext: [TimersList],
      _idleStart: 569,
      _onTimeout: [Function (anonymous)],
      _timerArgs: undefined,
      _repeat: 3600000,
      _destroyed: false,
      [Symbol(refed)]: false,
      [Symbol(kHasPrimitive)]: false,
      [Symbol(asyncId)]: 6,
      [Symbol(triggerId)]: 2
    },
    options: {
      agent: null,
      api: 'https://discord.com/api',
      authPrefix: 'Bot',
      cdn: 'https://cdn.discordapp.com',
      headers: {},
      invalidRequestWarningInterval: 0,
      globalRequestsPerSecond: 50,
      offset: 50,
      rejectOnRateLimit: null,
      retries: 3,
      timeout: 15000,
      userAgentAppendix: 'discord.js/14.15.2 Node.js/20.13.1',
      version: '10',
      hashSweepInterval: 14400000,
      hashLifetime: 86400000,
      handlerSweepInterval: 3600000,
      makeRequest: [AsyncFunction: makeRequest]
    }
  },
  ws: WebSocketManager {
    _events: [Object: null prototype] {},
    _eventsCount: 0,
    _maxListeners: undefined,
    gateway: 'wss://gateway.discord.gg/',
    shards: Collection(1) [Map] { 0 => [WebSocketShard] },
    status: 0,
    destroyed: false,
    _ws: WebSocketManager {
      _events: [Object: null prototype],
      _eventCount: 8,
      _maxListeners: 10,
      _internalPromiseMap: Map(0) {},
      _wrapperId: 0n,
      options: [Object],
      gatewayInformation: [Object],
      shardIds: [Array],
      strategy: [SimpleShardingStrategy]
    },
    totalShards: 1,
    [Symbol(shapeMode)]: false,
    [Symbol(kCapture)]: false
  },
  actions: ActionsManager {
    injectedUser: Symbol(djs.actions.injectedUser),
    injectedChannel: Symbol(djs.actions.injectedChannel),
    injectedMessage: Symbol(djs.actions.injectedMessage),
    client: [Circular *1],
    ApplicationCommandPermissionsUpdate: ApplicationCommandPermissionsUpdateAction { client: [Circular *1] },
    AutoModerationActionExecution: AutoModerationActionExecutionAction { client: [Circular *1] },
    AutoModerationRuleCreate: AutoModerationRuleCreateAction { client: [Circular *1] },
    AutoModerationRuleDelete: AutoModerationRuleDeleteAction { client: [Circular *1] },
    AutoModerationRuleUpdate: AutoModerationRuleUpdateAction { client: [Circular *1] },
    ChannelCreate: ChannelCreateAction { client: [Circular *1] },
    ChannelDelete: ChannelDeleteAction { client: [Circular *1] },
    ChannelUpdate: ChannelUpdateAction { client: [Circular *1] },
    EntitlementCreate: EntitlementCreateAction { client: [Circular *1] },
    EntitlementDelete: EntitlementDeleteAction { client: [Circular *1] },
    EntitlementUpdate: EntitlementUpdateAction { client: [Circular *1] },
    GuildAuditLogEntryCreate: GuildAuditLogEntryCreateAction { client: [Circular *1] },
    GuildBanAdd: GuildBanAdd { client: [Circular *1] },
    GuildBanRemove: GuildBanRemove { client: [Circular *1] },
    GuildChannelsPositionUpdate: GuildChannelsPositionUpdate { client: [Circular *1] },
    GuildDelete: GuildDeleteAction { client: [Circular *1] },
    GuildEmojiCreate: GuildEmojiCreateAction { client: [Circular *1] },
    GuildEmojiDelete: GuildEmojiDeleteAction { client: [Circular *1] },
    GuildEmojiUpdate: GuildEmojiUpdateAction { client: [Circular *1] },
    GuildEmojisUpdate: GuildEmojisUpdateAction { client: [Circular *1] },
    GuildIntegrationsUpdate: GuildIntegrationsUpdate { client: [Circular *1] },
    GuildMemberRemove: GuildMemberRemoveAction { client: [Circular *1] },
    GuildMemberUpdate: GuildMemberUpdateAction { client: [Circular *1] },
    GuildRoleCreate: GuildRoleCreate { client: [Circular *1] },
    GuildRoleDelete: GuildRoleDeleteAction { client: [Circular *1] },
    GuildRoleUpdate: GuildRoleUpdateAction { client: [Circular *1] },
    GuildRolesPositionUpdate: GuildRolesPositionUpdate { client: [Circular *1] },
    GuildScheduledEventCreate: GuildScheduledEventCreateAction { client: [Circular *1] },
    GuildScheduledEventDelete: GuildScheduledEventDeleteAction { client: [Circular *1] },
    GuildScheduledEventUpdate: GuildScheduledEventUpdateAction { client: [Circular *1] },
    GuildScheduledEventUserAdd: GuildScheduledEventUserAddAction { client: [Circular *1] },
    GuildScheduledEventUserRemove: GuildScheduledEventUserRemoveAction { client: [Circular *1] },
    GuildStickerCreate: GuildStickerCreateAction { client: [Circular *1] },
    GuildStickerDelete: GuildStickerDeleteAction { client: [Circular *1] },
    GuildStickerUpdate: GuildStickerUpdateAction { client: [Circular *1] },
    GuildStickersUpdate: GuildStickersUpdateAction { client: [Circular *1] },
    GuildUpdate: GuildUpdateAction { client: [Circular *1] },
    InteractionCreate: InteractionCreateAction { client: [Circular *1] },
    InviteCreate: InviteCreateAction { client: [Circular *1] },
    InviteDelete: InviteDeleteAction { client: [Circular *1] },
    MessageCreate: MessageCreateAction { client: [Circular *1] },
    MessageDelete: MessageDeleteAction { client: [Circular *1] },
    MessageDeleteBulk: MessageDeleteBulkAction { client: [Circular *1] },
    MessagePollVoteAdd: MessagePollVoteAddAction { client: [Circular *1] },
    MessagePollVoteRemove: MessagePollVoteRemoveAction { client: [Circular *1] },
    MessageReactionAdd: MessageReactionAdd { client: [Circular *1] },
    MessageReactionRemove: MessageReactionRemove { client: [Circular *1] },
    MessageReactionRemoveAll: MessageReactionRemoveAll { client: [Circular *1] },
    MessageReactionRemoveEmoji: MessageReactionRemoveEmoji { client: [Circular *1] },
    MessageUpdate: MessageUpdateAction { client: [Circular *1] },
    PresenceUpdate: PresenceUpdateAction { client: [Circular *1] },
    StageInstanceCreate: StageInstanceCreateAction { client: [Circular *1] },
    StageInstanceDelete: StageInstanceDeleteAction { client: [Circular *1] },
    StageInstanceUpdate: StageInstanceUpdateAction { client: [Circular *1] },
    ThreadCreate: ThreadCreateAction { client: [Circular *1] },
    ThreadDelete: ThreadDeleteAction { client: [Circular *1] },
    ThreadListSync: ThreadListSyncAction { client: [Circular *1] },
    ThreadMemberUpdate: ThreadMemberUpdateAction { client: [Circular *1] },
    ThreadMembersUpdate: ThreadMembersUpdateAction { client: [Circular *1] },
    TypingStart: TypingStart { client: [Circular *1] },
    UserUpdate: UserUpdateAction { client: [Circular *1] },
    VoiceStateUpdate: VoiceStateUpdate { client: [Circular *1] },
    WebhooksUpdate: WebhooksUpdate { client: [Circular *1] }
  },
  voice: ClientVoiceManager { adapters: Map(0) {} },
  shard: null,
  users: UserManager {},
  guilds: GuildManager {},
  channels: ChannelManager {},
  sweepers: Sweepers {
    options: { threads: [Object], messages: [Object] },
    intervals: {
      autoModerationRules: null,
      applicationCommands: null,
      bans: null,
      emojis: null,
      entitlements: null,
      invites: null,
      guildMembers: null,
      messages: Timeout {
        _idleTimeout: 2000,
        _idlePrev: [TimersList],
        _idleNext: [TimersList],
        _idleStart: 600,
        _onTimeout: [Function (anonymous)],
        _timerArgs: undefined,
        _repeat: 2000,
        _destroyed: false,
        [Symbol(refed)]: false,
        [Symbol(kHasPrimitive)]: false,
        [Symbol(asyncId)]: 7,
        [Symbol(triggerId)]: 2
      },
      presences: null,
      reactions: null,
      stageInstances: null,
      stickers: null,
      threadMembers: null,
      threads: Timeout {
        _idleTimeout: 3600000,
        _idlePrev: [Timeout],
        _idleNext: [Timeout],
        _idleStart: 600,
        _onTimeout: [Function (anonymous)],
        _timerArgs: undefined,
        _repeat: 3600000,
        _destroyed: false,
        [Symbol(refed)]: false,
        [Symbol(kHasPrimitive)]: false,
        [Symbol(asyncId)]: 8,
        [Symbol(triggerId)]: 2
      },
      users: null,
      voiceStates: null
    }
  },
  presence: ClientPresence {
    userId: null,
    guild: null,
    status: 'idle',
    activities: [ [Activity] ],
    clientStatus: null
  },
  user: ClientUser {
    id: '1232384723188449283',
    bot: true,
    system: false,
    flags: UserFlagsBitField { bitfield: 0 },
    username: 'Bumblebee',
    globalName: null,
    discriminator: '6031',
    avatar: '2b6933b3512c134b027e30eb81a48eec',
    banner: '18ef52ed05ff6200b3c9e3a8f8c547d2',
    accentColor: null,
    avatarDecoration: null,
    verified: true,
    mfaEnabled: true
  },
  application: ClientApplication {
    id: '1232384723188449283',
    name: 'Bumblebee',
    description: 'A Multipurpose Discord Bot, focused on Automoderation, Autorole, Voice-Roles, Temp-Voice, Moderation, Media Channels, Fun and Utility.',
    icon: '2b6933b3512c134b027e30eb81a48eec',
    tags: [
      'Auto Moderation',
      'Moderation',
      'TempChannels',
      'Auto Roles',
      'Voice Roles'
    ],
    installParams: null,
    customInstallURL: 'https://discord.com/oauth2/authorize?client_id=1232384723188449283&permissions=8&response_type=code&redirect_uri=https%3A%2F%2Fdiscord.com%2Finvite%2Fm5UHp3abHW&scope=applications.commands+guilds+bot',
    flags: ApplicationFlagsBitField { bitfield: 10764288 },
    approximateGuildCount: 62,
    guildId: '1232390454683893841',
    cover: null,
    rpcOrigins: [],
    botRequireCodeGrant: false,
    bot: ClientUser {
      id: '1232384723188449283',
      bot: true,
      system: false,
      flags: [UserFlagsBitField],
      username: 'Bumblebee',
      globalName: null,
      discriminator: '6031',
      avatar: '2b6933b3512c134b027e30eb81a48eec',
      banner: '18ef52ed05ff6200b3c9e3a8f8c547d2',
      accentColor: null,
      avatarDecoration: null,
      verified: true,
      mfaEnabled: true
    },
    botPublic: true,
    interactionsEndpointURL: null,
    roleConnectionsVerificationURL: null,
    owner: Team {
      id: '1234832667392868468',
      name: 'Bumblebee',
      icon: '2b6933b3512c134b027e30eb81a48eec',
      ownerId: '1156173961034465333',
      members: [Collection [Map]]
    },
    commands: ApplicationCommandManager {
      permissions: [ApplicationCommandPermissionsManager]
    },
    entitlements: EntitlementManager {}
  },
  readyTimestamp: 1716630703782,
  welcome: Database {
    name: './database/welcome.sqlite',
    open: true,
    inTransaction: false,
    readonly: false,
    memory: false
  },
  perk: Database {
    name: './database/perk.sqlite',
    open: true,
    inTransaction: false,
    readonly: false,
    memory: false
  },
  guild: Database {
    name: './database/guild.sqlite',
    open: true,
    inTransaction: false,
    readonly: false,
    memory: false
  },
  ignore: Database {
    name: './database/ignore.sqlite',
    open: true,
    inTransaction: false,
    readonly: false,
    memory: false
  },
  extra: Database {
    name: './database/extra.sqlite',
    open: true,
    inTransaction: false,
    readonly: false,
    memory: false
  },
  invc: QuickDB {
    prepared: Promise { undefined },
    _driver: SqliteDriver { _database: [Database] },
    tableName: 'json',
    normalKeys: false,
    options: {
      filePath: './database/invc.sqlite',
      table: 'json',
      driver: [SqliteDriver],
      normalKeys: false
    }
  },
  people: Database {
    name: './database/users.sqlite',
    open: true,
    inTransaction: false,
    readonly: false,
    memory: false
  },
  media: Database {
    name: './database/media.sqlite',
    open: true,
    inTransaction: false,
    readonly: false,
    memory: false
  },
  night: Database {
    name: './database/night.sqlite',
    open: true,
    inTransaction: false,
    readonly: false,
    memory: false
  },
  vc: Database {
    name: './database/voice.sqlite',
    open: true,
    inTransaction: false,
    readonly: false,
    memory: false
  },
  ticket: QuickDB {
    prepared: Promise { undefined },
    _driver: SqliteDriver { _database: [Database] },
    tableName: 'json',
    normalKeys: false,
    options: {
      filePath: './database/ticket.sqlite',
      table: 'json',
      driver: [SqliteDriver],
      normalKeys: false
    }
  },
  automod: Database {
    name: './database/automod.sqlite',
    open: true,
    inTransaction: false,
    readonly: false,
    memory: false
  },
  test: Database {
    name: './database/test.db',
    open: true,
    inTransaction: false,
    readonly: false,
    memory: false
  },
  commands: Collection(53) [Map] {
    'antibot' => {
      name: 'antibot',
      UserPerms: [Array],
      BotPerms: [Array],
      voteOnly: true,
      aboveRole: true,
      run: [AsyncFunction: run]
    },
    'automod' => {
      name: 'automod',
      aliases: [Array],
      userPerms: [Array],
      botPerms: [Array],
      aboveRole: true,
      voteOnly: true,
      run: [AsyncFunction: run]
    },
    'nightmode' => {
      name: 'nightmode',
      UserPerms: [Array],
      BotPerms: [Array],
      voteOnly: true,
      aboveRole: true,
      run: [AsyncFunction: run]
    },
    'clear' => {
      name: 'clear',
      aliases: [Array],
      UserPerms: [Array],
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'hide' => {
      name: 'hide',
      UserPerms: [Array],
      BotPerms: [Array],
      voteOnly: false,
      run: [AsyncFunction: run]
    },
    'hideall' => {
      name: 'hideall',
      UserPerms: [Array],
      BotPerms: [Array],
      voteOnly: true,
      run: [AsyncFunction: run]
    },
    'list' => { name: 'list', run: [AsyncFunction: run] },
    'lock' => {
      name: 'lock',
      UserPerms: [Array],
      BotPerms: [Array],
      voteOnly: false,
      run: [AsyncFunction: run]
    },
    'lockall' => {
      name: 'lockall',
      UserPerms: [Array],
      BotPerms: [Array],
      voteOnly: true,
      run: [AsyncFunction: run]
    },
    'prefix' => {
      name: 'prefix',
      aliases: [Array],
      UserPerms: [Array],
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'steal' => {
      name: 'steal',
      description: 'Add Emoji',
      usage: 'add <emoji>',
      UserPerms: [Array],
      BotPerms: [Array],
      VoteOnly: true,
      run: [AsyncFunction: run]
    },
    'stealall' => {
      name: 'stealall',
      UserPerms: [Array],
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'sticker' => {
      name: 'sticker',
      UserPerms: [Array],
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'unhide' => {
      name: 'unhide',
      UserPerms: [Array],
      BotPerms: [Array],
      voteOnly: false,
      run: [AsyncFunction: run]
    },
    'unhideall' => {
      name: 'unhideall',
      UserPerms: [Array],
      BotPerms: [Array],
      voteOnly: true,
      run: [AsyncFunction: run]
    },
    'unlock' => {
      name: 'unlock',
      UserPerms: [Array],
      BotPerms: [Array],
      voteOnly: false,
      run: [AsyncFunction: run]
    },
    'unlockall' => {
      name: 'unlockall',
      UserPerms: [Array],
      BotPerms: [Array],
      voteOnly: true,
      run: [AsyncFunction: run]
    },
    'voice' => {
      name: 'voice',
      voteOnly: false,
      UserPerms: [Array],
      BotPerms: [Array],
      aliases: [Array],
      run: [AsyncFunction: run]
    },
    'backup' => { name: 'backup', run: [AsyncFunction: run] },
    'badge' => {
      name: 'badge',
      aliases: [Array],
      voteOnly: false,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'blacklist' => {
      name: 'blacklist',
      aliases: [Array],
      voteOnly: false,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'debug' => { name: 'debug', run: [AsyncFunction: run] },
    'eval' => {
      name: 'eval',
      voteOnly: false,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'noprefix' => {
      name: 'noprefix',
      aliases: [Array],
      voteOnly: false,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'serverlist' => {
      name: 'serverlist',
      aliases: [Array],
      VoteOnly: true,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'extra' => { name: 'extra', voteOnly: true, run: [AsyncFunction: run] },
    'ignore' => {
      name: 'ignore',
      voteOnly: true,
      UserPerms: [Array],
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'media' => {
      name: 'media',
      voteOnly: true,
      UserPerms: [Array],
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    '8ball' => {
      name: '8ball',
      description: 'Tells you a fortune',
      run: [AsyncFunction: run]
    },
    'afk' => { name: 'afk', voteOnly: false, run: [AsyncFunction: run] },
    'avatar' => {
      name: 'avatar',
      aliases: [Array],
      voteOnly: false,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'boostcount' => {
      name: 'boostcount',
      aliases: [Array],
      voteOnly: false,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'info' => {
      name: 'info',
      aliases: [Array],
      voteOnly: false,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'channelcount' => {
      name: 'channelcount',
      aliases: [Array],
      voteOnly: false,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'documentation' => {
      name: 'documentation',
      aliases: [Array],
      voteOnly: false,
      run: [AsyncFunction: run]
    },
    'embed' => {
      name: 'embed',
      UserPerms: [Array],
      BotPerms: [Array],
      VoteOnly: true,
      run: [AsyncFunction: run]
    },
    'emojicount' => {
      name: 'emojicount',
      aliases: [Array],
      voteOnly: false,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'help' => {
      name: 'help',
      aliases: [Array],
      BotPerms: [Array],
      voteOnly: false,
      run: [AsyncFunction: run]
    },
    'membercount' => {
      name: 'membercount',
      aliases: [Array],
      voteOnly: false,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'ping' => { name: 'ping', voteOnly: false, run: [AsyncFunction: run] },
    'premium' => {
      name: 'premium',
      voteOnly: false,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'privacy' => {
      name: 'privacy',
      aliases: [Array],
      voteOnly: false,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'rolecount' => {
      name: 'rolecount',
      aliases: [Array],
      voteOnly: false,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'stats' => {
      name: 'stats',
      aliases: [Array],
      voteOnly: false,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'support' => { name: 'support', voteOnly: false, run: [AsyncFunction: run] },
    'terms' => {
      name: 'terms',
      voteOnly: false,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'uptime' => {
      name: 'uptime',
      aliases: [Array],
      voteOnly: false,
      run: [AsyncFunction: run]
    },
    'userinfo' => {
      name: 'userinfo',
      aliases: [Array],
      voteOnly: false,
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'vote' => { name: 'vote', voteOnly: false, run: [AsyncFunction: run] },
    'website' => {
      name: 'website',
      aliases: [Array],
      voteOnly: false,
      run: [AsyncFunction: run]
    },
    'invc' => {
      name: 'invc',
      voteOnly: true,
      UserPerms: [Array],
      BotPerms: [Array],
      aboveRole: true,
      run: [AsyncFunction: run]
    },
    'tempvoice' => {
      name: 'tempvoice',
      aliases: [Array],
      UserPerms: [Array],
      BotPerms: [Array],
      run: [AsyncFunction: run]
    },
    'autorole' => {
      name: 'autorole',
      voteOnly: true,
      UserPerms: [Array],
      BotPerms: [Array],
      aboveRole: true,
      run: [AsyncFunction: run]
    }
  },
  aliases: Collection(37) [Map] {
    'am' => 'automod',
    'c' => 'clear',
    'purge' => 'clear',
    'prune' => 'clear',
    'customprefix' => 'prefix',
    'vc' => 'voice',
    'badges' => 'badge',
    'bg' => 'badge',
    'b' => 'badge',
    'pr' => 'badge',
    'profile' => 'badge',
    'bl' => 'blacklist',
    'np' => 'noprefix',
    'srlist' => 'serverlist',
    'av' => 'avatar',
    'pfp' => 'avatar',
    'pic' => 'avatar',
    'bc' => 'boostcount',
    'botinfo' => 'info',
    'bi' => 'info',
    'rogueinfo' => 'info',
    'cc' => 'channelcount',
    'docs' => 'documentation',
    'ec' => 'emojicount',
    'h' => 'help',
    'mc' => 'membercount',
    'policy' => 'privacy',
    'rc' => 'rolecount',
    'botstats' => 'stats',
    'botstatus' => 'stats',
    'st' => 'stats',
    'up' => 'uptime',
    'whois' => 'userinfo',
    'user' => 'userinfo',
    'ui' => 'userinfo',
    'web' => 'website',
    'tv' => 'tempvoice'
  },
  events: Collection(0) [Map] {},
  slashCommands: Collection(23) [Map] {
    'antibot' => {
      data: [SlashCommandBuilder],
      voteOnly: true,
      UserPerms: [Array],
      BotPerms: [Array],
      aboveRole: true,
      execute: [AsyncFunction: execute]
    },
    'automod' => {
      data: [SlashCommandBuilder],
      voteOnly: true,
      UserPerms: [Array],
      BotPerms: [Array],
      aboveRole: true,
      execute: [AsyncFunction: execute]
    },
    'nightmode' => {
      data: [SlashCommandBuilder],
      voteOnly: true,
      UserPerms: [Array],
      BotPerms: [Array],
      aboveRole: true,
      execute: [AsyncFunction: execute]
    },
    'extra' => {
      data: [SlashCommandBuilder],
      voteOnly: true,
      execute: [AsyncFunction: execute]
    },
    'ignore' => {
      data: [SlashCommandBuilder],
      voteOnly: true,
      UserPerms: [Array],
      BotPerms: [Array],
      execute: [AsyncFunction: execute]
    },
    'media' => {
      data: [SlashCommandBuilder],
      voteOnly: true,
      UserPerms: [Array],
      BotPerms: [Array],
      execute: [AsyncFunction: execute]
    },
    'profile' => {
      data: [SlashCommandBuilder],
      voteOnly: false,
      execute: [AsyncFunction: execute]
    },
    'boostcount' => {
      data: [Object],
      voteOnly: false,
      BotPerms: [Array],
      execute: [AsyncFunction: execute]
    },
    'channelcount' => {
      data: [SlashCommandBuilder],
      voteOnly: false,
      BotPerms: [Array],
      execute: [AsyncFunction: execute]
    },
    'documentation' => {
      data: [SlashCommandBuilder],
      voteOnly: false,
      execute: [AsyncFunction: execute]
    },
    'emojicount' => {
      data: [SlashCommandBuilder],
      voteOnly: false,
      BotPerms: [Array],
      execute: [AsyncFunction: execute]
    },
    'help' => {
      data: [SlashCommandBuilder],
      voteOnly: false,
      BotPerms: [Array],
      execute: [AsyncFunction: execute]
    },
    'membercount' => {
      data: [SlashCommandBuilder],
      voteOnly: false,
      BotPerms: [Array],
      execute: [AsyncFunction: execute]
    },
    'ping' => {
      data: [SlashCommandBuilder],
      voteOnly: false,
      execute: [AsyncFunction: execute]
    },
    'prefix' => {
      data: [SlashCommandBuilder],
      voteOnly: false,
      UserPerms: [Array],
      BotPerms: [Array],
      execute: [AsyncFunction: execute]
    },
    'rolecount' => {
      data: [SlashCommandBuilder],
      voteOnly: false,
      BotPerms: [Array],
      execute: [AsyncFunction: execute]
    },
    'support' => {
      data: [SlashCommandBuilder],
      voteOnly: false,
      execute: [AsyncFunction: execute]
    },
    'uptime' => {
      data: [SlashCommandBuilder],
      voteOnly: false,
      execute: [AsyncFunction: execute]
    },
    'vote' => {
      data: [SlashCommandBuilder],
      voteOnly: false,
      execute: [AsyncFunction: execute]
    },
    'website' => {
      data: [SlashCommandBuilder],
      voteOnly: false,
      execute: [AsyncFunction: execute]
    },
    'invc' => {
      data: [SlashCommandBuilder],
      voteOnly: true,
      UserPerms: [Array],
      BotPerms: [Array],
      execute: [AsyncFunction: execute]
    },
    'tempvoice' => {
      data: [SlashCommandBuilder],
      voteOnly: true,
      UserPerms: [Array],
      BotPerms: [Array],
      execute: [AsyncFunction: execute]
    },
    'autorole' => {
      data: [SlashCommandBuilder],
      voteOnly: true,
      execute: [AsyncFunction: execute]
    }
  },
  categories: [
    'automod',
    'moderation',
    'owner',
    'server',
    'utility',
    'voice master',
    'welcome'
  ],
  cluster: <ref *2> ClusterClient {
    _events: [Object: null prototype] {},
    _eventsCount: 0,
    _maxListeners: undefined,
    client: [Circular *1],
    mode: 'worker',
    queue: { mode: 'manual' },
    maintenance: false,
    ready: false,
    process: WorkerClient { ipc: [MessagePort [EventTarget]] },
    messageHandler: ClusterClientHandler { client: [Circular *2], ipc: [WorkerClient] },
    promise: PromiseHandler { nonce: Map(0) {} },
    [Symbol(shapeMode)]: false,
    [Symbol(kCapture)]: false
  },
  color: '#ffb504',
  error: 'https://media.discordapp.net/attachments/1232058051251667075/1232058078502064258/copyright-fail.png?ex=66281300&is=6626c180&hm=4559627766447e7fadbb968d37cde92a740350be0bfce8b33ff0b9bde4178695&=&format=webp&quality=lossless&width=1440&height=95',
  okay: 'https://media.discordapp.net/attachments/1232058051251667075/1232058087364366366/copyright-success.png?ex=66281302&is=6626c182&hm=1c999cc0abd3f0f582c74c3e72e36b335fcae350f4820c0d246c00b5467b6bb0&=&format=webp&quality=lossless&width=1440&height=95',
  website: 'https://bumblebeebot.netlify.app/',
  email: 'support@bumblebeebot.xyz',
  support: 'https://discord.com/invite/m5UHp3abHW',
  donate: 'https://bumblebeebot.netlify.app/donate/',
  sponsor: 'https://hydra-hosting.eu/',
  [Symbol(shapeMode)]: false,
  [Symbol(kCapture)]: true
}
Qjuh commented 6 months ago

voice: ClientVoiceManager { adapters: Map(0) {} }, what‘s this then? Looks perfectly fine

prineec commented 6 months ago

voice: ClientVoiceManager { adapters: Map(0) {} }, what‘s this then? Looks perfectly fine

idk man whenever my bot leaves a guild it throws this error:

TypeError: Cannot read properties of undefined (reading 'get')
    at GuildDeleteAction.handle (/home/ubuntu/node_modules/discord.js/src/client/actions/GuildDelete.js:29:29)
    at module.exports [as GUILD_DELETE] (/home/ubuntu/node_modules/discord.js/src/client/websocket/handlers/GUILD_DELETE.js:4:30)
    at WebSocketManager.handlePacket (/home/ubuntu/node_modules/discord.js/src/client/websocket/WebSocketManager.js:353:31)
    at WebSocketManager.<anonymous> (/home/ubuntu/node_modules/discord.js/src/client/websocket/WebSocketManager.js:237:12)
    at WebSocketManager.emit (/home/ubuntu/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:282:31)
    at WebSocketShard.<anonymous> (/home/ubuntu/node_modules/@discordjs/ws/dist/index.js:1103:51)
    at WebSocketShard.emit (/home/ubuntu/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:282:31)
    at WebSocketShard.onMessage (/home/ubuntu/node_modules/@discordjs/ws/dist/index.js:938:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Qjuh commented 6 months ago

Then there‘s probably something reassigning the <Client>.voice property. Seeing you have a custom client class and use third party libraries for sharding etc. I would start looking in there. Join the Discord support server if you want help with that.

prineec commented 6 months ago

Then there‘s probably something reassigning the <Client>.voice property. Seeing you have a custom client class and use third party libraries for sharding etc. I would start looking in there. Join the Discord support server if you want help with that.

const { Client, Partials, ActivityType, GatewayIntentBits, Options } = require('discord.js');
const { getInfo } = require('discord-hybrid-sharding');

module.exports = class Bumblebee extends Client {
    constructor() {
        super({
            shards: getInfo().SHARD_LIST,
            shardCount: getInfo().TOTAL_SHARDS,
            restTimeOffset: 2500,
            disableMentions: [
                "everyone",
                "here"
            ],
            debugger: true,
            intents: [
                GatewayIntentBits.Guilds,
                GatewayIntentBits.GuildMessages,
                GatewayIntentBits.MessageContent,
                GatewayIntentBits.GuildInvites,
                GatewayIntentBits.GuildMembers,
                GatewayIntentBits.GuildModeration,
                GatewayIntentBits.GuildEmojisAndStickers,
                GatewayIntentBits.GuildWebhooks,
                GatewayIntentBits.GuildVoiceStates,
            ],
            partials: [
                Partials.GuildMember,
                Partials.User,
                Partials.Message,
                Partials.Channel,
                Partials.Reaction,
                Partials.GuildScheduledEvent],
            presence: {
                activities: [{
                    name: `?help`,
                    type: ActivityType.Listening
                }],
                status: "idle",
                restRequestTimeout: 20000,
            },
            sweepers: {
                messages: { interval: 2, lifetime: 1, filter: () => message => message.id !== this.user.id }
            },
            makeCache: Options.cacheWithLimits({
                ApplicationCommandManager: 5,
                BaseGuildEmojiManager: 5,
                GuildBanManager: 0,
                GuildInviteManager: 0,
                GuildManager: Infinity,
                GuildMemberManager: {
                    maxSize: 200,
                    keepOverLimit: member => member.id === this.user.id,
                },
                GuildStickerManager: 0,
                GuildScheduledEventManager: 0,
                MessageManager: 5,
                PresenceManager: 0,
                ReactionManager: 0,
                ReactionUserManager: 0,
                StageInstanceManager: 500,
                ThreadManager: 0,
                ThreadMemberManager: 0,
            }),
        });
    }
}
Qjuh commented 6 months ago

Join the Discord support server if you want help with that.

Still not a library issue unless you can actually provide a reproducible sample code that doesn’t involve third-party libraries. But I‘ll gladly take a look at the bigger picture if you made forum post on the discord server.

Jiralite commented 6 months ago

Since this is not a discord.js issue, I'll be closing this. You may reach out on the Discord server's support channels to have others help you debug your code as it seems you cannot understand what your code is doing nor provide a reproducible sample.