Skip to content

Commit

Permalink
Merge pull request #19 from mckomaken/fix/escape
Browse files Browse the repository at this point in the history
fix: escape
  • Loading branch information
Syunngiku0402 authored Sep 30, 2024
2 parents 6136390 + 8121698 commit 4097db2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cogs/ckill.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
import discord
from discord import Member, app_commands
from discord.ext import commands
from discord.utils import escape_markdown, escape_mentions

import json
import random


def escape(text: str) -> str:
return escape_markdown(escape_mentions(text), True)


class CKill(commands.Cog):
lang_data: dict[str, str]

Expand Down Expand Up @@ -36,13 +41,16 @@ async def ckill(
# もしtargetがいなかったら、targetをエンティティの中から選出する
target_name = None
if target:
target_name = target.display_name
target_name = escape(target.display_name)

# 最大数制限
if 0 < count <= self.max_count:
logs: list[str] = []
for _ in range(count):
logs.append(self.generate_death_log(interaction.user.display_name, target_name))
logs.append(self.generate_death_log(
escape(interaction.user.display_name, True),
target_name
))

await interaction.response.send_message(
"\n".join(logs).rstrip("\n"),
Expand Down

0 comments on commit 4097db2

Please sign in to comment.