Skip to content
Permalink
Browse files
Replaced code with discord embed objects on the vote count bit
  • Loading branch information
masudm6 committed Nov 19, 2020
1 parent 1ce7371 commit 5c0453c71ab51b95e0ead26d94169b29829fdf9c
Showing 1 changed file with 14 additions and 9 deletions.
@@ -82,12 +82,10 @@ async def on_message(message): #checks for a message
await message.channel.send(response)
# ================================================
# ================ Masud did this ================

tickEmoji = "\u2705" # unicode for the tick Emoji
crossEmoji = "\u274C" # unicode for the cross Emoji

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
@@ -100,7 +98,7 @@ async def on_message(message): #checks for a message
await poll.add_reaction(tickEmoji) # add the tick emoji for the poll
await poll.add_reaction(crossEmoji) # add the cross emoji for the poll

if "count " == (message.content.lower())[:6]: # cecks if the input matches "count "
if "count " == (message.content.lower())[:6]: # checks if the input matches "count "
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
@@ -112,12 +110,19 @@ async def on_message(message): #checks for a message
pollReactions = pollMessage.reactions # accesses the reactions for the pollMessage object

await message.channel.send(f'Here are the saltiness statistics for the community {communityName}\nPoll ID:{pollID}') # message to discord

countEmbed = discord.Embed() # Discord embed object
countDesc = "" # description of countEmbed object
countEmbed.title = f"Is the community {communityName} toxic?" # title of countEmbed object

for emj in pollReactions: # for each emoji in the reactions object
emojiCount = emj.count - 1 # remove 1 vote, which was from the bot.
if emojiCount == 1: # message to discord accordingly
await message.channel.send(f'{emj.emoji} : {emojiCount} vote')
emojiCount = emj.count - 1 # remove 1 vote, which was from the bot.
if emojiCount == 1: # adjust embed description accordingly
countDesc = countDesc + f'\n{emj.emoji} : {emojiCount} vote'
else:
await message.channel.send(f'{emj.emoji} : {emojiCount} votes')
countDesc = countDesc + f'\n{emj.emoji} : {emojiCount} votes'
countEmbed.description = countDesc # add embed description to embed
await message.channel.send(embed=countEmbed) # send the embed to the channel the message is in

# ================ up to about here ================

0 comments on commit 5c0453c

Please sign in to comment.