Merge pull request #1 from turtlebasket/master

polish voting, clean up help menu, update statuses
pull/3/head
turtlebasket 2020-02-11 20:02:20 -08:00 committed by GitHub
commit f8abc4fb17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 14 deletions

35
bot.py
View File

@ -42,13 +42,16 @@ banning_users = []
async def status_loop(): async def status_loop():
while True: while True:
await bot.change_presence(activity=discord.Game(name='{0} users in {1} servers'.format(len(bot.users), len(bot.guilds)))) await bot.change_presence(activity=discord.Game(name='Serving {0} glorious servers'.format(len(bot.guilds))))
await asyncio.sleep(STATUS_LOOP) await asyncio.sleep(STATUS_LOOP)
await bot.change_presence(activity=discord.Game(name='>>help'.format(len(bot.guilds)))) await bot.change_presence(activity=discord.Game(name='>>help'.format(len(bot.guilds))))
await asyncio.sleep(STATUS_LOOP) await asyncio.sleep(STATUS_LOOP)
await bot.change_presence(activity=discord.Game(name='Communist Revolution 2: Electric Boogaloo'.format(len(bot.guilds)))) await bot.change_presence(activity=discord.Game(name='Proletarian Uprising 2: Electric Boogaloo'.format(len(bot.guilds))))
await asyncio.sleep(STATUS_LOOP)
await bot.change_presence(activity=discord.Game(name='Want to contribute? Have an issue? https://github.com/turtlebasket/comrade-bot'))
await asyncio.sleep(STATUS_LOOP) await asyncio.sleep(STATUS_LOOP)
@bot.event @bot.event
@ -63,32 +66,48 @@ async def help(ctx):
embed = discord.Embed(title="How 2 Comrade") embed = discord.Embed(title="How 2 Comrade")
embed.add_field( embed.add_field(
name=">>addEmote <emoji name>", name=">>addEmote <emoji name>",
value="hold a {0}-second vote on whether or not to add a given emote (provided as a message attachment).".format(EMOTE_VOTE_TIME) value=
"""Vote to add a new emoji.
Vote time: {0} minutes
Minimum Voters: {1}
""".format(int(EMOTE_VOTE_TIME/60), MIN_EMOTE_VOTERS)
) )
embed.add_field( embed.add_field(
name=">>mute <user>", name=">>mute <user>",
value="Hold a {0}-second vote to mute a user for {1} minutes (minimum voters: {2}, over 50% majority required).".format(MUTE_VOTE_TIME, int(MUTE_TIME/60), MIN_MUTE_VOTERS) value=
"""Vote to mute user for {0} minutes.
Vote time: {1} minutes
Minimum Voters: {2}
""".format(int(MUTE_TIME/60), int(MUTE_VOTE_TIME/60), MIN_MUTE_VOTERS)
) )
embed.add_field( embed.add_field(
name=">>kick <user>", name=">>kick <user>",
value="Kick user. The vote is up for {0} minutes, and requires that a minimum of {1} users and >50% approve.".format(int(KICK_VOTE_TIME/60), MIN_KICK_VOTERS) value=
"""Vote to kick user.
Vote Time: {0} minutes
Minimum Voters: {1}
""".format(int(KICK_VOTE_TIME/60), MIN_KICK_VOTERS)
) )
embed.add_field( embed.add_field(
name=">>ban <user>", name=">>ban <user>",
value="Ban user. By default, the vote lasts {0} minutes, and requires that there be at least {1} votes and a 50% majority.".format(int(BAN_VOTE_TIME/60), MIN_BAN_VOTERS) value=
"""Vote to ban user.
Vote Time: {1} minutes
Minimum Voters: {1}
""".format(int(BAN_VOTE_TIME/60), MIN_BAN_VOTERS)
) )
embed.add_field( embed.add_field(
name=">>shibe", name=">>shibe",
value="shibe :dog: :eyes:" value="Random shibe :dog: :eyes:"
) )
embed.add_field( embed.add_field(
name=">>birb", name=">>birb",
value="birb :bird: :hatching_chick:" value="Random birb :bird: :hatching_chick:"
) )
embed.add_field( embed.add_field(

View File

@ -27,10 +27,6 @@ async def take_vote(ctx, question:str, vote_time, min_voters):
await votey_message.add_reaction('') await votey_message.add_reaction('')
await votey_message.add_reaction('') await votey_message.add_reaction('')
# TODO: Short-circuit eval loop, old stuff temp commented
# await asyncio.sleep(vote_time)
passed = False passed = False
curr_time = 0 curr_time = 0
while curr_time < vote_time: while curr_time < vote_time:
@ -44,7 +40,6 @@ async def take_vote(ctx, question:str, vote_time, min_voters):
elif str(reaction.emoji) == '': elif str(reaction.emoji) == '':
not_in_favor += reaction.count-1 not_in_favor += reaction.count-1
print("check ({0} ✅, {1} ❌)".format(all_in_favor, not_in_favor))
if all_in_favor > not_in_favor and all_in_favor >= min_voters: if all_in_favor > not_in_favor and all_in_favor >= min_voters:
passed = True passed = True
break break

View File

@ -1,5 +1,5 @@
{ {
"MUTE_VOTE_TIME" : 30, "MUTE_VOTE_TIME" : 60,
"MIN_MUTE_VOTERS" : 4, "MIN_MUTE_VOTERS" : 4,
"MUTE_TIME" : 600, "MUTE_TIME" : 600,