imranbarbhuiya / pagination.djs

A simple yet powerful discord.js embed pagination package.
https://pagination-djs.js.org/
MIT License
17 stars 3 forks source link

Interaction not working #88

Closed Barnac1ed closed 1 year ago

Barnac1ed commented 1 year ago

Issue description

When running, it gives me the error The interaction must be an instance of Interaction or Message. I console logged interaction, which returrned:

CommandInteraction {
  type: 'APPLICATION_COMMAND',
  id: '1039703993796018296',
  applicationId: '1038820551185141870',
  channelId: '1008934814784688230',    
  guildId: '1008065292355764234',      
  user: User {
    id: '853094730820354079',
    bot: false,
    system: false,
    flags: UserFlags { bitfield: 64 },
    username: 'π—¦π˜‚π—Ώπ—»π—Άπ—Έπ—Ό.'       ,
    discriminator: '8676',
    avatar: '739103d837a0bc55043ed9d7d954e6b2',
    banner: undefined,
    accentColor: undefined
  },
  member: GuildMember {
    guild: Guild {
      id: '1008065292355764234',
      name: 'henrism hub',
      icon: '6efa74d88d75627b3438b8e92828cdb8',
      features: [Array],
      commands: [GuildApplicationCommandManager],
      members: [GuildMemberManager],
      channels: [GuildChannelManager],
      bans: [GuildBanManager],
      roles: [RoleManager],
      presences: PresenceManager {},
      voiceStates: [VoiceStateManager],
      stageInstances: [StageInstanceManager],
      invites: [GuildInviteManager],
      scheduledEvents: [GuildScheduledEventManager],
      available: true,
      shardId: 0,
      splash: null,
      banner: null,
      description: null,
      verificationLevel: 'LOW',
      vanityURLCode: null,
      nsfwLevel: 'DEFAULT',
      premiumSubscriptionCount: 0,
      discoverySplash: null,
      memberCount: 9,
      large: false,
      premiumProgressBarEnabled: false,
      applicationId: null,
      afkTimeout: 300,
      afkChannelId: null,
      systemChannelId: null,
      premiumTier: 'NONE',
      explicitContentFilter: 'ALL_MEMBERS',
      mfaLevel: 'NONE',
      joinedTimestamp: 1667744612490,
      defaultMessageNotifications: 'ONLY_MENTIONS',
      systemChannelFlags: [SystemChannelFlags],
      maximumMembers: 500000,
      maximumPresences: null,
      maxVideoChannelUsers: 25,
      approximateMemberCount: null,
      approximatePresenceCount: null,
      vanityURLUses: null,
      rulesChannelId: '1008934672719429692',
      publicUpdatesChannelId: '1009180226498088980',
      preferredLocale: 'en-US',
      ownerId: '602958162793988246',
      emojis: [GuildEmojiManager],
      stickers: [GuildStickerManager]
    },
    joinedTimestamp: 1660433348494,
    premiumSinceTimestamp: null,
    nickname: null,
    pending: false,
    communicationDisabledUntilTimestamp: null,
    _roles: [ '1008205840228024441' ],
    user: User {
      id: '853094730820354079',
      bot: false,
      system: false,
      flags: [UserFlags],
      username: 'π—¦π˜‚π—Ώπ—»π—Άπ—Έπ—Ό.'       ,
      discriminator: '8676',
      avatar: '739103d837a0bc55043ed9d7d954e6b2',
      banner: undefined,
      accentColor: undefined
    },
    avatar: null
  },
  version: 1,
  appPermissions: Permissions { bitfield: 4398046511103n },
  memberPermissions: Permissions { bitfield: 4398046511103n },
  locale: 'en-US',
  guildLocale: 'en-US',
  commandId: '1039684434015817738',
  commandName: 'cards',
  deferred: false,
  replied: false,
  ephemeral: null,
  webhook: InteractionWebhook { id: '1038820551185141870' },
  options: CommandInteractionOptionResolver {
    _group: null,
    _subcommand: null,
    _hoistedOptions: []
  }
}

Code sample

