aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar momothereal <[email protected]>2018-07-18 16:50:53 -0400
committerGravatar momothereal <[email protected]>2018-07-18 16:50:53 -0400
commit480da64050d7c1702e700586421e34bc284dd392 (patch)
tree7fe143ac57a4ad6847a091b7eed3823898d3c231
parentAdds framework for commands and warning command. (diff)
Add default infraction URLs to config, cleanup moderation cog
-rw-r--r--bot/cogs/moderation.py25
-rw-r--r--bot/constants.py2
-rw-r--r--config-default.yml4
3 files changed, 15 insertions, 16 deletions
diff --git a/bot/cogs/moderation.py b/bot/cogs/moderation.py
index 80712b259..23188ea57 100644
--- a/bot/cogs/moderation.py
+++ b/bot/cogs/moderation.py
@@ -1,16 +1,15 @@
import logging
-from datetime import datetime, timedelta
-from discord import Colour, Embed, User, utils
-from discord.ext.commands import Bot, Context, command
+from discord import User
+from discord.ext.commands import Bot, command
-from bot.constants import Channels, Keys, Roles, URLs
+from bot.constants import Keys, Roles, URLs
from bot.decorators import with_role
log = logging.getLogger(__name__)
-class Defcon:
+class Moderation:
"""
Rowboat replacement moderation tools.
"""
@@ -19,18 +18,17 @@ class Defcon:
self.bot = bot
self.headers = {"X-API-KEY": Keys.site_api}
-
@with_role(Roles.admin, Roles.owner, Roles.moderator)
@command(name="moderation.warn")
- async def warn(self, ctx, user: User, reason: str):
+ async def warn(self, ctx, user: User, *, reason: str):
"""
Create a warning infraction in the database for a user.
:param user: accepts user mention, ID, etc.
- :param reason: Wrap in quotes to make a warning larger than one word.
+ :param reason: the reason for the warning.
"""
try:
- response = await self.bot.http_session.put(
+ response = await self.bot.http_session.post(
URLs.site_infractions,
headers=self.headers,
json={
@@ -42,7 +40,7 @@ class Defcon:
)
except Exception:
# Same as defcon. Probably not the best but may work for now.
- log.Exception("There was an error adding an infraction.")
+ log.exception("There was an error adding an infraction.")
await ctx.send("There was an error updating the site.")
return
@@ -50,7 +48,7 @@ class Defcon:
@with_role(Roles.admin, Roles.owner, Roles.moderator)
@command(name="moderation.ban")
- async def ban(self, ctx, user: User, reason: str, duration: str=None):
+ async def ban(self, ctx, user: User, reason: str, duration: str = None):
"""
Create a banning infraction in the database for a user.
:param user: Accepts user mention, ID, etc.
@@ -60,7 +58,7 @@ class Defcon:
@with_role(Roles.admin, Roles.owner, Roles.moderator)
@command(name="moderation.mute")
- async def mute(self, ctx, user: User, reason: str, duration: str=None):
+ async def mute(self, ctx, user: User, reason: str, duration: str = None):
"""
Create a muting infraction in the database for a user.
:param user: Accepts user mention, ID, etc.
@@ -69,9 +67,6 @@ class Defcon:
"""
-
-
-
def setup(bot):
bot.add_cog(Moderation(bot))
# Here we'll need to call a command I haven't made yet
diff --git a/bot/constants.py b/bot/constants.py
index 4c7a7f09d..c435fbad9 100644
--- a/bot/constants.py
+++ b/bot/constants.py
@@ -264,7 +264,7 @@ class URLs(metaclass=YAMLGetter):
site_user_complete_api: str
site_infractions: str
site_infractions_user: str
- site_infractions_types: str
+ site_infractions_type: str
site_infractions_by_id: str
status: str
paste_service: str
diff --git a/config-default.yml b/config-default.yml
index 5b87f8d78..8f0c32af9 100644
--- a/config-default.yml
+++ b/config-default.yml
@@ -85,5 +85,9 @@ urls:
site_tags_api: 'https://api.pythondiscord.com/bot/tags'
site_user_api: 'https://api.pythondiscord.com/bot/users'
site_user_complete_api: 'https://api.pythondiscord.com/bot/users/complete'
+ site_infractions: 'https://api.pythondiscord.com/bot/infractions'
+ site_infractions_user: 'https://api.pythondiscord.com/bot/infractions/user/{user_id}'
+ site_infractions_type: 'https://api.pythondiscord.com/bot/infractions/type/{infraction_type}'
+ site_infractions_by_id: 'https://api.pythondiscord.com/bot/infractions/id/{infraction_id}'
status: !ENV 'STATUS_URL'
paste_service: 'https://paste.pydis.com/{key}'