Skip to content

Commit

Permalink
fix: Add a check for no entered emotes.
Browse files Browse the repository at this point in the history
  • Loading branch information
KararTY committed Jul 31, 2021
1 parent e63560e commit fcaa7da
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@adonisjs/env": "^1.0.18",
"@adonisjs/logger": "^2.1.0",
"@adonisjs/validator": "^7.4.0",
"befriendlier-shared": "kararty/BeFriendlier-Shared#0fc51b5",
"befriendlier-shared": "kararty/BeFriendlier-Shared#b4c9e83",
"dank-twitch-irc": "^4.3.0",
"got": "^11.8.2",
"p-queue": "^6.6.2",
Expand Down
5 changes: 5 additions & 0 deletions src/Handlers/GiveEmotesHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default class GiveEmotesHandler extends DefaultHandler {

// Get user details for provided user.
const res = await this.twitch.api.getUser(this.twitch.token.superSecret, [words[0]])

if (res !== null && res.length > 0) {
responseMessage.recipientUserTwitch = {
id: res[0].id,
Expand All @@ -27,6 +28,10 @@ export default class GiveEmotesHandler extends DefaultHandler {

responseMessage.emotes = this.parseEmotes(msg, words.slice(1))

if (responseMessage.emotes.length === 0) {
return this.twitch.sendMessage(responseMessage.channelTwitch, responseMessage.userTwitch, messagesText.noEmotes)
}

this.ws.sendMessage(this.messageType, JSON.stringify(responseMessage))
} else {
this.twitch.sendMessage(
Expand Down
3 changes: 2 additions & 1 deletion src/messagesText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const messagesText = {
unregistered: 'you\'re not registered! Browse to the website to register.',
noHoroscope: 'no horoscope today! Check back tomorrow?',
sameUser: 'recipient user is the same user as you.',
noEmotes: 'you\'ve not entered any Twitch emotes in your message.',
helpText: {
help: 'rubber ducky 🦆 Never lucky.',
emotes: 'sets your favorite emotes for your profile. Add "global" in the beginning to change your global profile\'s bio.',
Expand All @@ -20,7 +21,7 @@ const messagesText = {
ping: 'returns ping info about Twitch IRC & Website.',
rollMatch: 'initiates a match! Good luck, rubber ducky 🦆 Append "global" to initiate a match with global profiles.',
unmatch: 'unmatches with the provided user. Append "global" to unmatch with a user in your global profile.',
giveEmotes: 'lets you trade your emotes with another befriendlier user.',
giveEmotes: 'lets you trade your emotes with another befriendlier user. (<recipient name> <amount> <emote name>)',
},
}

Expand Down

0 comments on commit fcaa7da

Please sign in to comment.