Skip to content

Commit

Permalink
refactor(discord): update error message for twitch !link (#3611)
Browse files Browse the repository at this point in the history
  • Loading branch information
sogehige committed Apr 30, 2020
1 parent 4947558 commit 238b509
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/bot/expects.ts
Expand Up @@ -443,7 +443,7 @@ class Expects {
}
if (!opts.optional) {
this.checkText({
expects: 'any',
expects: opts.name ?? 'any',
...opts,
});
}
Expand Down
8 changes: 6 additions & 2 deletions src/bot/integrations/discord.ts
Expand Up @@ -126,7 +126,7 @@ class Discord extends Integration {
this.removeExpiredLinks();

try {
const [ uuid ] = new Expects(opts.parameters).everything().toArray();
const [ uuid ] = new Expects(opts.parameters).everything({ name: 'uuid' }).toArray();
if (!isUUID(uuid)) {
throw new Error(String(errors.NOT_UUID));
}
Expand All @@ -139,7 +139,11 @@ class Discord extends Integration {
return [{ response: `$sender, this account was linked with ${link.tag}.`, ...opts }];
} catch (e) {
if (e.message === String(errors.NOT_UUID)) {
return [{ response: '$sender, invalid token.', ...opts }];
return [{ response: '$sender, invalid or expired token.', ...opts }];
} else if (e.message.includes('Expected parameter')) {
return [
{ response: '$sender, to link you account on Discord: 1. Go to Discord server and send !link in bot channel. | 2. Wait for PM from bot | 3. Send command from you Discord PM here in twitch chat.', ...opts },
];
} else {
warning(e.stack);
return [{ response: '$sender, something went wrong.', ...opts }];
Expand Down

0 comments on commit 238b509

Please sign in to comment.