#Which one are you referring to I can t
1 messages · Page 1 of 1 (latest)
GuildMember
Interaction#inCachedGuild()
Indicates whether or not this interaction is both cached and received from a guild.
Thanks
So the APIInteractionGuildMember is when its not cached and guildmember if its cached
correct
Okay thanks alot :)
Though i still have one more issue could you help me with that aswell?
Do you possibly know why i can't modify the APIInteractionGuildMember from dc-api-types even though the same syntax works for discord.js
/* eslint-disable func-names */
import { Guild, CommandInteraction } from 'discord.js';
import Bot from '../base/Bot';
import { GuildDocument } from '../models/Guild';
import { TOptions } from 'i18next';
import { UserDocument } from '../models/User';
import { MemberDocument } from '../models/Member';
import { APIInteractionGuildMember } from 'discord-api-types/v9';
declare module 'discord.js' {
interface Guild {
client: Bot;
translate(key: string, args?: TOptions): string;
data: GuildDocument;
}
interface User {
client: Bot;
data: UserDocument;
}
interface GuildMember {
data: MemberDocument;
}
interface APIInteractionDataResolvedGuildMember {
data: MemberDocument;
}
interface CommandInteraction {
client: Bot;
translate(key: string, args?: TOptions): string;
}
}
declare module 'discord-api-types/v9' {
interface APIInteractionGuildMember {
data: MemberDocument;
}
}
Guild.prototype.translate = function (key: string, args?: TOptions): string {
const language = this.client.translations.get(this.data.language);
if (!language) throw new Error('Message: Invalid language set in data.');
return language(key, args);
};
CommandInteraction.prototype.translate = function (key: string, args?: TOptions) {
const language = this.client.translations.get(
this.guild ? this.guild.data.language : this.client.config.defaultLanguage,
);
if (!language) throw new Error('Message: Invalid language set in data.');
return language(key, args);
};
Results in me not being able to add the member document to the member object
member.data is not a thing, you can’t do that
Well yes
I modified it and extended it as you can see here but i can't modify the APIIntercationGuildMember somehow
You can’t modify either because that’s not how TS works
Well yes i can xd
For discord.js it works just not for discord-api-types
It only complains about the APIInteractionGuildMember
Again, that’s not how TS works
What exactly do you mean
I modified it for discord-api-types aswell but there it doesnt work
And thats what i dont understand
In ts you don’t magically create props that don’t exist
You can’t do that without module augmentation which isn’t recommended
Either way you should be using the typeguard by now
Well i created it for the module but it won't work