Professor-Redwood-Team / Professor-Redwood

Pokemon Go Discord Bot
MIT License
34 stars 21 forks source link

Adding optional weather emoji at end of raid alert. #60

Closed Alterraia closed 6 years ago

Alterraia commented 6 years ago

I'm trying to add a weather-boosted icon/emoji at the end of the line that the bot puts in the gymraid_alerts channel. I'm pretty certain the src>client.js file is where I need to do it. I attempted to write it myself, using the format of lines 17 - 26, but I got a syntax error that said "getEmoji has already been identified".

Not sure where I should put it for weather. This is what I have, but the bot doesn't work now because of the addition I made.

const getEmoji = (pokemon, weather) => { var emoji = pokemon; if (pokemon === 'ho-oh') { emoji = 'hooh'; // special case for ho-oh } var emoji = weather; if (weather === 'windy') { emoji = 'wind'; // special case for windy } if (emojisByName[emoji]) { return '<:' + emoji + ':' + emojisByName[emoji].id + '>'; } return ''; };

Basically, the command !raid boss minutesLeft location I'd have weather at the end:

!raid latios 42 Park windy

And it would put the windy emoji at the end of it or whichever one I need.

Note that the weather part would be only optional just to notify it's boosted.

Not certain if this is the only command line I need to edit for this to work.

I'm no programmer. I have to reverse engineer, so to speak, the code in order to add more, but I can't seem to figure this out.

Alterraia commented 6 years ago

Does it pull from pokemon.json for the pokemon?

pbk01 commented 6 years ago

@Alterraia , you need to make your desired changes in the raid.js file. The getEmoji function will work as-is if you pass it a string matching your weather emoji name (e.g. getEmoji("windy")).

Since the "location_details" can be a multi-word string, I would recommend looking for the weather keyword before or after "minutesRemaining", which would result in the following syntax: !raid [bossName] [minutesRemaining] [weather] [location details]

You could then modify the approach I used in the #51 (commit 814cbbb) pull request for the "exgym" parameter.

  1. Get the 3rd parameter (const weather = msgSplit[3];)
  2. Use a variable for weather emoji processing
    let weatherEmoji = '';
    weatherEmoji = data.getEmoji(weather);
  3. Detect/remove weather keyword from the "location_details" (remainder of the message)
  4. Add weatherEmojito reply and/or forwardReply, as desired.
Alterraia commented 6 years ago

I went through and updated everything for #51 and I want to keep the exgym option there, so I updated everything then modified it for where I live and with the additional tags like "perfectiv" and "zeroiv".

But I'm still having trouble where to enter what you suggested. I like weather being before the location. But as far as entering it, I'm struggling as to where. As I said, I never got into code writing (i think),

Would it be too much to ask if you could tell me which numbered lines to enter what I need?

It should be around lines 98 through 124, which is specific for the exgym tagging, or rather, after this one, but before lines 136-end.

This part is more complicated, for me at least.

Thanks for your help so far!