aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Shivansh-007 <[email protected]>2021-04-18 06:27:02 +0530
committerGravatar Shivansh-007 <[email protected]>2021-10-11 12:05:35 +0530
commit00175a55784603c6030e83f2099e7e7daba02654 (patch)
tree478f311d96f32ffcb47a6829c661cc0c31c82d34
parentUse str() rather than f string for single variable. (diff)
Make incidents channel webhook a cog level attribute
This would not fetch it everytime.
-rw-r--r--bot/exts/moderation/incidents.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/bot/exts/moderation/incidents.py b/bot/exts/moderation/incidents.py
index df8d08509..a2548daca 100644
--- a/bot/exts/moderation/incidents.py
+++ b/bot/exts/moderation/incidents.py
@@ -265,6 +265,9 @@ class Incidents(Cog):
"""Prepare `event_lock` and schedule `crawl_task` on start-up."""
self.bot = bot
+ # Webhook to send message link embeds in #incidents
+ self.incidents_webhook = await self.bot.fetch_webhook(Webhooks.incidents)
+
self.event_lock = asyncio.Lock()
self.crawl_task = scheduling.create_task(self.crawl_incidents(), event_loop=self.bot.loop)
@@ -509,8 +512,7 @@ class Incidents(Cog):
"""
if is_incident(message):
webhook_embed_list = await extract_message_links(message, self.bot)
- webhook = await self.bot.fetch_webhook(Webhooks.incidents)
- await self.send_webhooks(webhook_embed_list, message, webhook)
+ await self.send_webhooks(webhook_embed_list, message, self.incidents_webhook)
await add_signals(message)
@@ -533,8 +535,7 @@ class Incidents(Cog):
if is_incident(msg_after):
webhook_embed_list = await extract_message_links(msg_after, self.bot)
- webhook = await self.bot.fetch_webhook(Webhooks.incidents)
- await self.send_webhooks(webhook_embed_list, msg_after, webhook)
+ await self.send_webhooks(webhook_embed_list, msg_after, self.incidents_webhook)
await add_signals(msg_after)
@@ -588,8 +589,7 @@ class Incidents(Cog):
webhook_msg_id = await self.message_link_embeds_cache.get(message.id)
if webhook_msg_id:
- webhook = await self.bot.fetch_webhook(Webhooks.incidents)
- await webhook.delete_message(webhook_msg_id)
+ await self.incidents_webhook.delete_message(webhook_msg_id)
await self.message_link_embeds_cache.delete(message.id)
log.trace("Successfully deleted discord links webhook message.")