Skip to content
Permalink
Browse files
Added saltiness stuff in main code, will work on it later to make it …
…work fully. Doesn't interfere with other code (yet) and I can add more print statements to debug later
  • Loading branch information
masudm6 committed Nov 5, 2020
1 parent 27bb533 commit b02e72e73e6b46aec41fa970065d9a2431cd272f
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
@@ -23,7 +23,7 @@ async def on_ready():
members = '\n - '.join([member.name for member in guild.members])
print(f'Guild Members:\n - {members}')


polls = {} # masud added this to hold poll data

@client.event
async def on_message(message): #checks for a message
@@ -42,5 +42,37 @@ async def on_message(message): #checks for a message
response = random.choice(creepyHellos)
await message.channel.send(response)

# Masud did this

#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
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')

# 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
#================================
#================================
23 nacl.py
@@ -0,0 +1,23 @@
# a file which is incredibly salty
# read through at your own risk
polls = {}

async def createSaltPoll(communityName,message):
poll = await message.channel.send(f'vote here: for {communityName}')
polls[poll.id] = communityName
tickEmoji = "\u2705"
crossEmoji = "\u274C"
await poll.add_reaction(tickEmoji)
await poll.add_reaction(crossEmoji)

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



dataFormat = []
dataFormat.append(pollID) # 0
dataFormat.append(pollReactions) # 1
return dataFormat

0 comments on commit b02e72e

Please sign in to comment.