Git Product home page Git Product logo

discord.js-light's Issues

How to send webhook in the thread?

const channel = await client.channels.fetch(discord.channelId);
let webhooks = await channel.fetchWebhooks();
webhook = webhooks.find(v => {
return v.name == 'XOXO' && v.type == "Incoming";
})
await webhook.send({ content: text, username: message.myName.username, avatarURL: message.myName.avatarURL });

It is work in channel, but get error in thread

error TypeError: channel.fetchWebhooks is not a function

Disconnecting and not reconnecting

I'm getting that error in all of sudden while it's working fine.

   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR Caught exception: TypeError: Cannot read property 'guild' of undefined
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR TypeError: Cannot read property 'guild' of undefined
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR     at ChannelManager.remove (/home/vcap/deps/0/node_modules/discord.js/src/managers/ChannelManager.js:44:17)
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR     at GuildDeleteAction.client.actions.GuildDelete.handle (/home/vcap/deps/0/node_modules/discord.js-light/actions.js:126:15)
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR     at Object.PacketHandlers.GUILD_DELETE (/home/vcap/deps/0/node_modules/discord.js-light/handlers.js:106:47)
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR     at WebSocketManager.client.ws.handlePacket (/home/vcap/deps/0/node_modules/discord.js-light/actions.js:38:28)
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR     at WebSocketShard.onPacket (/home/vcap/deps/0/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR     at WebSocketShard.onMessage (/home/vcap/deps/0/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR     at WebSocket.onMessage (/home/vcap/deps/0/node_modules/ws/lib/event-target.js:132:16)
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR     at WebSocket.emit (node:events:378:20)
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR     at Receiver.receiverOnMessage (/home/vcap/deps/0/node_modules/ws/lib/websocket.js:825:20)
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR     at Receiver.emit (node:events:378:20)
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR     at Receiver.dataMessage (/home/vcap/deps/0/node_modules/ws/lib/receiver.js:428:14)
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR     at Receiver.getData (/home/vcap/deps/0/node_modules/ws/lib/receiver.js:367:17)
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR     at Receiver.startLoop (/home/vcap/deps/0/node_modules/ws/lib/receiver.js:143:22)
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR     at Receiver._write (/home/vcap/deps/0/node_modules/ws/lib/receiver.js:78:10)
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR     at writeOrBuffer (node:internal/streams/writable:400:12)
   2021-02-09T16:45:54.69+0300 [APP/PROC/WEB/0] ERR     at _write (node:internal/streams/writable:341:10)
   2021-02-09T16:46:53.80+0300 [APP/PROC/WEB/0] OUT Debug log: [WS => Shard 0] [HeartbeatTimer] Didn't receive a heartbeat ack last time, assuming
zombie connection. Destroying and reconnecting.
   2021-02-09T16:46:53.80+0300 [APP/PROC/WEB/0] OUT     Status          : READY
   2021-02-09T16:46:53.80+0300 [APP/PROC/WEB/0] OUT     Sequence        : 66582
   2021-02-09T16:46:53.80+0300 [APP/PROC/WEB/0] OUT     Connection State: OPEN
   2021-02-09T16:46:53.80+0300 [APP/PROC/WEB/0] OUT Debug log: [WS => Shard 0] [DESTROY]
   2021-02-09T16:46:53.80+0300 [APP/PROC/WEB/0] OUT     Close Code    : 4009
   2021-02-09T16:46:53.80+0300 [APP/PROC/WEB/0] OUT     Reset         : true
   2021-02-09T16:46:53.80+0300 [APP/PROC/WEB/0] OUT     Emit DESTROYED: true
   2021-02-09T16:46:53.80+0300 [APP/PROC/WEB/0] OUT Debug log: [WS => Shard 0] Clearing the heartbeat interval.

MessageManager#forge doesn't set channel or guild data

When creating a message with MessageManager#forge the created message doesn't have a guild or channel set.

Example code:

const Discord = require('discord.js-light');
const client = new Discord.Client({ intents: [] });

const guild = client.guilds.forge('765694954416373771');
const channel = guild.channels.forge('765694954416373771', 'GUILD_TEXT');
const message = channel.messages.forge('960328996095148082');
console.log(message);
/*
Message {
  channelId: undefined,                 <------ These are unset
  guildId: null,
  id: '960328996095148082',
  createdTimestamp: 1649030674719,
  system: null,
  type: null,
  content: null,
  author: null,
  pinned: null,
  tts: null,
  nonce: null,
  embeds: [],
  components: [],
  attachments: Collection(0) [Map] {},
  stickers: Collection(0) [Map] {},
  editedTimestamp: null,
  reactions: ReactionManager { message: [Circular *1] },
  mentions: MessageMentions {
    everyone: false,
    users: Collection(0) [Map] {},
    roles: Collection(0) [Map] {},
    _members: null,
    _channels: null,
    crosspostedChannels: Collection(0) [Map] {},
    repliedUser: null
  },
  webhookId: null,
  groupActivityApplication: null,
  applicationId: null,
  activity: null,
  flags: MessageFlags { bitfield: 0 },
  reference: null,
  interaction: null
}
*/

Discord.MessageManager.prototype.forge = function(id) {
return this._add({ id }, false);
};

TypeError: Cannot read property 'id' of undefined

Hi, just here to report an issue I've just noticed within Discord JS light. Somehow, it seems possible that a new guild member can come through with an undefined ID, crashing the app. Please let me know whether this is an issue you can resolve or which I should take up to Discord JS.

Sadly, as this is an automated logging which happened about 16 minutes ago at the time of writing, I don't know much more than this as it was not in a development situation but in a live bot. It's worth noting that this bot has been fine for multiple weeks now, and this is the first issue I seemingly am not able to resolve myself.

Thank you for the library and I hope I'm both at the right place and that I can get this issue resolved with you.

Cheers!

Aug 06 09:20:34.447am info app TypeError: Cannot read property 'id' of undefined
Aug 06 09:20:34.447am info app at GuildMemberManager.Discord.GuildMemberManager.add (/app/node_modules/discord.js-light/classes.js:460:103)
Aug 06 09:20:34.447am info app at Message._patch (/app/node_modules/discord.js-light/classes.js:31:28)
Aug 06 09:20:34.447am info app at new Message (/app/node_modules/discord.js-light/node_modules/discord.js/src/structures/Message.js:43:20)
Aug 06 09:20:34.447am info app at new Message (/app/node_modules/discord.js-light/classes.js:6:9)
Aug 06 09:20:34.447am info app at Immediate.<anonymous> (/app/node_modules/discord.js-light/actions.js:29:29)
Aug 06 09:20:34.447am info app at processImmediate (internal/timers.js:458:21)
Aug 06 09:20:34.447am info app at MessageManager.add (/app/node_modules/discord.js-light/node_modules/discord.js/src/managers/BaseManager.js:49:32)
Aug 06 09:20:34.447am info app at MessageManager.add (/app/node_modules/discord.js-light/node_modules/discord.js/src/managers/MessageManager.js:29:18)
Aug 06 09:20:34.447am info app at MessageCreateAction.client.actions.MessageCreate.handle (/app/node_modules/discord.js-light/actions.js:221:34)
Aug 06 09:20:34.447am info app at Object.PacketHandlers.MESSAGE_CREATE (/app/node_modules/discord.js-light/handlers.js:170:49)

Fetching members from a guild returns partial results

Hello,
When using <Guild>.members.fetch(), the Member and User structures returned are sometimes partial for everyone except the bot itself. Not sure if this is the intended behavior, since it is my understanding that fetching should return non-partial results.

Example:

guild.members.fetch({ withPresences: true }).then(members => {
    console.log(members.map(x => x.displayName)); // sometimes returns ["bot name", null, null, null, etc...]
    console.log(members.map(x => x.user)); // sometimes returns User structures with nothing except for the ID
});

discord.js-light version: 3.5.3
Client options:

const client = new Client({
    partials: ["MESSAGE", "CHANNEL", "REACTION", "USER", "GUILD_MEMBER"],
    ws: { intents: ["DIRECT_MESSAGES", "DIRECT_MESSAGE_REACTIONS", "GUILDS", "GUILD_BANS", "GUILD_EMOJIS", "GUILD_INVITES", "GUILD_MEMBERS", "GUILD_PRESENCES", "GUILD_MESSAGES", "GUILD_MESSAGE_REACTIONS", "GUILD_VOICE_STATES"] },
    cacheChannels: true,
    cacheEmojis: true,
    cacheOverwrites: true,
    cacheGuilds: true,
    cacheRoles: true,
    cachePresences: true,
});

`guildCreate` doesn't get triggered on init

Currently there's no way to get guilds on launch with ChannelManager and GuildManager being LimitedCollection with size = 0 without fetching them with client.guilds.forge(exampleGuildId).channels.fetch() (ChannelManager) and client.guilds.forge(exampleGuildId).fetch() (GuildManager) as example.

client.on("raw",console.log) shows, that we receive GUILD_CREATE events (with channels and threads) without getting them on guildCreate or guildUpdate (shardConnect works for this option, but will do it only on sharding).

I was collecting parentId's of guild channels and thread parentIds, so there's no way to get them at launch without fetching.

Code:

...

const categories = new Collection<Snowflake, Snowflake>() // { channel => category }
const threads = new Collection<Snowflake, Snowflake>() // { thread => channel }

// categories and threads are always synced:
client.on("channelCreate",this._onChannelCreate);
client.on("channelUpdate",this._onChannelUpdate);
client.on("channelDelete",this._onChannelDelete);
client.on("threadCreate",this._onThreadCreate);
client.on("threadDelete",this._onThreadDelete);
client.on("threadUpdate",this._onThreadUpdate);
client.on("threadListSync",this._onThreadSync);

const channels = await this.client.guilds.forge(config().constants.trustedGuild).channels.fetch(); // can't receive on guildUpdate or guildCreate
// same with threads

channels.forEach(channel => {
   if (!channel.parentId || !channel.isText()) return;
   this.categories.set(channel.id, channel.parentId)
})

...

messageCreate: (leveling.channelMultipliers contains { Snowflake: number } with channel/category ids and multiplier values)

const channelId = message.channel.isThread() ? this.threads.get(message.channelId) : message.channelId;
const categoryId = channelId ? this.categories.get(channelId) : null;

const channelMultiplier = leveling.channelMultipliers[channelId!] ?? leveling.channelMultipliers[categoryId!] ?? 0;

console.log(`${channelId}'s multiplier is ${channelMultiplier}`);

Cannot read properties of undefined (reading '_add')

Hi
I don't know if this is an issue with discord.js light, but this is coming from there.

TypeError: Cannot read properties of undefined (reading '_add')
    at MessageCreateAction.MessageCreate [as handle] (/app/node_modules/discord.js-light/actions.js:440:36)
    at Object.MESSAGE_CREATE (/app/node_modules/discord.js-light/handlers.js:281:52)
    at WebSocketManager.Client.ws.handlePacket (/app/node_modules/discord.js-light/client.js:47:29)
    at WebSocketShard.onPacket (/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
    at WebSocket.onMessage (/app/node_modules/ws/lib/event-target.js:199:18)
    at WebSocket.emit (node:events:394:28)
    at Receiver.receiverOnMessage (/app/node_modules/ws/lib/websocket.js:1137:20)
    at Receiver.emit (node:events:394:28)
    at Receiver.dataMessage (/app/node_modules/ws/lib/receiver.js:528:14)

versions:
discord.js : 13.6.0
discord.js light: 4.6.1

MessageFlags is not defined

if(this.channel.type !== 'news' || this.type !== 'DEFAULT' || this.flags.has(MessageFlags.FLAGS.CROSSPOSTED)) { return false; }

Got error "ReferenceError: MessageFlags is not defined" while trying to check property "crosspostable" of message.

TextChannel can never be an instance of User

discord.js-light/classes.js

Lines 283 to 285 in c0abe51

Discord.Structures.extend("TextChannel", T => class TextChannel extends T {
async send(content, options) {
if (this instanceof Discord.User || this instanceof Discord.GuildMember) {

if (this instanceof Discord.User)

but as you can see

class TextChannel extends T

where T is TextChannel from discord.js

Error in makePartial and in actions

Hello.

Most of the shards on my bot crashed early today due to this error:

TypeError: Object.defineProperty called on non-object
    at Function.defineProperty (<anonymous>)
    at makePartial (./node_modules/discord.js-light/functions.js:26:9)
    at ChannelUpdateAction.ChannelUpdate [as handle] (./node_modules/discord.js-light/actions.js:64:4)
    at Object.CHANNEL_UPDATE (./node_modules/discord.js-light/handlers.js:99:57)
    at WebSocketManager.Client.ws.handlePacket (./node_modules/discord.js-light/client.js:47:29)
    at WebSocketShard.onPacket (./node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (./node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
    at WebSocket.onMessage (./node_modules/ws/lib/event-target.js:199:18)
    at WebSocket.emit (node:events:390:28)
    at Receiver.receiverOnMessage (./node_modules/ws/lib/websocket.js:1098:20)

I also got a notification about this one a few days ago:

TypeError: Cannot convert undefined or null to object
    at Function.values (<anonymous>)
    at ThreadListSyncAction.ThreadListSync [as handle] (./node_modules/discord.js-light/actions.js:667:33)
    at Object.THREAD_LIST_SYNC (./node_modules/discord.js-light/handlers.js:376:33)
    at WebSocketManager.Client.ws.handlePacket (./node_modules/discord.js-light/client.js:47:29)
    at WebSocketShard.onPacket (./node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (./node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
    at WebSocket.onMessage (./node_modules/ws/lib/event-target.js:199:18)
    at WebSocket.emit (node:events:390:28)
    at Receiver.receiverOnMessage (./node_modules/ws/lib/websocket.js:1098:20)
    at Receiver.emit (node:events:390:28)

Also do you have a Discord server where I could ask if I set up the caching properly? I've got some caching issues with channels and channel permissions.

discord-api-types conflicts

Hello, i'm facing an issue with the api types with this latest update of v4

Here are my version installed:

discord.js: 13.7.0 (uses api types 0.30.0)
discord.js-light: 4.7.0 (uses api types 0.33.0)

The error

Type 'MessageActionRow<MessageActionRowComponent | TextInputComponent, MessageActionRowComponentResolvable, { ...; }>' is not assignable to type 'MessageActionRow<MessageActionRowComponent, MessageActionRowComponentResolvable, APIActionRowComponent<APIMessageActionRowComponent>>'.
  Types of property 'components' are incompatible.
    Type '(MessageActionRowComponent | TextInputComponent)[]' is not assignable to type 'MessageActionRowComponent[]'.
      Type 'MessageActionRowComponent | TextInputComponent' is not assignable to type 'MessageActionRowComponent'.

46 const actionRow = (components: MessageActionRowComponentResolvable[]): MessageActionRow => new MessageActionRow({ components });
The inferred type of 'default' cannot be named without a reference to 'discord.js/node_modules/discord-api-types/v9'. This is likely not portable. A type annotation is necessary.

The code

const actionRow = (components: MessageActionRowComponentResolvable[]): MessageActionRow => new MessageActionRow({ components });

export default {
    actionRow: actionRow,
}

How i actually import from api types

import { APIMessage } from 'discord.js/node_modules/discord-api-types/v9 (or v10)';

I don't exactly understand what the error is here. If you have any idea that would be great ! :)

Channel NSFW status

The library seems to return an incorrect NSFW status for text channels in message objects when channel caching is disabled.
Despite the channel being NSFW, the property always is false.

Shard 0 keeps reconnecting

image

I'm guessing this isn't supposed to be happening? I haven't tested whether or not it can still receive messages while it's reconnecting but it keeps saying that in console

Permission issues

we were going to switch our bot to discord.js light but one issue stopped us.
when looking for permissions on a channel for our bot the bitfield that returns is always 0.

TypeError: Cannot read property 'slice' of null

Hey, I use the below code and got error, how can i fix it?

`TypeError: Cannot read property 'slice' of null

let high = parseInt(num.slice(0, -10)) || 0;
^

function channelFilter(channel) {
return !channel.messages || Discord.SnowflakeUtil.deconstruct(channel.lastMessageId).timestamp < Date.now() - 3600000;
}

ChannelManager: {
		maxSize: Infinity, // 
		sweepFilter: () => channelFilter, // remove manually cached channels according to the filter
		sweepInterval: 3600
	},
	GuildChannelManager: {
		maxSize: Infinity, // 
		sweepFilter: () => channelFilter, // remove manually cached channels according to the filter
		sweepInterval: 3600
	},

Shards: "auto" not working

I have an application that delivery (now) 230 bots with same source code, the idea is to make code as generic as possible and keep it health to host. Your lib is helping me a lot, but I'm having problem to make shard works in automatic mode. Maybe there is a way to use ShardManager, but I would have to check which bot needs Shards or not, and rewrite a big part of the struct code (which isn't a problem, but maybe it doesn't scale so good).

In summary, shards: "auto" already solved my situation using discord.js main lib, BUT, costing me 2000% more RAM than your library.

Question: I'm doing something wrong or shards auto option (in ClientOptions params) isn't working?
PS: In rare cases it works, but in most part of time not.

Error [SHARDING_REQUIRED]: This session would have handled too many guilds - Sharding is required.
801|vps | at WebSocketManager.createShards (/root/fork-heroku-bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:249:15)
801|vps | at async Client.login (/root/fork-heroku-bot/node_modules/discord.js/src/client/Client.js:245:7)
801|vps | at async upsetEvents (/root/fork-heroku-bot/dist/bot.js:336:21) {
801|vps | [Symbol(code)]: 'SHARDING_REQUIRED'
801|vps | }

const config = {

  intents: ["GUILD_MESSAGES"],

  makeCache: Discord.Options.cacheWithLimits({
    ApplicationCommandManager: 0, 
    BaseGuildEmojiManager: 0, 
    ChannelManager: 0, 
    GuildChannelManager: 0, 
    GuildBanManager: 0, 
    GuildInviteManager: 0, 
    GuildManager: Infinity, 
    GuildMemberManager: 0,
    GuildStickerManager: 0, 
    MessageManager: 0, 
    PermissionOverwriteManager: 0,
    PresenceManager: 0, 
    ReactionManager: 0,
    ReactionUserManager: 0, 
    RoleManager: 0, 
    StageInstanceManager: 0, 
    ThreadManager: 0, 
    ThreadMemberManager: 0, 
    UserManager: 0, 
    VoiceStateManager: 0 
  })
}
const Discord = require("discord.js-light")

...
some code here
...

discordApiKey.forEach((_) => this.client.push(new Discord.Client({
      ...config,
      shards: "auto"
})))

LimitedCollection Typescript Error

Hello, I'm having a typescript error.
It's warning me that 'All declarations of "LimitedCollection' must have identical type parameters" in node_modules/discord.js-light/client.d.ts:35:12 and node_modules/discord.js-light/node_modules/discord.js/typings/index.d.ts:1084:14

node: v16.6.0
discord.js: v13.1.0
discord.js-light: v4.1.4
image_2021-09-12_183650

<VoiceChannel>.join() don't work

Hello, i use <VoiceChannel>.join() and the bot say:

Error [VOICE_JOIN_CHANNEL]: You do not have permission to join this voice channel.

i view the code so <VoiceChannel>.joinable and <VoiceChannel>.viewable always is false.

v13

When will discord.js-light support v13?

GuildChannel.permissionsFor(user) returns null with all caches enabled

When using the GuildChannel.permissionsFor(), null is returned.

Example:

const Discord = require('discord.js-light');
const client = new Discord.Client({
    cacheGuilds: true,
    cacheChannels: true,
    cacheOverwrites: true,
    cacheRoles: true,
    cacheEmojis: true,
    cachePresences: true,
});

const MY_TOKEN = '{INSERT_TOKEN_HERE}';

(() => {
    client.on('message', msg => {
        if (msg.content.toLowerCase() !== 'test') {
            return;
        }

        // This comes back null
        let authorPerms = msg.channel.permissionsFor(msg.author);

        // This will fail because the above is null
        let authorIsAdmin = authorPerms.has('ADMINISTRATOR');

        msg.channel.send(authorIsAdmin ? 'You are an admin!' : 'You are not an admin!');
    });

    client.login(MY_TOKEN);
})();

Migration from discord.js

Hey!

I'm the owner of a fairly large Discord bot, and I'm considering migrating my code from discord.js to discord.js-light, because their memory usage is getting absolutely stupid at 7k+ servers.

I have a few questions:

  • Are there ANY API differences and gotchas I should be looking out for while I switch to this library, or is it literally just a drop-in replacement without caching? I assume I do have to make sure data is in cache now before pulling it, which i could basically avoid before since discord.js caches everything, but I mean anything other than that.
  • Would you be interested in migrating discord.js-light's codebase to Typescript? If i ever find the courage I might be interested in doing that, doesn't seem like a huge amount of work from what I've seen.
  • Are github issues the best way to contact you? In case I have problems & bugs as I migrate my project, I wanna make sure I ask in the right place.

TypeScript support?

When using TypeScript, the editor is unable to find the type declarations file (I'm guessing since it is included in discord.js but not in discord.js-light?):

Missing TypeScript

Is there a way to include or redirect typescript definitions to make discord.js-light usable with typescript?

Getting an error

Hey, I'm getting this error:

TypeError: Cannot read properties of null (reading 'members')
    at Message._patch (./node_modules/discord.js-light/extensions.js:80:78)
    at Message._update (./node_modules/discord.js/src/structures/Base.js:30:10)
    at MessageUpdateAction.MessageUpdate [as handle] (./node_modules/discord.js-light/actions.js:402:18)
    at Object.MESSAGE_UPDATE (./node_modules/discord.js-light/handlers.js:268:57)
    at WebSocketManager.Client.ws.handlePacket (./node_modules/discord.js-light/client.js:47:29)
    at WebSocketShard.onPacket (./node_modules/discord.js/src/client/websocket/WebSocketShard.js:443:22)
    at WebSocketShard.onMessage (./node_modules/discord.js/src/client/websocket/WebSocketShard.js:300:10)
    at WebSocket.onMessage (./node_modules/ws/lib/event-target.js:199:18)
    at WebSocket.emit (node:events:390:28)
    at Receiver.receiverOnMessage (./node_modules/ws/lib/websocket.js:1022:20)

GuildManager cache is on Infinity.

Buttons Support

Are you able to add buttons support to djs light as per the djs update?

Can't set maxSize on cache.

Hey, according to your example about caching roles only for the bot itself and ignoring all other roles you set the maxSize to 0.
In your types however there's only forceSet function defined and maxSize is not.
Because of that, TypeScript throws me an error.
image

Discord.js V14

Do you have an ETA on when you will release a version for Discord.js V14 maybe on a V5 branch ?

RangeError: "StageChannel" is not a valid extensible structure.

Hi, I'm using the discord.js-light master build, and whenever I start it up using the master build, I get this error:
image
and I'm not sure if the error is my fault or if it's to do with the library. Is there anything I can do to fix it, or is there any fix on the way?
Thanks!

Fetching multiple members a 2nd time returns an array instead of a map

the first guild.members.fetch returns a collection, the second call returns an array. This should only return a collection
Unit test

test('members fetch issue', async () => {
    const client = await login(); // login using discord.js-light
    const guild = await client.guilds.fetch("YOUR_GUILD_ID");
    const mapOrArray1 = await guild.members.fetch({user: ["MEMBER_1", "MEMBER_2"]});
    console.log(Array.isArray(mapOrArray1)); // false
    const mapOrArray2 = await guild.members.fetch({user: ["MEMBER_1", "MEMBER_2"]});
    console.log(Array.isArray(mapOrArray2)); // true ???
},999999);

I'm using this code to handle it for now

module.exports = async ({guild, playerIds}) => {
    const members = await guild.members.fetch({user: playerIds});
    if (Array.isArray(members)) {
        return new Map(members.map(member => [member.id, member]));
    } else {
        return members;
    }
};

Here's my client config

new Discord.Client({
    cacheGuilds: true,
    cacheChannels: false,
    cacheOverwrites: false,
    cacheRoles: true,
    cacheEmojis: false,
    cachePresences: false
})

I've tested this same code with discord.js and it always returns a collection

Question

Hi there! I really love this wrapper.

Could you possibly explain why I'm unable to read usernames from this code? When console logging, it shows the user info but when putting it into code it does not.

Test:

const test = await req.app.get("client").users.fetch("359498825150365699");
console.log(test);

Code: (EJS)

<%= await discord_data.users.fetch(i.userID).username ? discord_data.users.fetch(i.userID).username : "Not In Guild" %> 

Notes: discord_data is the discord.js light client. i.userID is a user ID string from my database.

Property 'forceSet' does not exist on type 'Collection<string, Channel>'

When using typescipt, then forceSet function from cache manager doesn't exists

Property 'forceSet' does not exist on type 'Collection<string, Channel>'

This error is from

this.client.channels.cache.forceSet(interaction.channelId, channel);

I am trying to migrate from djs to djs-light, and for permissions i am using the first example in README.md from here, and that error appears inside of that if

Privileged Intents Support

Private Intents does not work on commit "7c753b9d6a59ed149464d14415123772fa9e49ab".
I wrote the code like this.

const client = new Client({
  intents: [Intents.FLAGS.GUILD_MESSAGES, Intents.PRIVILEGED],
});

client.on("message", (msg) => {
  if (msg.author.bot) return;
  console.log(msg.author.presence.status);
});

However, only offline appears in the console log.

Also, it doesn't seem to work in the official release of v3.5.11.
This code was created when using the above version, and will only output offline to the console log.

const client = new Client({
  ws: {
    intents: [Intents.FLAGS.GUILD_MESSAGES, Intents.PRIVILEGED],
  },
});

client.on("message", (msg) => {
  if (msg.author.bot) return;
  console.log(msg.author.presence.status);
});

Owner Name and NickName

I'm trying to load the information from the server and save it to a database. I'm getting information like name, id, urlImage, owner id ... But I want to get the owner's name, and I'm getting a null result. I know that DiscordLight does not store cache. Would there be any other way of obtaining this information?

const Discord = require('discord.js-light');
const client = new Discord.Client({
  cacheGuilds: true,
  cacheChannels: true,
  cacheOverwrites: false,
  cacheRoles: true,
  cacheEmojis: false,
  cachePresences: false
});

client.on('ready', async () => {
  console.log(`Logged in as ${client.user.tag}!`);

  client.guilds.cache.forEach((value) => {
    console.log(value.name);  //return Guild Name
    console.log(value.id); //return Guild ID
    console.log(value.iconURL()); //return urlImage
    console.log(value.owner); //return null
    console.log(value.ownerID); //return Owner Id
  });    
});

how do i get all channels in a guild?

so If I pass in the options for no channelCaching, how can I get all channels in a guild? Would It be like:

<Guild>.channels.fetch();
//do something
<Guild>.channels.cache.deleteAll();

or does it automatically remove it from the cache?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.