Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: infraction info to use discord timestamps, remove unused import #449

Open
wants to merge 6 commits into
base: live
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GearBot/Bot/GearBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ async def on_error(self, event, *args, **kwargs):
async def on_guild_update(self, before, after):
await TheRealGearBot.on_guild_update(before, after)


#### reloading
1 change: 1 addition & 0 deletions GearBot/Bot/TheRealGearBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ async def message_flusher():
await asyncio.sleep(60)
await DBUtils.flush()


async def on_message(bot, message:Message):
if message.author.bot:
if message.author.id == bot.user.id:
Expand Down
20 changes: 11 additions & 9 deletions GearBot/Cogs/Infractions.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import asyncio
import json
import re
import datetime

import disnake
from disnake import Interaction
from disnake import Interaction, utils
from disnake.ext import commands
from disnake.ext.commands import BadArgument, Greedy, BucketType

Expand All @@ -20,6 +19,12 @@


class Infractions(BaseCog):

def inf_time(self, inf_timestamp: int):
"""Returns the infraction time as discord timestamps."""
long_dt_time = utils.format_dt(inf_timestamp, 'F')
relative_time = utils.format_dt(inf_timestamp, 'R')
return f"{long_dt_time} ({relative_time})"

async def _warn(self, ctx, target, *, reason, message=True, dm_action=True):
i = await InfractionUtils.add_infraction(ctx.guild.id, target.id, ctx.author.id, "Warn", reason)
Expand Down Expand Up @@ -117,7 +122,8 @@ def check(interaction: Interaction):
@commands.group(aliases=["infraction", "infractions"], invoke_without_command=True)
async def inf(self, ctx: commands.Context):
"""inf_help"""
pass
if ctx.subcommand_passed is None:
await ctx.invoke(self.bot.get_command("help"), query="infraction")

@inf.command()
async def search(self, ctx: commands.Context, fields: commands.Greedy[InfSearchLocation] = None, *,
Expand Down Expand Up @@ -272,13 +278,9 @@ async def info(self, ctx, infraction: ServerInfraction):
embed.add_field(name=Translator.translate('user', ctx), value=Utils.clean_user(user))
embed.add_field(name=Translator.translate('mod_id', ctx), value=infraction.mod_id)
embed.add_field(name=Translator.translate('user_id', ctx), value=infraction.user_id)
embed.add_field(name=Translator.translate('inf_added', ctx),
value=datetime.datetime.utcfromtimestamp(infraction.start).replace(
tzinfo=datetime.timezone.utc))
embed.add_field(name=Translator.translate('inf_added', ctx), value=self.inf_time(infraction.start))
if infraction.end is not None:
embed.add_field(name=Translator.translate('inf_end', ctx),
value=datetime.datetime.utcfromtimestamp(infraction.end).replace(
tzinfo=datetime.timezone.utc))
embed.add_field(name=Translator.translate('inf_end', ctx), value=self.inf_time(infraction.end))
embed.add_field(name=Translator.translate('inf_active', ctx),
value=MessageUtils.assemble(ctx, 'YES' if infraction.active else 'NO',
str(infraction.active).lower()))
Expand Down