aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar sco1 <[email protected]>2018-12-28 14:42:08 -0500
committerGravatar sco1 <[email protected]>2018-12-28 14:42:08 -0500
commit912923418924749af9295232dfae398f0e4dda4f (patch)
treefeda4ee1c663d98ba84f1edd762ea2be433f50a2
parentAdd #defcon to channel constants (diff)
Add defcon channel topic updating
-rw-r--r--bot/cogs/defcon.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/bot/cogs/defcon.py b/bot/cogs/defcon.py
index 5fb5ef88f..d26170444 100644
--- a/bot/cogs/defcon.py
+++ b/bot/cogs/defcon.py
@@ -10,7 +10,6 @@ from bot.decorators import with_role
log = logging.getLogger(__name__)
-
REJECTION_MESSAGE = """
Hi, {user} - Thanks for your interest in our server!
@@ -22,6 +21,8 @@ will be resolved soon. In the meantime, please feel free to peruse the resources
<https://pythondiscord.com/>, and have a nice day!
"""
+BASE_CHANNEL_TOPIC = "Python Discord Defense Mechanism"
+
class Defcon:
"""Time-sensitive server defense mechanisms"""
@@ -64,6 +65,8 @@ class Defcon:
self.days = timedelta(days=0)
log.warning(f"DEFCON disabled")
+ self.update_channel_topic()
+
async def on_member_join(self, member: Member):
if self.enabled and self.days.days > 0:
now = datetime.utcnow()
@@ -148,6 +151,8 @@ class Defcon:
f"**Days:** {self.days.days}\n\n"
)
+ self.update_channel_topic()
+
@defcon_group.command(name='disable', aliases=('off', 'd'))
@with_role(Roles.admin, Roles.owner)
async def disable_command(self, ctx: Context):
@@ -189,6 +194,8 @@ class Defcon:
f"**Staffer:** {ctx.author.name}#{ctx.author.discriminator} (`{ctx.author.id}`)"
)
+ self.update_channel_topic()
+
@defcon_group.command(name='status', aliases=('s',))
@with_role(Roles.admin, Roles.owner)
async def status_command(self, ctx: Context):
@@ -250,6 +257,21 @@ class Defcon:
f"**Days:** {self.days.days}"
)
+ self.update_channel_topic()
+
+ async def update_channel_topic(self):
+ """
+ Update the #defcon channel topic with the current DEFCON status
+ """
+
+ if self.enabled:
+ new_topic = f"{BASE_CHANNEL_TOPIC}\n(Status: Enabled, Threshold: {self.days} days)"
+ else:
+ new_topic = f"{BASE_CHANNEL_TOPIC}\n(Status: Disabled)"
+
+ defcon_channel = await self.bot.guild.get_channel(Channels.defcon)
+ await defcon_channel.edit(topic=new_topic)
+
def setup(bot: Bot):
bot.add_cog(Defcon(bot))