mirror of
https://github.com/allthingslinux/tux.git
synced 2024-10-02 16:43:12 +00:00
Finish up Pollban code and fix some bugs
This commit is contained in:
parent
7fe7b85f18
commit
ce6515782b
2 changed files with 14 additions and 11 deletions
|
@ -31,7 +31,7 @@ class PollBan(ModerationCogBase):
|
||||||
flags: PollBanFlags,
|
flags: PollBanFlags,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Ban a user from creating polls using tux..
|
Ban a user from creating polls using tux.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
|
|
|
@ -65,13 +65,7 @@ class Poll(commands.Cog):
|
||||||
|
|
||||||
@app_commands.command(name="poll", description="Creates a poll.")
|
@app_commands.command(name="poll", description="Creates a poll.")
|
||||||
@app_commands.describe(title="Title of the poll", options="Poll options, comma separated")
|
@app_commands.describe(title="Title of the poll", options="Poll options, comma separated")
|
||||||
async def poll(
|
async def poll(self, interaction: discord.Interaction, title: str, options: str) -> None:
|
||||||
self,
|
|
||||||
interaction: discord.Interaction,
|
|
||||||
title: str,
|
|
||||||
options: str,
|
|
||||||
ctx: commands.Context[Tux],
|
|
||||||
) -> None:
|
|
||||||
"""
|
"""
|
||||||
Create a poll with a title and options.
|
Create a poll with a title and options.
|
||||||
|
|
||||||
|
@ -83,8 +77,9 @@ class Poll(commands.Cog):
|
||||||
The title of the poll.
|
The title of the poll.
|
||||||
options : str
|
options : str
|
||||||
The options for the poll, separated by commas.
|
The options for the poll, separated by commas.
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
assert ctx.guild
|
|
||||||
|
|
||||||
# Split the options by comma
|
# Split the options by comma
|
||||||
options_list = options.split(",")
|
options_list = options.split(",")
|
||||||
|
@ -92,8 +87,16 @@ class Poll(commands.Cog):
|
||||||
# Remove any leading or trailing whitespaces from the options
|
# Remove any leading or trailing whitespaces from the options
|
||||||
options_list = [option.strip() for option in options_list]
|
options_list = [option.strip() for option in options_list]
|
||||||
|
|
||||||
if await self.is_pollbanned(ctx.guild.id, ctx.author.id):
|
if await self.is_pollbanned(interaction.guild_id, interaction.user.id):
|
||||||
await ctx.send("You are banned from making polls.")
|
embed = EmbedCreator.create_embed(
|
||||||
|
bot=self.bot,
|
||||||
|
embed_type=EmbedCreator.ERROR,
|
||||||
|
user_name=interaction.user.name,
|
||||||
|
user_display_avatar=interaction.user.display_avatar.url,
|
||||||
|
title="Poll Banned",
|
||||||
|
description="you are banned from making polls. think about what you have done.",
|
||||||
|
)
|
||||||
|
await interaction.response.send_message(embed=embed, ephemeral=True)
|
||||||
return
|
return
|
||||||
# Check if the options count is between 2-9
|
# Check if the options count is between 2-9
|
||||||
if len(options_list) < 2 or len(options_list) > 9:
|
if len(options_list) < 2 or len(options_list) > 9:
|
||||||
|
|
Loading…
Reference in a new issue