#Which one are you referring to I can t

1 messages · Page 1 of 1 (latest)

errant shadow
#

.

empty oak
#

which one do you want

#

guildmember or the api type

errant shadow
#

GuildMember

cobalt portalBOT
errant shadow
#

So the APIInteractionGuildMember is when its not cached and guildmember if its cached

empty oak
#

correct

errant shadow
#

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

empty oak
errant shadow
errant shadow
empty oak
errant shadow
#

It only complains about the APIInteractionGuildMember

empty oak
#

Again, that’s not how TS works

errant shadow
#

I modified it for discord-api-types aswell but there it doesnt work
And thats what i dont understand

empty oak
#

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

errant shadow