SeaCogs/art/art.py
SeaswimmerTheFsh 02a68b726c
Some checks failed
Pylint / Pylint (3.11) (push) Failing after 42s
fix(art): use file, not files
2023-12-28 10:05:03 -05:00

76 lines
3.1 KiB
Python

# _____ _
# / ____| (_)
# | (___ ___ __ _ _____ ___ _ __ ___ _ __ ___ ___ _ __
# \___ \ / _ \/ _` / __\ \ /\ / / | '_ ` _ \| '_ ` _ \ / _ \ '__|
# ____) | __/ (_| \__ \\ V V /| | | | | | | | | | | | __/ |
# |_____/ \___|\__,_|___/ \_/\_/ |_|_| |_| |_|_| |_| |_|\___|_|
import discord
from redbot.core import app_commands, config, checks, commands, data_manager
from redbot.core.app_commands import Choice
class Art(commands.Cog):
"""TODO."""
__author__ = "SeaswimmerTheFsh"
__version__ = "0.1.0"
def __init__(self, bot):
self.bot = bot
self.config = config.Config.get_conf(
self, identifier=2347831296542324
)
self.config.register_guild(
art_channel=None,
art_submission_channel=None
)
@app_commands.command()
async def art(self, interaction: discord.Interaction, art: discord.Attachment):
"""Submit art.
Parameters
-----------
art: discord.Attachment
Upload your art submission here.
"""
await interaction.response.defer(ephemeral=True)
art_submission_channel = interaction.guild.get_channel(await self.config.guild(interaction.guild).art_submission_channel())
if art_submission_channel is None:
await interaction.followup.send("Art submission channel not set. Report this error to the server administrators.", ephemeral=True)
return
await art_submission_channel.send(f"Art submission from {interaction.user.mention} ({interaction.user.id}):", file=art)
await interaction.followup.send("Art submitted.", ephemeral=True)
@commands.group()
@checks.admin_or_permissions(manage_guild=True)
async def artset(self, ctx: commands.Context):
"""Art submission settings."""
@artset.command()
async def channel(self, ctx: commands.Context, channel: discord.TextChannel):
"""Set the art submission channel."""
await self.config.guild(ctx.guild).art_submission_channel.set(channel.id)
await ctx.send(f"Art submission channel set to {channel.mention}.")
@artset.command()
async def artchannel(self, ctx: commands.Context, channel: discord.TextChannel):
"""Set the art channel."""
await self.config.guild(ctx.guild).art_channel.set(channel.id)
await ctx.send(f"Art channel set to {channel.mention}.")
@artset.command()
async def list(self, ctx: commands.Context):
"""List all settings."""
art_channel = ctx.guild.get_channel(await self.config.guild(ctx.guild).art_channel())
art_submission_channel = ctx.guild.get_channel(await self.config.guild(ctx.guild).art_submission_channel())
if art_channel:
response_str = f"Art channel: {art_channel.mention}\n"
else:
response_str = "Art channel not set.\n"
if art_submission_channel:
response_str += f"Art submission channel: {art_submission_channel.mention}"
else:
response_str += "Art submission channel not set."
await ctx.send(response_str)