From b7e5bb749811202e17d05c4c079e536ce54ffa05 Mon Sep 17 00:00:00 2001 From: Syunngiku0402 Date: Fri, 15 Nov 2024 18:16:54 +0900 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E5=BA=A6=E3=82=B3=E3=83=9F=E3=83=83?= =?UTF-8?q?=E3=83=88=E3=80=81=E3=81=AA=E3=81=8A=E3=81=BE=E3=81=A0=E4=BD=BF?= =?UTF-8?q?=E3=81=88=E3=82=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cogs/crandom.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cogs/crandom.py b/cogs/crandom.py index 5fc701f..b0e20a2 100644 --- a/cogs/crandom.py +++ b/cogs/crandom.py @@ -3,15 +3,16 @@ from discord import app_commands import random -anydot=[ +anydot = [ "...", "....", - ".....", - "......", - ".......", + ".....", + "......", + ".......", "........" ] + class CRandom(commands.Cog): def __init__(self, bot: commands.Bot): self.bot = bot @@ -20,7 +21,7 @@ def __init__(self, bot: commands.Bot): @app_commands.describe( mode="value : 自分にのみ表示・roll : 全体に表示", range="送信したい内容を書いてください" - ) + ) @app_commands.choices( mode=[ app_commands.Choice(name="roll", value="mroll"), @@ -28,7 +29,7 @@ def __init__(self, bot: commands.Bot): ] ) async def cybase64( - self, interaction: discord.Interaction, mode: app_commands.Choice[str], range : str + self, interaction: discord.Interaction, mode: app_commands.Choice[str], range: str ): if anydot in range: await interaction.response.send_message("rangeで使うドットの数は2個です\n(例 : ..-10(-10以下)・10..(10以上))・1..30(1以上30以下)") @@ -37,24 +38,24 @@ async def cybase64( target = '..' idx = s.find(target) - r = s[idx+1:] # スライスで半角空白文字のインデックス+1以降を抽出 + r = s[idx + 1:] # スライスで半角空白文字のインデックス+1以降を抽出 print(r) # 05:30 text = range str1 = ".." - aaa = text[c+1:] if (c := text.find(str1)) != -1 and text.startswith(str1) else "" + aaa = text[c + 1:] if (c := text.find(str1)) != -1 and text.startswith(str1) else "" bbb = text[:c] if (c := text.rfind(str1)) != -1 and text.endswith(str1) else "" ccc = text[:c] if (c := text.rfind(str1)) != -1 else "" - ddd = text[c+len(str1):] if (c := text.find(str1)) != -1 else "" + ddd = text[c + len(str1):] if (c := text.find(str1)) != -1 else "" if range.content.startswith("aaa"): number = random.randint(-2147483647, 2147483648) startnum = 1 stopnum = 10 - + abcd = aaa + bbb + ccc + ddd if mode.value == "mroll": - await interaction.response.send_message(f"{interaction.user.display_name}は{number}を引きました ( 値の範囲は{startnum}から{stopnum} )", ephemeral=False) + await interaction.response.send_message(f"{interaction.user.display_name}は{number}{abcd}を引きました ( 値の範囲は{startnum}から{stopnum} )", ephemeral=False) if mode.value == "mvalue": await interaction.response.send_message(f"乱数 : {number}", ephemeral=True)