-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfo_channels.py
34 lines (27 loc) · 1.21 KB
/
info_channels.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
Manages updateing info-channels (Currently only `log` channel)
"""
from typing import Union
import discord
from discord.ext import commands
class InfoChannels(commands.Cog):
def __init__(self, bot: commands.Bot):
print('Loading InfoChannels module...', end='')
self.bot = bot
self.guild_config_cog = bot.get_cog('GuildConfigCog')
self.allowed_mentions = discord.AllowedMentions(everyone=False, users=False, roles=False)
print(' Done')
@commands.Cog.listener()
async def on_member_ban(self, guild: discord.Guild, user: Union[discord.User, discord.Member]):
guild_config = await self.guild_config_cog.get_guild(guild)
log_channel = await guild_config.get_log_channel()
if log_channel:
await log_channel.send('{} was banned'.format(str(user)))
@commands.Cog.listener()
async def on_member_unban(self, guild: discord.Guild, user: discord.User):
guild_config = await self.guild_config_cog.get_guild(guild)
log_channel = await guild_config.get_log_channel()
if log_channel:
await log_channel.send('{} was unbanned'.format(str(user)))
def setup(bot: commands.Bot):
bot.add_cog(InfoChannels(bot))