1
0
Fork 0
mirror of synced 2024-06-29 03:30:57 +12:00

Added default dictionary if nothing is loaded

This commit is contained in:
Phxntxm 2016-08-13 22:29:36 -05:00
parent 07c8f286a2
commit 3e3a459637

View file

@ -34,7 +34,7 @@ class Strawpoll:
async def strawpolls(self, ctx, poll_id: int=None):
"""This command can be used to show a strawpoll setup on this server"""
all_polls = config.getContent('strawpolls') or {}
server_polls = all_polls.get(ctx.message.server.id)
server_polls = all_polls.get(ctx.message.server.id) or {}
if not server_polls:
await self.bot.say("There are currently no strawpolls running on this server!")
return
@ -77,9 +77,10 @@ class Strawpoll:
data = await response.json()
all_polls = config.getContent('strawpolls') or {}
server_polls = all_polls.get(ctx.message.server.id)
server_polls = all_polls.get(ctx.message.server.id) or {}
server_polls[data['id']] = {'author': ctx.message.author,'date': pendulum.utcnow()}
all_polls[ctx.message.server.id] = server_polls
config.saveContent('strawpolls',all_polls)
await self.bot.say("Link for your new strawpoll: https://strawpoll.me/{}".format(data['id']))