diff options
| author | 2018-07-30 13:13:43 +0000 | |
|---|---|---|
| committer | 2018-07-30 13:13:43 +0000 | |
| commit | 84250d2813d3fa3bf8281e110b7898c367f316a6 (patch) | |
| tree | 11f61431af69151961773a609a521d21cb21a96a | |
| parent | Merge branch 'bugfix/newline-filter-max-count' into 'master' (diff) | |
| parent | Add the `otname delete` command. (diff) | |
Merge branch 'enhancement/delete-otname-command' into 'master'
Add the `otname delete` command.
Closes #40
See merge request python-discord/projects/bot!38
| -rw-r--r-- | bot/cogs/off_topic_names.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/bot/cogs/off_topic_names.py b/bot/cogs/off_topic_names.py index f089e0b5a..bcf3148f8 100644 --- a/bot/cogs/off_topic_names.py +++ b/bot/cogs/off_topic_names.py @@ -111,6 +111,32 @@ class OffTopicNames: error_reason = response.get('message', "No reason provided.") await ctx.send(f":warning: got non-200 from the API: {error_reason}") + @otname_group.command(name='delete', aliases=('remove', 'rm', 'del', 'd')) + @with_role(Roles.owner, Roles.admin, Roles.moderator) + async def delete_command(self, ctx, name: OffTopicName): + """Removes a off-topic name from the rotation.""" + + result = await self.bot.http_session.delete( + URLs.site_off_topic_names_api, + headers=self.headers, + params={'name': name} + ) + + response = await result.json() + + if result.status == 200: + if response['deleted'] == 0: + await ctx.send(f":warning: No name matching `{name}` was found in the database.") + else: + log.info( + f"{ctx.author.name}#{ctx.author.discriminator}" + f" deleted the off-topic channel name '{name}" + ) + await ctx.send(":ok_hand:") + else: + error_reason = response.get('message', "No reason provided.") + await ctx.send(f":warning: got non-200 from the API: {error_reason}") + @otname_group.command(name='list', aliases=('l',)) @with_role(Roles.owner, Roles.admin, Roles.moderator) async def list_command(self, ctx): |