Skip to content

Commit

Permalink
Make /coin check default to the caller
Browse files Browse the repository at this point in the history
`/coin check` originally had a mandatory argument of a target user to
check the balance of. Now the argument defaults to the user who called
the command, making it more ergonomic to use.
  • Loading branch information
hydrobeam committed Aug 13, 2022
1 parent 30d82d9 commit 57914db
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/commandDetails/coin/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ import { getCoinEmoji } from '../../components/emojis';
// Check a user's balance
const coinCheckExecuteCommand: SapphireMessageExecuteType = async (
_client,
_messageFromUser,
messageFromUser,
args
): Promise<SapphireMessageResponse> => {
// Mandatory argument is user
const user = <User>args['user'];

// use the caller as a default user if no argument is provided
const user = <User>args['user'] ?? messageFromUser.member?.user;
// Get coin balance
const balance = await getCoinBalanceByUserId(user.id);
// Show coin balance
Expand All @@ -43,7 +42,7 @@ export const coinCheckCommandDetails: CodeyCommandDetails = {
name: 'user',
description: 'The user to check the balance of,',
type: CodeyCommandOptionType.USER,
required: true
required: false
}
],
subcommandDetails: {}
Expand Down

0 comments on commit 57914db

Please sign in to comment.