Closes #20, implement mass mention prevention. TODO: Implement warning for mass mentions
This commit is contained in:
parent
987e349488
commit
1f7ecb3579
2 changed files with 41 additions and 2 deletions
|
@ -80,6 +80,16 @@ async def on_message(message: Message):
|
||||||
if autoreact:
|
if autoreact:
|
||||||
for reaction in autoreact["reactions"]:
|
for reaction in autoreact["reactions"]:
|
||||||
await message.add_reaction(reaction)
|
await message.add_reaction(reaction)
|
||||||
|
massmention = db.jarvis.settings.find_one(
|
||||||
|
{"guild": message.guild.id, "setting": "massmention"}
|
||||||
|
)
|
||||||
|
if (
|
||||||
|
massmention["value"] > 0
|
||||||
|
and len(message.mentions) >= massmention["value"]
|
||||||
|
):
|
||||||
|
await message.delete()
|
||||||
|
# TODO: Implement warnings on massmention
|
||||||
|
await message.channel.send("Please do not mass mention.")
|
||||||
await jarvis.process_commands(message)
|
await jarvis.process_commands(message)
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,7 +105,13 @@ async def on_guild_join(guild):
|
||||||
)
|
)
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
await general.send("Importing all preferences from home interface...")
|
await general.send("Importing all preferences from home interface...")
|
||||||
await asyncio.sleep(5)
|
|
||||||
|
# Set some default settings
|
||||||
|
db = DBManager(get_config().mongo).mongo
|
||||||
|
db.jarvis.settings.insert_one(
|
||||||
|
{"guild": guild.id, "setting": "massmention", "value": 5}
|
||||||
|
)
|
||||||
|
|
||||||
await general.send("Systems are now fully operational")
|
await general.send("Systems are now fully operational")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class SettingsCog(commands.Cog):
|
||||||
def update_settings(self, setting, value, guild):
|
def update_settings(self, setting, value, guild):
|
||||||
settings = {"setting": setting, "value": value, "guild": guild}
|
settings = {"setting": setting, "value": value, "guild": guild}
|
||||||
updated = self.db.jarvis.settings.update_one(
|
updated = self.db.jarvis.settings.update_one(
|
||||||
{"settings": setting, "guild": guild},
|
{"setting": setting, "guild": guild},
|
||||||
{"$set": settings},
|
{"$set": settings},
|
||||||
upsert=True,
|
upsert=True,
|
||||||
)
|
)
|
||||||
|
@ -31,6 +31,7 @@ class SettingsCog(commands.Cog):
|
||||||
base="settings",
|
base="settings",
|
||||||
name="mute",
|
name="mute",
|
||||||
description="Set mute role",
|
description="Set mute role",
|
||||||
|
guild_ids=[418094694325813248, 578757004059738142],
|
||||||
options=[
|
options=[
|
||||||
create_option(
|
create_option(
|
||||||
name="role",
|
name="role",
|
||||||
|
@ -50,6 +51,7 @@ class SettingsCog(commands.Cog):
|
||||||
base="settings",
|
base="settings",
|
||||||
name="modlog",
|
name="modlog",
|
||||||
description="Set modlog channel",
|
description="Set modlog channel",
|
||||||
|
guild_ids=[418094694325813248, 578757004059738142],
|
||||||
options=[
|
options=[
|
||||||
create_option(
|
create_option(
|
||||||
name="channel",
|
name="channel",
|
||||||
|
@ -71,6 +73,7 @@ class SettingsCog(commands.Cog):
|
||||||
base="settings",
|
base="settings",
|
||||||
name="userlog",
|
name="userlog",
|
||||||
description="Set userlog channel",
|
description="Set userlog channel",
|
||||||
|
guild_ids=[418094694325813248, 578757004059738142],
|
||||||
options=[
|
options=[
|
||||||
create_option(
|
create_option(
|
||||||
name="channel",
|
name="channel",
|
||||||
|
@ -88,6 +91,26 @@ class SettingsCog(commands.Cog):
|
||||||
f"Settings applied. New userlog channel is {channel.mention}"
|
f"Settings applied. New userlog channel is {channel.mention}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@cog_ext.cog_subcommand(
|
||||||
|
base="settings",
|
||||||
|
name="massmention",
|
||||||
|
description="Set massmention amount",
|
||||||
|
guild_ids=[418094694325813248, 578757004059738142],
|
||||||
|
options=[
|
||||||
|
create_option(
|
||||||
|
name="amount",
|
||||||
|
description="Amount of mentions (0 to disable)",
|
||||||
|
option_type=4,
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
@commands.has_permissions(administrator=True)
|
||||||
|
async def _massmention(self, ctx, amount: int):
|
||||||
|
await ctx.defer()
|
||||||
|
self.update_settings("massmention", amount, ctx.guild.id)
|
||||||
|
await ctx.send(f"Settings applied. New massmention limit is {amount}")
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(SettingsCog(bot))
|
bot.add_cog(SettingsCog(bot))
|
||||||
|
|
Loading…
Add table
Reference in a new issue