feat: add guaranteed channelId and userId getters to Context (#320)

This commit is contained in:
mina
2023-08-06 15:28:38 -05:00
committed by GitHub
parent 215aca2f46
commit 50253ca322

View File

@@ -37,6 +37,11 @@ export class Context extends CoreContext<Message, ChatInputCommandInteraction> {
public get channel() {
return this.ctx.val.channel;
}
public get channelId(): Snowflake {
return safeUnwrap(this.ctx.map(m => m.channelId).mapErr(i => i.channelId));
}
/**
* If context is holding a message, message.author
* else, interaction.user
@@ -45,6 +50,10 @@ export class Context extends CoreContext<Message, ChatInputCommandInteraction> {
return safeUnwrap(this.ctx.map(m => m.author).mapErr(i => i.user));
}
public get userId(): Snowflake {
return this.user.id;
}
public get createdTimestamp(): number {
return this.ctx.val.createdTimestamp;
}