Implemented clear command
This commit is contained in:
parent
394d78fb2c
commit
4861d7b2ed
|
|
@ -72,6 +72,8 @@ class VocalMaisBot(discord.Client):
|
||||||
return await self.forget_channel(message)
|
return await self.forget_channel(message)
|
||||||
elif _check_list_element(contents, 1, "list"):
|
elif _check_list_element(contents, 1, "list"):
|
||||||
return await self.list_watched_channels(message)
|
return await self.list_watched_channels(message)
|
||||||
|
elif _check_list_element(contents, 1, "clear"):
|
||||||
|
return await self.clear_watched_channels(message)
|
||||||
else:
|
else:
|
||||||
return self.sorry_do_not_understand(message)
|
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} 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} forget channel_id` : make me stop watching the voice channel with id `channel_id`
|
||||||
**·** `@{me} list` : list watched channels
|
**·** `@{me} list` : list watched channels
|
||||||
|
**·** `@{me} clear` : stop watching all channels
|
||||||
**·** `@{me} help` : print this help
|
**·** `@{me} help` : print this help
|
||||||
**·** `@{me} ping` : pong
|
**·** `@{me} ping` : pong
|
||||||
"""
|
"""
|
||||||
|
|
@ -182,6 +185,16 @@ class VocalMaisBot(discord.Client):
|
||||||
else:
|
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`")
|
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):
|
async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState):
|
||||||
if member.bot:
|
if member.bot:
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue