Skip to content
Permalink
Browse files
basic vote functionality which is super bad because it detects the wo…
…rds in any string rather than just the key words
  • Loading branch information
masudm6 committed Nov 5, 2020
1 parent b02e72e commit 23d1e50b89c90d509cf6a5abdd974711a11a878f
Showing 1 changed file with 24 additions and 19 deletions.
@@ -46,33 +46,38 @@ async def on_message(message): #checks for a message

#if message.content.lower()[4:] == "salt":
if "salt" in message.content.lower():
print("DEBUG: IT REACHED HERE!")
communityName = message.content.split(" ").remove("salt")

poll = await message.channel.send(f'vote here: for {communityName}')
polls[poll.id] = communityName
communityName = (message.content)[5:]
poll = await message.channel.send(f'vote here for {communityName}:')
print(f'[BOT DEBUG] {communityName} added to list of polls')
polls[poll.id] = communityName.upper()
print(polls)
tickEmoji = "\u2705"
crossEmoji = "\u274C"
await poll.add_reaction(tickEmoji)
await poll.add_reaction(crossEmoji)

if message.content.lower()[5:] == "count":
communityName = message.content.split(" ").remove("count")

pollID = list(polls.keys())[list(polls.values()).index(communityName)]
pollMessage = await message.channel.fetch_message(pollID)
pollReactions = pollMessage.reactions

await message.channel.send(f'Here are the saltiness statistics for the community {communityName}\nPoll ID:{pollID}')
for emj in pollReactions:
emojiCount = emj.count - 1
if emojiCount == 1:
await message.channel.send(f'{emj.emoji} : {emojiCount} vote')
else:
await message.channel.send(f'{emj.emoji} : {emojiCount} votes')
if "count" in message.content.lower():
communityName = (message.content)[6:]

if communityName.upper() not in polls.values():
await message.channel.send(f'No poll found for community: {communityName}.')
else:

pollID = list(polls.keys())[list(polls.values()).index(communityName.upper())]
pollMessage = await message.channel.fetch_message(pollID)
pollReactions = pollMessage.reactions

await message.channel.send(f'Here are the saltiness statistics for the community {communityName}\nPoll ID:{pollID}')
for emj in pollReactions:
emojiCount = emj.count - 1
if emojiCount == 1:
await message.channel.send(f'{emj.emoji} : {emojiCount} vote')
else:
await message.channel.send(f'{emj.emoji} : {emojiCount} votes')

# up to about here


client.run(TOKEN) #this is the token of the discord bot. You can create your own bot and put that token in here or the .env file to run the code
#================================

0 comments on commit 23d1e50

Please sign in to comment.