Change ban/kick messages to embeds, closes #70
This commit is contained in:
parent
0496e288c2
commit
a940ba7aba
2 changed files with 72 additions and 19 deletions
|
@ -14,8 +14,15 @@ from psutil import Process
|
||||||
from jarvis import logo, utils
|
from jarvis import logo, utils
|
||||||
from jarvis.config import get_config
|
from jarvis.config import get_config
|
||||||
from jarvis.db import DBManager
|
from jarvis.db import DBManager
|
||||||
from jarvis.db.types import (Autopurge, Autoreact, Ban, Lock, Mute, Setting,
|
from jarvis.db.types import (
|
||||||
Warning)
|
Autopurge,
|
||||||
|
Autoreact,
|
||||||
|
Ban,
|
||||||
|
Lock,
|
||||||
|
Mute,
|
||||||
|
Setting,
|
||||||
|
Warning,
|
||||||
|
)
|
||||||
from jarvis.utils import build_embed
|
from jarvis.utils import build_embed
|
||||||
from jarvis.utils.field import Field
|
from jarvis.utils.field import Field
|
||||||
|
|
||||||
|
|
|
@ -136,8 +136,25 @@ class AdminCog(commands.Cog):
|
||||||
if mtype == "temp":
|
if mtype == "temp":
|
||||||
user_message += f"\nDuration: {duration} hours"
|
user_message += f"\nDuration: {duration} hours"
|
||||||
|
|
||||||
|
fields = [Field(name="Type", value=mtype)]
|
||||||
|
|
||||||
|
if mtype == "temp":
|
||||||
|
fields.append(Field(name="Duration", value=f"{duration} hour(s)"))
|
||||||
|
|
||||||
|
user_embed = build_embed(
|
||||||
|
title="You have been banned",
|
||||||
|
description=f"Reason: {reason}",
|
||||||
|
fields=fields,
|
||||||
|
)
|
||||||
|
|
||||||
|
user_embed.set_author(
|
||||||
|
name=ctx.author.name + "#" + ctx.author.discriminator,
|
||||||
|
icon_url=ctx.author.avatar_url,
|
||||||
|
)
|
||||||
|
user_embed.set_thumbnail(url=ctx.guild.icon_url)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await user.send(user_message)
|
await user.send(embed=user_embed)
|
||||||
except Exception:
|
except Exception:
|
||||||
send_failed = True
|
send_failed = True
|
||||||
try:
|
try:
|
||||||
|
@ -149,14 +166,21 @@ class AdminCog(commands.Cog):
|
||||||
if mtype == "soft":
|
if mtype == "soft":
|
||||||
await ctx.guild.unban(user, reason="Ban was softban")
|
await ctx.guild.unban(user, reason="Ban was softban")
|
||||||
|
|
||||||
message = (
|
fields.append(Field(name="DM Sent?", value=str(not send_failed)))
|
||||||
f"{user.name} has been {mtype}banned from {guild_name}."
|
|
||||||
+ f" Reason:\n{reason}"
|
admin_embed = build_embed(
|
||||||
|
title="User Banned",
|
||||||
|
description=f"Reason: {reason}",
|
||||||
|
fields=fields,
|
||||||
)
|
)
|
||||||
|
|
||||||
if send_failed:
|
admin_embed.set_author(
|
||||||
message += "\n**Note: DM failed to send to user.**"
|
name=user.name + "#" + user.discriminator, icon_url=user.avatar_url
|
||||||
await ctx.send(message)
|
)
|
||||||
|
admin_embed.set_thumbnail(url=user.avatar_url)
|
||||||
|
admin_embed.set_footer(text=f"User ID: {user.id}")
|
||||||
|
|
||||||
|
await ctx.send(embed=admin_embed)
|
||||||
if type != "temp":
|
if type != "temp":
|
||||||
duration = None
|
duration = None
|
||||||
active = True
|
active = True
|
||||||
|
@ -475,17 +499,39 @@ class AdminCog(commands.Cog):
|
||||||
"Mr. Stark is displeased with your presence. Please leave."
|
"Mr. Stark is displeased with your presence. Please leave."
|
||||||
)
|
)
|
||||||
guild_name = ctx.guild.name
|
guild_name = ctx.guild.name
|
||||||
try:
|
embed = build_embed(
|
||||||
await user.send(
|
title=f"You have been kicked from {guild_name}",
|
||||||
f"You have been kicked from {guild_name}. Reason:\n{reason}"
|
description=f"Reason: {reason}",
|
||||||
)
|
fields=[],
|
||||||
except Exception:
|
|
||||||
await ctx.send("Unable to message user.")
|
|
||||||
await ctx.guild.kick(user, reason=reason)
|
|
||||||
await ctx.send(
|
|
||||||
f"{user.name} has been kicked from {guild_name}."
|
|
||||||
+ f"Reason:\n{reason}"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
embed.set_author(
|
||||||
|
name=ctx.author.name + "#" + ctx.author.discriminator,
|
||||||
|
icon_url=ctx.author.avatar_url,
|
||||||
|
)
|
||||||
|
embed.set_thumbnail(ctx.guild.icon_url)
|
||||||
|
|
||||||
|
send_failed = False
|
||||||
|
try:
|
||||||
|
await user.send(embed=embed)
|
||||||
|
except Exception:
|
||||||
|
send_failed = True
|
||||||
|
await ctx.guild.kick(user, reason=reason)
|
||||||
|
|
||||||
|
embed = build_embed(
|
||||||
|
title="User Kicked",
|
||||||
|
description=f"Reason: {reason}",
|
||||||
|
fields=[],
|
||||||
|
)
|
||||||
|
|
||||||
|
embed.set_author(
|
||||||
|
name=user.name + "#" + user.discriminator,
|
||||||
|
icon_url=user.avatar_url,
|
||||||
|
)
|
||||||
|
embed.set_thumbnail(url=user.avatar_url)
|
||||||
|
embed.set_footer(text=f"User ID: {user.id}")
|
||||||
|
|
||||||
|
await ctx.send(embed=embed)
|
||||||
_ = Kick(
|
_ = Kick(
|
||||||
user=user.id,
|
user=user.id,
|
||||||
reason=reason,
|
reason=reason,
|
||||||
|
|
Loading…
Add table
Reference in a new issue