mirror of
https://github.com/sern-handler/handler
synced 2026-06-24 08:42:17 +00:00
feat: add guaranteed channelId and userId getters to Context (#320)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user