Skip to content

Commit

Permalink
fix(dice): handle error
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-fish committed Dec 7, 2023
1 parent 0d83f50 commit 33c7594
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/plugins/dice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,21 @@ export default class PluginDice extends BasePlugin {
.option('no-critical', '-C 不检查大成功/大失败', { type: 'boolean' })
.option('difficulty', '-d <difficulty:posint> 难度值', { type: 'posint' })
.action(async ({ session, options }, diceStr) => {
const dices = this.parseDices(diceStr)
const results = dices.map((item) => this.dice(item))
const resultStr = this.toResultString(
results,
options.difficulty,
!options['no-critical']
)
try {
const dices = this.parseDices(diceStr)
const results = dices.map((item) => this.dice(item))
const resultStr = this.toResultString(
results,
options.difficulty,
!options['no-critical']
)

return `${h.at(getUserIdFromSession(session), {
name: getUserNickFromSession(session),
})}${resultStr}`
return `${h.at(getUserIdFromSession(session), {
name: getUserNickFromSession(session),
})}${resultStr}`
} catch (err) {
return err.message || '' + err
}
})
}

Expand Down

0 comments on commit 33c7594

Please sign in to comment.