fix bug for forbidden channel

This commit is contained in:
Klemek
2021-03-16 16:00:20 +01:00
parent d092074ed5
commit 3e781c746f
3 changed files with 34 additions and 27 deletions
+1
View File
@@ -70,6 +70,7 @@ class ChannelLogs:
yield len(self.messages), False
self.last_message_id = channel.last_message_id
except discord.errors.HTTPException:
yield -1, True
return # When an exception occurs (like Forbidden)
yield len(self.messages), True
+1 -1
View File
@@ -154,7 +154,7 @@ class GuildLogs:
workers += [Worker(self.channels[channel.id], channel)]
warning_msg = "(this might take a while)"
if len(target_channels) > 5 and loading_new > 5:
warning_msg = "(most channels are new, this might take a looong while)"
warning_msg = "(most channels are new, this will take a long while)"
elif loading_new > 0:
warning_msg = "(some channels are new, this might take a long while)"
await code_message(
+32 -26
View File
@@ -123,38 +123,44 @@ class Scanner(ABC):
self.msg_count += count
self.chan_count += 1 if count > 0 else 0
logging.info(f"scan {guild.id} > scanned in {delta(t0):,}ms")
await progress.edit(content="```Computing results...```")
# Display results
t0 = datetime.now()
results = self.get_results(
get_intro(
self.intro_context,
self.full,
self.channels,
self.members,
self.msg_count,
self.chan_count,
if self.total_msg == 0:
await message.channel.send(
"There are no messages found matching the filters",
reference=message,
)
)
logging.info(f"scan {guild.id} > results in {delta(t0):,}ms")
response = ""
first = True
for r in results:
if len(response + "\n" + r) > 2000:
else:
await progress.edit(content="```Computing results...```")
# Display results
t0 = datetime.now()
results = self.get_results(
get_intro(
self.intro_context,
self.full,
self.channels,
self.members,
self.msg_count,
self.chan_count,
)
)
logging.info(f"scan {guild.id} > results in {delta(t0):,}ms")
response = ""
first = True
for r in results:
if len(response + "\n" + r) > 2000:
await message.channel.send(
response,
reference=message if first else None,
allowed_mentions=discord.AllowedMentions.none(),
)
first = False
response = ""
response += "\n" + r
if len(response) > 0:
await message.channel.send(
response,
reference=message if first else None,
allowed_mentions=discord.AllowedMentions.none(),
)
first = False
response = ""
response += "\n" + r
if len(response) > 0:
await message.channel.send(
response,
reference=message if first else None,
allowed_mentions=discord.AllowedMentions.none(),
)
# Delete custom progress message
await progress.delete()