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

Add exclude muted members option #177

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
26 changes: 26 additions & 0 deletions cogs/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,31 @@ async def setup(self, ctx):
)
)

@commands.guild_only()
@commands.command(
description="Prohibit muted members from creating a ticket",
usage="excludemuted",
)
async def excludemuted(self, ctx):
if (await ctx.message.member.guild_permissions()).administrator is False:
raise commands.MissingPermissions(["administrator"])

data = await tools.get_data(self.bot, ctx.guild.id)
toset = True
if data[15] is True:
toset = False

async with self.bot.pool.acquire() as conn:
await conn.execute("UPDATE data SET excludemuted=$1 WHERE guild=$2", toset, ctx.guild.id)

await ctx.send(
Embed(
"Block timed out members is now "
f"`{'Enabled' if toset is True else 'Disabled'}`.",
)
)


@commands.guild_only()
@commands.command(
description="Change the prefix or view the current prefix.",
Expand Down Expand Up @@ -463,6 +488,7 @@ async def viewconfig(self, ctx):
embed.add_field("Advanced Logging", "Enabled" if data[7] is True else "Disabled")
embed.add_field("Anonymous Messaging", "Enabled" if data[10] is True else "Disabled")
embed.add_field("Command Only", "Enabled" if data[11] is True else "Disabled")
embed.add_field("Exclude Muted", "Enabled" if data[15] is True else "Disabled")
embed.add_field("Ticket Creation", "Enabled" if toggle is None else f"Disabled ({toggle})")
embed.add_field("Greeting Message", "*Not set*" if greeting is None else greeting, False)
embed.add_field("Closing Message", "*Not set*" if closing is None else closing, False)
Expand Down
10 changes: 10 additions & 0 deletions cogs/direct_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ async def send_mail(self, message, guild):
ErrorEmbed("That server has blacklisted you from sending a message there.")
)
return

if data[15] is True and member.timed_out_until is not None:
embed = ErrorEmbed(
"Ticket Not Created",
"You can't create a ticket because you are timed out.",
timestamp=True,
)
embed.set_footer(f"{guild.name} | {guild.id}", guild.icon_url)
await message.channel.send(embed)
return

channel = None
for text_channel in await guild.text_channels():
Expand Down
1 change: 1 addition & 0 deletions migrations/2022-05-01-135059_initialize_db/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ CREATE TABLE data
blacklist bigint[] NOT NULL,
anonymous boolean NOT NULL,
commandonly boolean NOT NULL,
excludemuted boolean NOT NULL,
PRIMARY KEY (guild)
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE data DROP COLUMN excludemuted;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE data ADD COLUMN excludemuted boolean;
3 changes: 2 additions & 1 deletion utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ async def get_data(bot, guild):
return res

return await conn.fetchrow(
"INSERT INTO data VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) "
"INSERT INTO data VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14) "
"RETURNING *",
guild,
None,
Expand All @@ -196,6 +196,7 @@ async def get_data(bot, guild):
False,
False,
None,
False,
)


Expand Down