mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[V3 Modlog] Modlog layout and formatting changes (#1089)
* Modlog layout and formatting changes * Remove unused import
This commit is contained in:
parent
14ba572acd
commit
fb0be051aa
@ -64,91 +64,91 @@ class Mod:
|
|||||||
{
|
{
|
||||||
"name": "ban",
|
"name": "ban",
|
||||||
"default_setting": True,
|
"default_setting": True,
|
||||||
"image": ":hammer:",
|
"image": "\N{HAMMER}",
|
||||||
"case_str": "Ban",
|
"case_str": "Ban",
|
||||||
"audit_type": "ban"
|
"audit_type": "ban"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "kick",
|
"name": "kick",
|
||||||
"default_setting": True,
|
"default_setting": True,
|
||||||
"image": ":boot:",
|
"image": "\N{WOMANS BOOTS}",
|
||||||
"case_str": "Kick",
|
"case_str": "Kick",
|
||||||
"audit_type": "kick"
|
"audit_type": "kick"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "hackban",
|
"name": "hackban",
|
||||||
"default_setting": True,
|
"default_setting": True,
|
||||||
"image": ":bust_in_silhouette: :hammer:",
|
"image": "\N{BUST IN SILHOUETTE}\N{HAMMER}",
|
||||||
"case_str": "Hackban",
|
"case_str": "Hackban",
|
||||||
"audit_type": "ban"
|
"audit_type": "ban"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "softban",
|
"name": "softban",
|
||||||
"default_setting": True,
|
"default_setting": True,
|
||||||
"image": ":dash: :hammer:",
|
"image": "\N{DASH SYMBOL}\N{HAMMER}",
|
||||||
"case_str": "Softban",
|
"case_str": "Softban",
|
||||||
"audit_type": "ban"
|
"audit_type": "ban"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "unban",
|
"name": "unban",
|
||||||
"default_setting": True,
|
"default_setting": True,
|
||||||
"image": ":dove:",
|
"image": "\N{DOVE OF PEACE}",
|
||||||
"case_str": "Unban",
|
"case_str": "Unban",
|
||||||
"audit_type": "unban"
|
"audit_type": "unban"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "voiceban",
|
"name": "voiceban",
|
||||||
"default_setting": True,
|
"default_setting": True,
|
||||||
"image": ":mute:",
|
"image": "\N{SPEAKER WITH CANCELLATION STROKE}",
|
||||||
"case_str": "Voice Ban",
|
"case_str": "Voice Ban",
|
||||||
"audit_type": "member_update"
|
"audit_type": "member_update"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "voiceunban",
|
"name": "voiceunban",
|
||||||
"default_setting": True,
|
"default_setting": True,
|
||||||
"image": ":speaker:",
|
"image": "\N{SPEAKER}",
|
||||||
"case_str": "Voice Unban",
|
"case_str": "Voice Unban",
|
||||||
"audit_type": "member_update"
|
"audit_type": "member_update"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "vmute",
|
"name": "vmute",
|
||||||
"default_setting": False,
|
"default_setting": False,
|
||||||
"image": ":mute:",
|
"image": "\N{SPEAKER WITH CANCELLATION STROKE}",
|
||||||
"case_str": "Voice Mute",
|
"case_str": "Voice Mute",
|
||||||
"audit_type": "overwrite_update"
|
"audit_type": "overwrite_update"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "cmute",
|
"name": "cmute",
|
||||||
"default_setting": False,
|
"default_setting": False,
|
||||||
"image": ":mute:",
|
"image": "\N{SPEAKER WITH CANCELLATION STROKE}",
|
||||||
"case_str": "Channel Mute",
|
"case_str": "Channel Mute",
|
||||||
"audit_type": "overwrite_update"
|
"audit_type": "overwrite_update"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "smute",
|
"name": "smute",
|
||||||
"default_setting": True,
|
"default_setting": True,
|
||||||
"image": ":mute:",
|
"image": "\N{SPEAKER WITH CANCELLATION STROKE}",
|
||||||
"case_str": "Guild Mute",
|
"case_str": "Guild Mute",
|
||||||
"audit_type": "overwrite_update"
|
"audit_type": "overwrite_update"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "vunmute",
|
"name": "vunmute",
|
||||||
"default_setting": False,
|
"default_setting": False,
|
||||||
"image": ":speaker:",
|
"image": "\N{SPEAKER}",
|
||||||
"case_str": "Voice Unmute",
|
"case_str": "Voice Unmute",
|
||||||
"audit_type": "overwrite_update"
|
"audit_type": "overwrite_update"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "cunmute",
|
"name": "cunmute",
|
||||||
"default_setting": False,
|
"default_setting": False,
|
||||||
"image": ":speaker:",
|
"image": "\N{SPEAKER}",
|
||||||
"case_str": "Channel Unmute",
|
"case_str": "Channel Unmute",
|
||||||
"audit_type": "overwrite_update"
|
"audit_type": "overwrite_update"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sunmute",
|
"name": "sunmute",
|
||||||
"default_setting": True,
|
"default_setting": True,
|
||||||
"image": ":speaker:",
|
"image": "\N{SPEAKER}",
|
||||||
"case_str": "Guild Unmute",
|
"case_str": "Guild Unmute",
|
||||||
"audit_type": "overwrite_update"
|
"audit_type": "overwrite_update"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import discord
|
|
||||||
import os
|
import os
|
||||||
|
from datetime import datetime
|
||||||
|
from typing import List, Union
|
||||||
|
|
||||||
|
import discord
|
||||||
|
|
||||||
from redbot.core import Config
|
from redbot.core import Config
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
from redbot.core.utils.chat_formatting import bold
|
|
||||||
from typing import List, Union
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"Case", "CaseType", "get_next_case_number", "get_case", "get_all_cases",
|
"Case", "CaseType", "get_next_case_number", "get_case", "get_all_cases",
|
||||||
@ -83,37 +83,37 @@ class Case:
|
|||||||
|
|
||||||
async def message_content(self):
|
async def message_content(self):
|
||||||
"""
|
"""
|
||||||
Format a case message
|
Format a case message
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
discord.Embed
|
discord.Embed
|
||||||
A rich embed representing a case message
|
A rich embed representing a case message
|
||||||
|
|
||||||
"""
|
"""
|
||||||
casetype = await get_casetype(self.action_type)
|
casetype = await get_casetype(self.action_type)
|
||||||
title = "{}".format(bold("Case #{} | {} {}".format(
|
title = "{}".format("Case #{} | {} {}".format(
|
||||||
self.case_number, casetype.case_str, casetype.image)))
|
self.case_number, casetype.case_str, casetype.image))
|
||||||
|
|
||||||
if self.reason:
|
if self.reason:
|
||||||
reason = "**Reason:** {}".format(self.reason)
|
reason = "**Reason:** {}".format(self.reason)
|
||||||
else:
|
else:
|
||||||
reason = \
|
reason = \
|
||||||
"**Reason:** Type [p]reason {} <reason> to add it".format(
|
"**Reason:** Use `[p]reason {} <reason>` to add it".format(
|
||||||
self.case_number
|
self.case_number
|
||||||
)
|
)
|
||||||
|
|
||||||
emb = discord.Embed(title=title, description=reason)
|
emb = discord.Embed(title=title, description=reason)
|
||||||
|
user = "{}#{} ({})\n".format(
|
||||||
|
self.user.name, self.user.discriminator, self.user.id)
|
||||||
|
emb.set_author(name=user, icon_url=self.user.avatar_url)
|
||||||
|
|
||||||
moderator = "{}#{} ({})\n".format(
|
moderator = "{}#{} ({})\n".format(
|
||||||
self.moderator.name,
|
self.moderator.name,
|
||||||
self.moderator.discriminator,
|
self.moderator.discriminator,
|
||||||
self.moderator.id
|
self.moderator.id
|
||||||
)
|
)
|
||||||
emb.set_author(name=moderator, icon_url=self.moderator.avatar_url)
|
emb.add_field(name="Moderator", value=moderator, inline=False)
|
||||||
user = "{}#{} ({})\n".format(
|
|
||||||
self.user.name, self.user.discriminator, self.user.id)
|
|
||||||
emb.add_field(name="User", value=user)
|
|
||||||
if self.until:
|
if self.until:
|
||||||
start = datetime.fromtimestamp(self.created_at)
|
start = datetime.fromtimestamp(self.created_at)
|
||||||
end = datetime.fromtimestamp(self.until)
|
end = datetime.fromtimestamp(self.until)
|
||||||
@ -126,7 +126,7 @@ class Case:
|
|||||||
emb.add_field(name="Duration", value=duration)
|
emb.add_field(name="Duration", value=duration)
|
||||||
|
|
||||||
if self.channel:
|
if self.channel:
|
||||||
emb.add_field(name="Channel", value=self.channel.name)
|
emb.add_field(name="Channel", value=self.channel.name, inline=False)
|
||||||
if self.amended_by:
|
if self.amended_by:
|
||||||
amended_by = "{}#{} ({})".format(
|
amended_by = "{}#{} ({})".format(
|
||||||
self.amended_by.name,
|
self.amended_by.name,
|
||||||
@ -151,7 +151,7 @@ class Case:
|
|||||||
-------
|
-------
|
||||||
dict
|
dict
|
||||||
The case in the form of a dict
|
The case in the form of a dict
|
||||||
|
|
||||||
"""
|
"""
|
||||||
data = {
|
data = {
|
||||||
"case_number": self.case_number,
|
"case_number": self.case_number,
|
||||||
@ -181,12 +181,12 @@ class Case:
|
|||||||
The bot's instance. Needed to get the target user
|
The bot's instance. Needed to get the target user
|
||||||
data: dict
|
data: dict
|
||||||
The JSON representation of the case to be gotten
|
The JSON representation of the case to be gotten
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
Case
|
Case
|
||||||
The case object for the requested case
|
The case object for the requested case
|
||||||
|
|
||||||
"""
|
"""
|
||||||
guild = mod_channel.guild
|
guild = mod_channel.guild
|
||||||
message = await mod_channel.get_message(data["message"])
|
message = await mod_channel.get_message(data["message"])
|
||||||
@ -330,7 +330,7 @@ async def get_case(case_number: int, guild: discord.Guild,
|
|||||||
-------
|
-------
|
||||||
Case
|
Case
|
||||||
The case associated with the case number
|
The case associated with the case number
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
------
|
------
|
||||||
RuntimeError
|
RuntimeError
|
||||||
@ -397,7 +397,7 @@ async def create_case(guild: discord.Guild, created_at: datetime, action_type: s
|
|||||||
The time the action is in effect until
|
The time the action is in effect until
|
||||||
channel: `discord.TextChannel` or `discord.VoiceChannel`
|
channel: `discord.TextChannel` or `discord.VoiceChannel`
|
||||||
The channel the action was taken in
|
The channel the action was taken in
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
Case
|
Case
|
||||||
@ -407,7 +407,7 @@ async def create_case(guild: discord.Guild, created_at: datetime, action_type: s
|
|||||||
------
|
------
|
||||||
RuntimeError
|
RuntimeError
|
||||||
If the mod log channel doesn't exist
|
If the mod log channel doesn't exist
|
||||||
|
|
||||||
"""
|
"""
|
||||||
mod_channel = None
|
mod_channel = None
|
||||||
if hasattr(guild, "owner"):
|
if hasattr(guild, "owner"):
|
||||||
@ -577,12 +577,12 @@ async def register_casetypes(new_types: List[dict]) -> List[CaseType]:
|
|||||||
----------
|
----------
|
||||||
new_types: list
|
new_types: list
|
||||||
The new types to register
|
The new types to register
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
bool
|
bool
|
||||||
`True` if all were registered successfully
|
`True` if all were registered successfully
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
------
|
------
|
||||||
RuntimeError
|
RuntimeError
|
||||||
@ -593,7 +593,7 @@ async def register_casetypes(new_types: List[dict]) -> List[CaseType]:
|
|||||||
See Also
|
See Also
|
||||||
--------
|
--------
|
||||||
redbot.core.modlog.register_casetype
|
redbot.core.modlog.register_casetype
|
||||||
|
|
||||||
"""
|
"""
|
||||||
type_list = []
|
type_list = []
|
||||||
for new_type in new_types:
|
for new_type in new_types:
|
||||||
@ -622,7 +622,7 @@ async def get_modlog_channel(guild: discord.Guild
|
|||||||
----------
|
----------
|
||||||
guild: `discord.Guild`
|
guild: `discord.Guild`
|
||||||
The guild to get the modlog channel for
|
The guild to get the modlog channel for
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
`discord.TextChannel` or `None`
|
`discord.TextChannel` or `None`
|
||||||
@ -654,7 +654,7 @@ async def set_modlog_channel(guild: discord.Guild,
|
|||||||
The guild to set a mod log channel for
|
The guild to set a mod log channel for
|
||||||
channel: `discord.TextChannel` or `None`
|
channel: `discord.TextChannel` or `None`
|
||||||
The channel to be set as modlog channel
|
The channel to be set as modlog channel
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
bool
|
bool
|
||||||
@ -675,7 +675,7 @@ async def reset_cases(guild: discord.Guild) -> bool:
|
|||||||
----------
|
----------
|
||||||
guild: `discord.Guild`
|
guild: `discord.Guild`
|
||||||
The guild to reset cases for
|
The guild to reset cases for
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
bool
|
bool
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user