misc(art): moving art to a seperate branch pending discord.py 2.4 and the relevant Red update
All checks were successful
Pylint / Pylint (3.11) (push) Successful in 40s
All checks were successful
Pylint / Pylint (3.11) (push) Successful in 40s
This commit is contained in:
parent
f1fbec1fd5
commit
f55dd00300
4 changed files with 0 additions and 165 deletions
|
@ -1,5 +0,0 @@
|
||||||
from .art import Art
|
|
||||||
|
|
||||||
|
|
||||||
async def setup(bot):
|
|
||||||
await bot.add_cog(Art(bot))
|
|
141
art/art.py
141
art/art.py
|
@ -1,141 +0,0 @@
|
||||||
# _____ _
|
|
||||||
# / ____| (_)
|
|
||||||
# | (___ ___ __ _ _____ ___ _ __ ___ _ __ ___ ___ _ __
|
|
||||||
# \___ \ / _ \/ _` / __\ \ /\ / / | '_ ` _ \| '_ ` _ \ / _ \ '__|
|
|
||||||
# ____) | __/ (_| \__ \\ V V /| | | | | | | | | | | | __/ |
|
|
||||||
# |_____/ \___|\__,_|___/ \_/\_/ |_|_| |_| |_|_| |_| |_|\___|_|
|
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
import discord
|
|
||||||
from redbot.core import app_commands, checks, commands
|
|
||||||
|
|
||||||
from .config import config, register_config
|
|
||||||
|
|
||||||
|
|
||||||
class Art(commands.Cog):
|
|
||||||
"""TODO. Broken until Discord.py 2.4 is released."""
|
|
||||||
|
|
||||||
__author__ = "SeaswimmerTheFsh"
|
|
||||||
__version__ = "0.1.0"
|
|
||||||
|
|
||||||
def __init__(self, bot):
|
|
||||||
self.bot = bot
|
|
||||||
register_config(config)
|
|
||||||
|
|
||||||
async def cog_load(self) -> None:
|
|
||||||
self.add_dynamic_items(ApproveButton)
|
|
||||||
self.add_dynamic_items(DenyButton)
|
|
||||||
|
|
||||||
@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 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
|
|
||||||
msg = await art_submission_channel.send(f"Art submission from {interaction.user.mention} ({interaction.user.id}):", file=await art.to_file())
|
|
||||||
view = discord.ui.View(timeout=None)
|
|
||||||
view.add_item(ApproveButton(interaction.id, msg, self.bot))
|
|
||||||
view.add_item(DenyButton(interaction.id, msg, self.bot))
|
|
||||||
msg.edit(view=view)
|
|
||||||
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 submission(self, ctx: commands.Context, channel: discord.TextChannel):
|
|
||||||
"""Set the art submission channel."""
|
|
||||||
await 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 result(self, ctx: commands.Context, channel: discord.TextChannel):
|
|
||||||
"""Set the art channel."""
|
|
||||||
await 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 config.guild(ctx.guild).art_channel())
|
|
||||||
art_submission_channel = ctx.guild.get_channel(await 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)
|
|
||||||
|
|
||||||
class ApproveButton(discord.ui.DynamicItem[discord.ui.Button], template=r'button:interaction:(?P<id>[0-9]+)'):
|
|
||||||
def __init__(self, interaction_id: int, msg: discord.Message, bot) -> None:
|
|
||||||
super().__init__(
|
|
||||||
discord.ui.Button(
|
|
||||||
label='Approve',
|
|
||||||
style=discord.ButtonStyle.green,
|
|
||||||
custom_id=f'art:approve:interaction:{interaction_id}',
|
|
||||||
emoji='\N{THUMBS UP SIGN}',
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self.interaction_id: int = interaction_id
|
|
||||||
self.msg = msg
|
|
||||||
self.bot = bot
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
async def from_custom_id(cls, interaction: discord.Interaction, item: discord.ui.Button, match: re.Match[str], /):
|
|
||||||
interaction_id = int(match['id'])
|
|
||||||
return cls(interaction_id)
|
|
||||||
|
|
||||||
async def interaction_check(self, interaction: discord.Interaction) -> bool:
|
|
||||||
return self.bot.is_mod(interaction.user)
|
|
||||||
|
|
||||||
async def callback(self, interaction: discord.Interaction):
|
|
||||||
art_channel = interaction.guild.get_channel(await config.guild(interaction.guild).art_channel())
|
|
||||||
if art_channel is None:
|
|
||||||
await interaction.followup.send("Art channel not set. Report this error to the server administrators.", ephemeral=True)
|
|
||||||
return
|
|
||||||
content = self.msg.content
|
|
||||||
await self.msg.edit(content=content + f"\n\n*This art submission was approved by {interaction.user.mention} ({interaction.user.id}).*")
|
|
||||||
msg: discord.Message = await art_channel.send(f"Art submission from {interaction.user.mention} ({interaction.user.id}):", file=self.msg.attachments[0])
|
|
||||||
await msg.add_reaction('\N{THUMBS UP SIGN}')
|
|
||||||
await msg.add_reaction('\N{THUMBS DOWN SIGN}')
|
|
||||||
|
|
||||||
|
|
||||||
class DenyButton(discord.ui.DynamicItem[discord.ui.Button], template=r'button:interaction:(?P<id>[0-9]+)'):
|
|
||||||
def __init__(self, interaction_id: int, msg: discord.Message, bot) -> None:
|
|
||||||
super().__init__(
|
|
||||||
discord.ui.Button(
|
|
||||||
label='Deny',
|
|
||||||
style=discord.ButtonStyle.red,
|
|
||||||
custom_id=f'art:deny:interaction:{interaction_id}',
|
|
||||||
emoji='\N{THUMBS DOWN SIGN}',
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self.interaction_id: int = interaction_id
|
|
||||||
self.msg = msg
|
|
||||||
self.bot = bot
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
async def from_custom_id(cls, interaction: discord.Interaction, item: discord.ui.Button, match: re.Match[str], /):
|
|
||||||
interaction_id = int(match['id'])
|
|
||||||
return cls(interaction_id)
|
|
||||||
|
|
||||||
async def interaction_check(self, interaction: discord.Interaction) -> bool:
|
|
||||||
return self.bot.is_mod(interaction.user)
|
|
||||||
|
|
||||||
async def callback(self, interaction: discord.Interaction):
|
|
||||||
content = self.msg.content
|
|
||||||
await self.msg.edit(content=content + f"\n\n*This art submission was denied by {interaction.user.mention} ({interaction.user.id}).*")
|
|
|
@ -1,9 +0,0 @@
|
||||||
from redbot.core import Config
|
|
||||||
|
|
||||||
config: Config = Config.get_conf(None, identifier=2347831296542324, cog_name="Art")
|
|
||||||
|
|
||||||
def register_config(config_obj: Config):
|
|
||||||
config_obj.register_guild(
|
|
||||||
art_channel=None,
|
|
||||||
art_submission_channel=None
|
|
||||||
)
|
|
|
@ -1,10 +0,0 @@
|
||||||
{
|
|
||||||
"author" : ["SeaswimmerTheFsh"],
|
|
||||||
"install_msg" : "Thank you for installing Art!\nYou can find the source code of this cog [here](https://coastalcommits.com/SeaswimmerTheFsh/SeaCogs).",
|
|
||||||
"name" : "Art",
|
|
||||||
"short" : "TODO",
|
|
||||||
"description" : "TODO",
|
|
||||||
"end_user_data_statement" : "This cog does not store end user data.",
|
|
||||||
"hidden": true,
|
|
||||||
"disabled": true
|
|
||||||
}
|
|
Loading…
Reference in a new issue