1
0
Fork 0
mirror of synced 2024-07-03 05:31:14 +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): async def strawpolls(self, ctx, poll_id: int=None):
"""This command can be used to show a strawpoll setup on this server""" """This command can be used to show a strawpoll setup on this server"""
all_polls = config.getContent('strawpolls') or {} 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: if not server_polls:
await self.bot.say("There are currently no strawpolls running on this server!") await self.bot.say("There are currently no strawpolls running on this server!")
return return
@ -77,9 +77,10 @@ class Strawpoll:
data = await response.json() data = await response.json()
all_polls = config.getContent('strawpolls') or {} 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()} server_polls[data['id']] = {'author': ctx.message.author,'date': pendulum.utcnow()}
all_polls[ctx.message.server.id] = server_polls all_polls[ctx.message.server.id] = server_polls
config.saveContent('strawpolls',all_polls) config.saveContent('strawpolls',all_polls)
await self.bot.say("Link for your new strawpoll: https://strawpoll.me/{}".format(data['id'])) await self.bot.say("Link for your new strawpoll: https://strawpoll.me/{}".format(data['id']))