Update roleping to include users with blocked role

This commit is contained in:
Zeva Rose 2021-07-14 12:30:27 -06:00
parent 0ef839e2b5
commit 3c661fbf8c

View file

@ -9,13 +9,12 @@ from discord.ext import commands
from discord.ext.tasks import loop
from discord.utils import find, get
from discord_slash import SlashCommand
from psutil import Process
from jarvis import logo, utils
from jarvis.config import get_config
from jarvis.utils import build_embed
from jarvis.utils.db import DBManager
from jarvis.utils.field import Field
from psutil import Process
if asyncio.get_event_loop().is_closed():
asyncio.set_event_loop(asyncio.new_event_loop())
@ -128,14 +127,17 @@ async def on_message(message: Message):
roleping = db.jarvis.settings.find_one(
{"guild": message.guild.id, "setting": "roleping"}
)
if roleping and any(
x.id in roleping["value"] for x in message.role_mentions
):
await message.delete()
roles = []
for mention in message.role_mentions:
roles.append(mention.id)
for mention in message.mentions:
for role in mention.roles:
roles.append(role.id)
if roleping and any(x.id in roleping["value"] for x in roles):
db.jarvis.warns.insert_one(
{
"user": message.author.id,
"reason": "Pinged a blocked role",
"reason": "Pinged a blocked role/user with a blocked role",
"admin": get_config().client_id,
"time": datetime.now(),
"guild": message.guild.id,
@ -143,7 +145,13 @@ async def on_message(message: Message):
"active": True,
}
)
fields = [Field("Reason", "Pinged a blocked role", False)]
fields = [
Field(
"Reason",
"Pinged a blocked role/user with a blocked role",
False,
)
]
embed = build_embed(
title="Warning",
description=f"{message.author.mention} has been warned",
@ -156,7 +164,8 @@ async def on_message(message: Message):
icon_url=message.author.avatar_url,
)
embed.set_footer(
text=f"{message.author.name}#{message.author.discriminator} | {message.author.id}"
text=f"{message.author.name}#{message.author.discriminator} "
+ f"| {message.author.id}"
)
await message.channel.send(embed=embed)
autopurge = db.jarvis.autopurge.find_one(