Implemented clear command

This commit is contained in:
Elnath 2020-12-26 22:20:06 +01:00
parent 394d78fb2c
commit 4861d7b2ed
1 changed files with 13 additions and 0 deletions

View File

@ -72,6 +72,8 @@ class VocalMaisBot(discord.Client):
return await self.forget_channel(message)
elif _check_list_element(contents, 1, "list"):
return await self.list_watched_channels(message)
elif _check_list_element(contents, 1, "clear"):
return await self.clear_watched_channels(message)
else:
return self.sorry_do_not_understand(message)
@ -81,6 +83,7 @@ class VocalMaisBot(discord.Client):
**·** `@{me} register channel_id` : make me watch the voice channel with id `channel_id`
**·** `@{me} forget channel_id` : make me stop watching the voice channel with id `channel_id`
**·** `@{me} list` : list watched channels
**·** `@{me} clear` : stop watching all channels
**·** `@{me} help` : print this help
**·** `@{me} ping` : pong
"""
@ -182,6 +185,16 @@ class VocalMaisBot(discord.Client):
else:
await message.channel.send(f":see_no_evil: I am not watching any voice channel! Do not hesitate to add some by running `@{self.user.display_name} register channel_id`")
async def clear_watched_channels(self, message: discord.Message):
if not await self._check_administrator_for_command(message):
return
guild_id = str(message.guild.id)
if guild_id in self.watched_channels:
self.watched_channels[guild_id]["watched_channels"] = []
self.write_watched_channels_file()
await message.channel.send(":white_check_mark: I am no longer watching any channel")
async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState):
if member.bot:
return