Skip to content
Permalink
Browse files
Added devops work item 34, cleared debug print statements and removed…
… variables which used to hold the tick and cross emojis.
  • Loading branch information
masudm6 committed Nov 19, 2020
1 parent 5c0453c commit a7fc0c83548f167ab5293507c1a28c1a0bd9e88e
Showing 1 changed file with 26 additions and 8 deletions.
@@ -84,21 +84,19 @@ async def on_message(message): #checks for a message
# ================ Masud did this ================
if "salt " == (message.content.lower())[:5]: # checks if the input matches "salt "
communityName = (message.content)[5:] # saves the rest of the input as communityName
tickEmoji = "\u2705" # unicode for the tick Emoji
crossEmoji = "\u274C" # unicode for the cross Emoji

if communityName.upper() in polls.values(): # if there is a poll active already
pollID = list(polls.keys())[list(polls.values()).index(communityName.upper())] # get the ID of the poll
await message.channel.send(f'The community: {communityName} already has a poll active. Poll ID:{pollID}.') # message to discord
else: # and if there is not an active poll already...
poll = await message.channel.send(f'vote here for {communityName}:') # create the vote poll
print(f'[BOT DEBUG] {communityName} added to list of polls') # print to console for debugging only
# print(f'[BOT DEBUG] {communityName} added to list of polls') # print to console for debugging only
polls[poll.id] = communityName.upper() # save the pollID and communityName together
print(polls) # print list of polls active for debugging only
await poll.add_reaction(tickEmoji) # add the tick emoji for the poll
await poll.add_reaction(crossEmoji) # add the cross emoji for the poll
# print("[BOT DEBUG] Poll dict:\n",polls) # print list of polls active for debugging only
await poll.add_reaction("✅") # add the tick emoji for the poll
await poll.add_reaction("❌") # add the cross emoji for the poll

if "count " == (message.content.lower())[:6]: # checks if the input matches "count "
if "count " == (message.content.lower())[:6]: # checks if the input matches "count ". DevOps work item 33
communityName = (message.content)[6:] # saves the rest of the input as communityName

if communityName.upper() not in polls.values(): # checks if the poll does not exist already
@@ -113,14 +111,34 @@ async def on_message(message): #checks for a message

countEmbed = discord.Embed() # Discord embed object
countDesc = "" # description of countEmbed object
countEmbed.title = f"Is the community {communityName} toxic?" # title of countEmbed object
countEmbed.title = f"Is the community {communityName} salty or supportive?" # title of countEmbed object. DevOps work item 32

tickCount = 0
crossCount = 0

for emj in pollReactions: # for each emoji in the reactions object
emojiCount = emj.count - 1 # remove 1 vote, which was from the bot.
# print("[BOT DEBUG] emj.emoji:",emj.emoji) # debug code for reactions.emoji object
if emj.emoji == "✅": # if emoji is tick emoji
tickCount = emj.count - 1 # this reaction will be tickCount
elif emj.emoji == "❌": # if emoji is cross emoji
crossCount = emj.count - 1 # this reaction will be crossCount

if emojiCount == 1: # adjust embed description accordingly
countDesc = countDesc + f'\n{emj.emoji} : {emojiCount} vote'
else:
countDesc = countDesc + f'\n{emj.emoji} : {emojiCount} votes'

# add a message to the end of the results depending on the votes for the emojis. DevOps work item 34
# print("[BOT DEBUG] tick cross :",tickCount,crossCount) # this code was used to debug the tick and cross counts.
if tickCount == crossCount:
countDesc = countDesc + "\n This community seems to be equally supportive and salty."
elif tickCount > crossCount:
countDesc = countDesc + "\n This community seems to be more supportive."
elif tickCount < crossCount:
countDesc = countDesc + "\n This community seems to be more salty."

# add the description to the embed and message it to the channel.
countEmbed.description = countDesc # add embed description to embed
await message.channel.send(embed=countEmbed) # send the embed to the channel the message is in

0 comments on commit a7fc0c8

Please sign in to comment.