Closed ySnoopyDogy closed 3 years ago
https://github.com/MenheraBot/MenheraBot/runs/3638596126
More info here
Strange, client.channels.cache should be a LimitedCollection, not a Collection. But anyway i added a typing for it too, can you test if it works? npm i timotejroiko/discord.js-light#v4
Hey, apologies for the delay. It works for the forceSet, but with that i cannot use Collection for value, like create a collection. For me its not a problem, i can use a map instead, but i don't know for others. But yeah, the main problem its fixed. Thanks
why cant you use it? what happens if you try to use it?
If i import both, LimitedCollection and Collection from discord.js-light it says 'Collection' only refers to a type, but is being used as a value here.
. The code is
import { Collection, LimitedCollection } from 'discord.js-light';
const collection = new Collection(); //'Collection' only refers to a type, but is being used as a value here
const limited = new LimitedCollection(); //'LimitedCollection' only refers to a type, but is being used as a value here
tried something new, can you test the v4 branch again?
Yes, it works! forceSet exists, and limitedCollection and Collection are now classes too. Thanks.
By the way, i saw that the readme shows people that uses discord.js-light, i don't know what i need to do to add it here, but if its available, i would like to add my bot in here. Thanks again for the attention
cool, i'll update it on npm soon, and sure, just make a PR for it
Oky Doki, it just to create a PR to change the readme with my information, right?
Hey, sorry for it, but i just found out that the forceSet problem still exists. I can use forceSet in custom Collection and LimitedCollections, but in collections from discord.js (client.channels in my case) the forceSet function does not exists
Actually, i updated to the timotejroiko/discord.js-light#v4
again, and the problem is back for creating Collections, it shows that its a type. forceSet exists in client.channels
made another update, try again
I can create collections, and they have forceSet property, but the collection from djs (client.channels) does not have forceSet
sigh... i hate typescript....
what about now?
I think we'll still have to fight for it
hmm, i dont believe its gonna be possible without modifying discordjs/collection...
i've reverted the typings a few steps back, and i believe the solution is to do this instead:
(client.channels.cache as Discord.Collection<Discord.Snowflake, Discord.Channel>).forceSet()
The issue is that internally discord.js does not use Discord.Collection but they directly import discordjs/collection, so i dont think we can override that from this lib.
No problem, i will update my code now. Thank you for all the support
if (!this.client.channels.cache.has(interaction.channelId)) {
const channel = await this.client.channels.fetch(interaction.channelId).catch(() => null);
if (channel) {
(this.client.channels.cache as Collection<string, ThreadChannel | GuildChannel>).forceSet(
interaction.channelId,
channel,
);
(
interaction.guild?.channels.cache as Collection<string, ThreadChannel | GuildChannel>
).forceSet(interaction.channelId, channel);
}
}
This is my final code taking from reference the first example in your readme, it works pretty well
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
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