migration prep
This commit is contained in:
1 parent
640a274146
commit
c220b5b590
6 files changed
+165
-15
No files matched your search
+13
-5
@@ -705,10 +705,18 @@ class Poll:
|
||||
|
||||
|
||||
async def to_dict(self):
|
||||
if self.channel is None:
|
||||
cid = 0
|
||||
else:
|
||||
cid = self.channel.id
|
||||
if self.author is None:
|
||||
aid = 0
|
||||
else:
|
||||
aid = self.author.id
|
||||
return {
|
||||
'server_id': str(self.server.id),
|
||||
'channel_id': str(self.channel.id),
|
||||
'author': str(self.author.id),
|
||||
'channel_id': str(cid),
|
||||
'author': str(aid),
|
||||
'name': self.name,
|
||||
'short': self.short,
|
||||
'anonymous': self.anonymous,
|
||||
@@ -827,9 +835,9 @@ class Poll:
|
||||
return None
|
||||
|
||||
async def from_dict(self, d):
|
||||
self.server = self.bot.get_server(d['server_id'])
|
||||
self.channel = self.bot.get_channel(d['channel_id'])
|
||||
self.author = await self.bot.get_user_info(d['author'])
|
||||
self.server = self.bot.get_server(str(d['server_id']))
|
||||
self.channel = self.bot.get_channel(str(d['channel_id']))
|
||||
self.author = await self.bot.get_user_info(str(d['author']))
|
||||
self.name = d['name']
|
||||
self.short = d['short']
|
||||
self.anonymous = d['anonymous']
|
||||
|
||||
@@ -215,7 +215,8 @@ class PollControls:
|
||||
query = self.bot.db.polls.find({'server_id': str(server.id), 'active': False})
|
||||
|
||||
if query is not None:
|
||||
polls = [poll async for poll in query]
|
||||
# sort by newest first
|
||||
polls = [poll async for poll in query.sort('_id', -1)]
|
||||
else:
|
||||
return
|
||||
|
||||
@@ -228,9 +229,9 @@ class PollControls:
|
||||
# await self.bot.say(embed=await self.embed_list_paginated(polls, item_fct, embed))
|
||||
# msg = await self.embed_list_paginated(ctx, polls, item_fct, embed, per_page=8)
|
||||
pre = await get_server_pre(self.bot, server)
|
||||
footer_text = '' # f'type {pre}show <label> to display a poll.
|
||||
footer_text = f'type {pre}show <label> to display a poll. '
|
||||
msg = await embed_list_paginated(self.bot, pre, polls, item_fct, embed, footer_prefix=footer_text,
|
||||
per_page=8)
|
||||
per_page=10)
|
||||
else:
|
||||
p = await Poll.load_from_db(self.bot, str(server.id), short)
|
||||
if p is not None:
|
||||
@@ -347,10 +348,10 @@ class PollControls:
|
||||
async def on_reaction_add(self, reaction, user):
|
||||
if user != self.bot.user:
|
||||
try:
|
||||
if reaction.emoji.startswith(('⏪', '⏩')):
|
||||
if isinstance(reaction.emoji, str) and reaction.emoji.startswith(('⏪', '⏩')):
|
||||
return
|
||||
except:
|
||||
print("fail emoji",reaction.emoji)
|
||||
logger.warning("fail emoji "+str(reaction.emoji))
|
||||
|
||||
# only look at our polls
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user