const { EmbedBuilder } = require("discord.js");
const { Pagination } = require("pagination.djs");
const sdv = require("sportsdataverse");
const User = require("../schemas/User.js");

module.exports = {
  name: "cards",
  description: "Displays your current cards",
  options: [],
  run: async (client, interaction) => {
    console.warn(interaction);
    const persons = await User.where("userid").equals(interaction.user.id);
    var user;
    if (persons.length === 0) {
      user = new User({
        userId: interaction.user.id,
        username: `${interaction.user.username}#${interaction.user.discriminator}`,
        cards: [],
      }).save();
    } else {
      user = persons[0];
    }

    var cards = user.cards;
    var embeds = [];
    for (const card of cards) {
      var player = card;
      var g = await sdv.nba.getTeamInfo(player.teamId);
      var ga = g.team;
      var embed = new EmbedBuilder()
        .setTitle(`${player.name} | ${player.team}`)
        .addFields(
          { name: "__`Name`__", value: player.name, inline: true },
          { name: "__`Position`__", value: player.position, inline: true },
          { name: "__`Team`__", value: player.team, inline: true },
          { name: "__`Weight`__", value: player.weight, inline: true },
          { name: "__`Height`__", value: player.height, inline: true },
          {
            name: "__`Birthplace`__",
            value: `${player.birthplace.city}, ${player.birthplace.country}`,
            inline: true,
          }
        )
        .setTimestamp()
        .setThumbnail(ga.logos[0].href)
        .setColor(`#${ga.color}`)
        .setFooter({ text: `${player.id} | Steps` });

      if (player.headshot !== null) embed.setImage(player.headshot);
      embeds.push(embed);
    }

    const pagination = new Pagination(interaction);
    pagination.setEmbeds(embeds);

    //await pagination.render();
  },
};

Package version

β”œβ”€β”€ @voiddevs.org/slashbot@1.1.8 β”œβ”€β”€ discord.js@14.6.0 β”œβ”€β”€ fs@0.0.1-security β”œβ”€β”€ mongoose@6.7.2 β”œβ”€β”€ pagination.djs@4.0.5 β”œβ”€β”€ simple-json-db@2.0.0 └── sportsdataverse@1.2.3

Node.js version

v18.8.0

Operating system

WIndows

I have tested this issue on a next release

pagination.djs@4.0.5

imranbarbhuiya commented 1 year ago

Probably a mismatch of djs version. If u r using yarn v3, run yarn dedupe and it should fix it. Else try uninstalling djs and reinstall

Barnac1ed commented 1 year ago

I just tried reinstalling and uninstalling both discord.js and pagination.djs, but i still have the same problem i am not using yarn btw.

imranbarbhuiya commented 1 year ago

Ig i'll just remove the check then as it doesn't do anything.

Barnac1ed commented 1 year ago

i just removed the check, and it threw a new error: TypeError [INVALID_TYPE]: Supplied data.type is not a valid MessageComponentType.

imranbarbhuiya commented 1 year ago

Can you run yarn why discord.js and yarn why pagination.djs and send the ss here

Barnac1ed commented 1 year ago

im not running yarn

imranbarbhuiya commented 1 year ago

then use npm ls discord.js and npm ls pagination.djs if u r using pnpm then run the equivalent command for pnpm

Barnac1ed commented 1 year ago

npm ls discord.js returns:

card-bot@1.0.0 C:\Users\Nolan\Documents\card-bot
β”œβ”€β”¬ @voiddevs.org/slashbot@1.1.8
β”‚ └── discord.js@13.11.0
β”œβ”€β”€ discord.js@14.6.0
└─┬ pagination.djs@4.0.5
  └── discord.js@14.6.0 deduped

npm ls pagination.djs returns:

 card-bot@1.0.0 C:\Users\Nolan\Documents\card-bot
└── pagination.djs@4.0.5
imranbarbhuiya commented 1 year ago
β”œβ”€β”¬ @voiddevs.org/slashbot@1.1.8
β”‚ └── discord.js@13.11.0

This is causing the issue. It's installing the v13 version of djs and u r using v14 djs. And pagination.djs v4 needs v14 djs

Barnac1ed commented 1 year ago

that worked, thanks for all of the help :)