diff --git a/cogs/meme.py b/cogs/meme.py index 649973d..2ffd39e 100644 --- a/cogs/meme.py +++ b/cogs/meme.py @@ -14,6 +14,12 @@ class meme(commands.Cog): def __init__(self, bot): self.bot = bot + with open("utils/report_label.json", encoding="UTF8") as f: + self.data = json.load(f) + + self.options = [] + for i in self.data.keys(): + self.options.append(discord.SelectOption(value=i, label=self.data[i]["label"], description=self.data[i]["description"])) async def cog_check(self): if await BLACKLIST.search_blacklist(self.author.id): @@ -34,7 +40,47 @@ async def account_check(self): @commands.Cog.listener() async def on_interaction(self, interaction: discord.Interaction): - if interaction.is_component(): + if interaction.type == discord.InteractionType.modal_submit: + if interaction.data["custom_id"].startswith("reportformjakseong-"): + report_category_list = [] + report_category_list_value = [] + for i in (interaction.data['custom_id'].split('-')[2]).split(','): + report_category_list.append(f'reportlabel-{i}') + report_category_list_value.append(f"``{self.data[f'reportlabel-{i}']['label']}``") + + rp_list = ', '.join(report_category_list_value) + + embed = discord.Embed(color=0x5865F2, title="🚨 μ‹ κ³  μ ‘μˆ˜λ¨", description="μ‹ κ³ κ°€ μ ‘μˆ˜λ˜μ—ˆμŠ΅λ‹ˆλ‹€.\n>>> 🚩 μ‹ κ³  μ²˜λ¦¬λŠ” μ΅œλŒ€ 7μΌκΉŒμ§€ μ†Œμš”λ  수 있으며, 처리 κ²°κ³ΌλŠ” μ΄μš©μžλ‹˜μ˜ DM으둜 λ°œμ†‘λ©λ‹ˆλ‹€.\nπŸ™ μ΄μš©μžλ‹˜μ˜ μ‹ κ³ λ‘œ 지방러 μ‹œμŠ€ν…œμ΄ κΉ¨λ—ν•΄μ§ˆ 수 있기λ₯Ό κΈ°λŒ€ν•©λ‹ˆλ‹€!") + embed.add_field(name="μ‹ κ³  μ„ΈλΆ€ 정보", value=f">>> μ‹ κ³ ν•œ 지 : ``{interaction.data['custom_id'].split('-')[1]}``\nμ‹ κ³ μž : {interaction.user.mention} (``{interaction.user.id}``)\nμœ„λ°˜ μΉ΄ν…Œκ³ λ¦¬ : {rp_list}", inline=False) + embed.add_field(name="μ‹ κ³  μ‚¬μœ ", value=interaction.data['components'][0]['components'][0]['value'], inline=False) + view = discord.ui.View() + view.add_item(discord.ui.Button( + label="μ‹ κ³ λœ 지 보기", + emoji="🚧", + style=discord.ButtonStyle.green, + custom_id=f"reportcheckmeme-{interaction.data['custom_id'].split('-')[1]}-{interaction.user.id}", + )) + view.add_item(discord.ui.Button( + label="처리 κ²°κ³Ό ν†΅λ³΄ν•˜κΈ°", + emoji="🚩", + style=discord.ButtonStyle.blurple, + custom_id=f"reportpunishmeme-{interaction.data['custom_id'].split('-')[1]}-{interaction.user.id}", + )) + await self.bot.get_channel(config.BOT.REPORT_CHANNEL).send(embed=embed, view=view) + try: + return await interaction.followup.edit_message( + content=None, + embed=embed, + view=None, + ) + except: + return await interaction.response.edit_message( + content=None, + embed=embed, + view=None, + ) + + if interaction.type == discord.InteractionType.component: if interaction.data["custom_id"].startswith("report-"): with open("utils/report_label.json", encoding="UTF8") as f: data = json.load(f) @@ -51,7 +97,7 @@ async def on_interaction(self, interaction: discord.Interaction): min_values=1, max_values=len(data.keys()), options=options, - custom_id="reportlabel", + custom_id=f"reportlabel-{interaction.data['custom_id'].replace('report-', '')}", ) ) try: @@ -66,81 +112,34 @@ async def on_interaction(self, interaction: discord.Interaction): view=view, ephemeral=True, ) - - - def check(inter): - return inter.user.id == interaction.user.id - #return inter.user.id == interaction.user.id and inter.response.id == m.id - - try: - interaction_check = await self.bot.wait_for( - "interaction", check=check, timeout=60.0 - ) - except asyncio.TimeoutError: - embed = discord.Embed( - title=f"<:jbllogo:929615468233363457> μ‹œκ°„ 초과", - description="μ‹œκ°„μ΄ μ΄ˆκ³Όλ˜μ—ˆμŠ΅λ‹ˆλ‹€.", - color=0x5865F2, - ) - try: - return await m.edit_original_message( - content=None, - embed=embed, - view=None, - ) - except: - return await m.edit( - content=None, - embed=embed, - view=None, - ) + if interaction.data["custom_id"].startswith("reportlabel-"): reason_list = [] - for value in (interaction_check.data["values"]): - reason_list.append(f"``{data[value]['label']}``") + value_list = [] + for value in (interaction.data["values"]): + reason_list.append(f"``{self.data[value]['label']}``") + value_list.append(value.split("-")[1]) reasons = ", ".join(reason_list) + values = ",".join(value_list) view = discord.ui.View() view.add_item(discord.ui.Button( label="μ‹ κ³  λ‚΄μš© μž‘μ„±ν•˜κΈ°", emoji="πŸ“", style=discord.ButtonStyle.blurple, - custom_id=f"reportform-{interaction.user.id}", + custom_id=f"reportformyochung-{interaction.data['custom_id'].replace('reportlabel-', '')}-{values}", )) try: - await m.edit_original_message(content=f"μ•ˆλ…•ν•˜μ„Έμš”, {interaction.user.mention}λ‹˜.\nν•΄λ‹Ή 밈(``ID : {interaction.data['custom_id'].replace('report-', '')}``)에 λŒ€ν•œ μ‹ κ³  μ‚¬μœ κ°€ μ„ νƒλ˜μ—ˆμŠ΅λ‹ˆλ‹€.\n\n> μ‚¬μœ  : {reasons}\n\n**``μ‹ κ³  λ‚΄μš© μž‘μ„±ν•˜κΈ°`` λ²„νŠΌμ„ 눌러 λ‚΄μš©μ„ μž‘μ„±ν•΄μ£Όμ„Έμš”.**", view=view) + await interaction.response.edit_message(content=f"μ•ˆλ…•ν•˜μ„Έμš”, {interaction.user.mention}λ‹˜.\nν•΄λ‹Ή 밈(``ID : {interaction.data['custom_id'].replace('report-', '')}``)에 λŒ€ν•œ μ‹ κ³  μ‚¬μœ κ°€ μ„ νƒλ˜μ—ˆμŠ΅λ‹ˆλ‹€.\n\n> μ‚¬μœ  : {reasons}\n\n**``μ‹ κ³  λ‚΄μš© μž‘μ„±ν•˜κΈ°`` λ²„νŠΌμ„ 눌러 λ‚΄μš©μ„ μž‘μ„±ν•΄μ£Όμ„Έμš”.\n\n⚠ ν•œ λ²ˆμ”© λ¬Έμ œκ°€ λ°œμƒν•˜λŠ”λ°, λ²„νŠΌμ„ λ‹€μ‹œ λˆ„λ₯΄λ©΄ ν•΄κ²°λ©λ‹ˆλ‹€!**", view=view) except: - await m.edit(content=f"μ•ˆλ…•ν•˜μ„Έμš”, {interaction.user.mention}λ‹˜.\nν•΄λ‹Ή 밈(``ID : {interaction.data['custom_id'].replace('report-', '')}``)에 λŒ€ν•œ μ‹ κ³  μ‚¬μœ κ°€ μ„ νƒλ˜μ—ˆμŠ΅λ‹ˆλ‹€.\n\n> μ‚¬μœ  : {reasons}\n\n**``μ‹ κ³  λ‚΄μš© μž‘μ„±ν•˜κΈ°`` λ²„νŠΌμ„ 눌러 λ‚΄μš©μ„ μž‘μ„±ν•΄μ£Όμ„Έμš”.**", view=view) - - try: - interaction_check = await self.bot.wait_for( - "interaction", check=check, timeout=600.0 - ) - except asyncio.TimeoutError: - embed = discord.Embed( - title=f"<:jbllogo:929615468233363457> μ‹œκ°„ 초과", - description="μ‹œκ°„μ΄ μ΄ˆκ³Όλ˜μ—ˆμŠ΅λ‹ˆλ‹€.", - color=0x5865F2, - ) - try: - return await m.edit_original_message( - content=None, - embed=embed, - view=None, - ) - except: - return await m.edit( - content=None, - embed=embed, - view=None, - ) + await interaction.followup.edit_message(content=f"μ•ˆλ…•ν•˜μ„Έμš”, {interaction.user.mention}λ‹˜.\nν•΄λ‹Ή 밈(``ID : {interaction.data['custom_id'].replace('report-', '')}``)에 λŒ€ν•œ μ‹ κ³  μ‚¬μœ κ°€ μ„ νƒλ˜μ—ˆμŠ΅λ‹ˆλ‹€.\n\n> μ‚¬μœ  : {reasons}\n\n**``μ‹ κ³  λ‚΄μš© μž‘μ„±ν•˜κΈ°`` λ²„νŠΌμ„ 눌러 λ‚΄μš©μ„ μž‘μ„±ν•΄μ£Όμ„Έμš”.\n\n⚠ ν•œ λ²ˆμ”© λ¬Έμ œκ°€ λ°œμƒν•˜λŠ”λ°, λ²„νŠΌμ„ λ‹€μ‹œ λˆ„λ₯΄λ©΄ ν•΄κ²°λ©λ‹ˆλ‹€!**", view=view) - if interaction.data["custom_id"].startswith("reportform-"): - modal = discord.ui.Modal(title="μ‹ κ³  λ‚΄μš© μž‘μ„±ν•˜κΈ°", custom_id="reportform") + if interaction.data["custom_id"].startswith("reportformyochung-"): + modal = discord.ui.Modal(title="μ‹ κ³  λ‚΄μš© μž‘μ„±ν•˜κΈ°", custom_id=f"reportformjakseong-{interaction.data['custom_id'].replace('reportformyochung-', '')}") modal.add_item( discord.ui.InputText( label="μ‹ κ³  μ‚¬μœ ", - placeholder="μ™œ 이 지을 μ‹ κ³ ν•˜μ‹œκ²Œ λ˜μ—ˆλ‚˜μš”? μžμ„Έν•˜κ²Œ μ„€λͺ…ν•΄μ£Όμ‹œλ©΄ 처리 속도가 더 ν–₯μƒλœλ‹΅λ‹ˆλ‹€!", + placeholder="μ™œ 이 지을 μ‹ κ³ ν•˜μ‹œκ²Œ λ˜μ—ˆλ‚˜μš”? μžμ„Έν•˜κ²Œ μ„€λͺ…ν•΄μ£Όμ‹œλ©΄ μ²˜λ¦¬μ— 도움이 λ©λ‹ˆλ‹€!", style=discord.InputTextStyle.long, max_length=1024, custom_id="description",