Skip to content
This repository was archived by the owner on Jul 4, 2023. It is now read-only.

Commit da9926b

Browse files
authored
Merge pull request #6 from EightBot-Developer/kinoutuika
色々な追加と変更
2 parents 1ecf0eb + 1f8f224 commit da9926b

18 files changed

Lines changed: 1069 additions & 136 deletions

cogs/afk.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ async def afkk(self, i: discord.Interaction):
3333
except:
3434
await i.response.send_message("afkを解除できませんでした。", ephemeral=True)
3535

36-
@commands.Cog.listener(name='on_message')
36+
@commands.Cog.listener(name="on_message")
3737
async def afk_msg(self, message: discord.Message):
3838
try:
3939
if message.mentions:
4040
for d in message.mentions:
4141
if afk_get[int(d.id)]:
42-
await message.channel.send("このユーザーはafkです。(こののメッセージは10秒後に削除されます。)", delete_after=10)
42+
await message.channel.send(
43+
"このユーザーはafkです。(こののメッセージは10秒後に削除されます。)", delete_after=10
44+
)
4345
except:
4446
pass
4547

cogs/ban_member.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ def __init__(self, bot: commands.Bot) -> None:
1111
async def ban_members(self, i: discord.Interaction):
1212
m = []
1313
async for entry in i.guild.bans(limit=999999):
14-
m.append(f"{entry.user.name}, ")
14+
m.append(f"{entry.user.name}, ")
1515
if not len(m) == 0:
16-
end = len(m) - 1
17-
m[end] = m[end].split(', ')[0]
18-
send_content = "".join(m)
16+
end = len(m) - 1
17+
m[end] = m[end].split(", ")[0]
18+
send_content = "".join(m)
1919
elif len(m) == 0:
20-
send_content = "Banされたユーザーはいません。"
20+
send_content = "Banされたユーザーはいません。"
2121
await i.response.send_message(send_content)
2222

2323

cogs/bot_info.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
from discord import app_commands
44
from replit import db
55

6+
67
def bot_command_count_get(data):
78
return db[f"bot_command_{data}_count_db"]
89

10+
911
def bot_command_all_count_db_get():
1012
return db[f"bot_command_all_count_db"]
1113

@@ -14,13 +16,15 @@ class bot_info(commands.Cog):
1416
def __init__(self, bot: commands.Bot) -> None:
1517
self.bot: commands.Bot = bot
1618

17-
@app_commands.command(
18-
name="bot_info",
19-
description="Botの情報を表示します。"
20-
)
21-
async def botinfo(
22-
self, i: discord.Interaction
23-
):
24-
await i.response.send_message(embed=discord.Embed(title='Botの情報').add_field(name='全コマンドの合計実行数', value=str(bot_command_all_count_db_get())), ephemeral=True)
19+
@app_commands.command(name="bot_info", description="Botの情報を表示します。")
20+
async def botinfo(self, i: discord.Interaction):
21+
await i.response.send_message(
22+
embed=discord.Embed(title="Botの情報").add_field(
23+
name="全コマンドの合計実行数", value=str(bot_command_all_count_db_get())
24+
),
25+
ephemeral=True,
26+
)
27+
28+
2529
async def setup(bot: commands.Bot) -> None:
2630
await bot.add_cog(bot_info(bot))

cogs/bot_invite.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,28 @@ class MyView(discord.ui.View):
2424
value="admin",
2525
),
2626
discord.SelectOption(
27-
label="権限選択式",
28-
description="全ての権限を選択式にしたURLを生成します。",
29-
value="all"
27+
label="権限選択式", description="全ての権限を選択式にしたURLを生成します。", value="all"
3028
),
3129
discord.SelectOption(
32-
label="権限なし",
33-
description="全ての権限をなしにしたURLを生成します。",
34-
value="none"
30+
label="権限なし", description="全ての権限をなしにしたURLを生成します。", value="none"
3531
),
36-
37-
]
32+
],
3833
)
3934
async def select_callback(self, select, i):
4035
bot_id = db_get(i.message.id)
4136
d = select.values[0]
4237
if d == "admin":
43-
await i.response.edit_message(f"セレクトメニューをクリックして選択してください\n[Botを招待]({discord.utils.oauth_url(int(bot_id), permissions=discord.Permissions(permissions=discord.Permissions.administrator.flag))})")
38+
await i.response.edit_message(
39+
f"セレクトメニューをクリックして選択してください\n[Botを招待]({discord.utils.oauth_url(int(bot_id), permissions=discord.Permissions(permissions=discord.Permissions.administrator.flag))})"
40+
)
4441
elif d == "all":
45-
await i.response.edit_message(f"セレクトメニューをクリックして選択してください\n[Botを招待]({discord.utils.oauth_url(int(bot_id), permissions=discord.Permissions(permissions=discord.Permissions.all()))})")
42+
await i.response.edit_message(
43+
f"セレクトメニューをクリックして選択してください\n[Botを招待]({discord.utils.oauth_url(int(bot_id), permissions=discord.Permissions(permissions=discord.Permissions.all()))})"
44+
)
4645
elif d == "none":
47-
await i.response.edit_message(f"セレクトメニューをクリックして選択してください\n[Botを招待]({discord.utils.oauth_url(int(bot_id))})")
46+
await i.response.edit_message(
47+
f"セレクトメニューをクリックして選択してください\n[Botを招待]({discord.utils.oauth_url(int(bot_id))})"
48+
)
4849
else:
4950
await i.response.edit_message("セレクトメニューをクリックして選択してください\n不明なパラメーターが選択されました。")
5051

cogs/bot_process.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
from discord import app_commands
44
from replit import db
55

6+
67
def bot_command_count_get(data):
78
return db[f"bot_command_{data}_count_db"]
89

10+
911
def bot_command_count(data):
1012
db[f"bot_command_{data}_count_db"] = int(bot_command_count_get()) + 1
1113

14+
1215
def bot_command_all_count_db_get():
1316
return db[f"bot_command_all_count_db"]
1417

18+
1519
def bot_command_count_p1():
1620
db[f"bot_command_all_count_db"] = int(bot_command_all_count_db_get()) + 1
1721

@@ -20,7 +24,7 @@ class bot_process(commands.Cog):
2024
def __init__(self, bot: commands.Bot) -> None:
2125
self.bot: commands.Bot = bot
2226

23-
@commands.Cog.listener(name='on_interaction')
27+
@commands.Cog.listener(name="on_interaction")
2428
async def interaction(self, i: discord.Interaction):
2529
if i.type == discord.InteractionType.application_command:
2630
bot_command_count_p1()
@@ -29,5 +33,6 @@ async def interaction(self, i: discord.Interaction):
2933
else:
3034
return
3135

36+
3237
async def setup(bot: commands.Bot) -> None:
3338
await bot.add_cog(bot_process(bot))

cogs/embed.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

cogs/help.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from discord.ext import commands
33
import Paginator
44
from discord import app_commands
5+
56
a = "Tips: `/help コマンド名`でコマンドを検索できます。"
67

78

@@ -19,16 +20,12 @@ async def help(self, i: discord.Interaction, cmd: str = None) -> None:
1920
if not cmd:
2021
he = discord.Embed(title="ページ2", color=discord.Colour.blurple())
2122
he.add_field(name="help", value="helpを表示します。")
22-
he.set_footer(
23-
text=a
24-
)
23+
he.set_footer(text=a)
2524
embeds = [
2625
discord.Embed(
2726
title="ページ1",
2827
color=discord.Colour.blurple(),
29-
).set_footer(
30-
text=a
31-
),
28+
).set_footer(text=a),
3229
he,
3330
]
3431
return await Paginator.Simple().start(i, pages=embeds)

cogs/imgcheck.py

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
from discord.ext import commands
2+
from discord import app_commands
3+
import discord
4+
import aiohttp
5+
import urllib.parse
6+
import asyncio
7+
8+
9+
class imgcheck(commands.Cog):
10+
def __init__(self, bot: commands.Bot) -> None:
11+
self.bot: commands.Bot = bot
12+
13+
@app_commands.command(name="img_url_check", description="URLの画像から拾い画かチェックするコマンド。")
14+
async def img_url_check(self, i: discord.Interaction, url: str):
15+
load_text = "拾い画チェッカーAPIに接続しています"
16+
await i.response.send_message(load_text)
17+
await asyncio.sleep(1)
18+
await i.edit_original_response(content=f"{load_text}.")
19+
await asyncio.sleep(1)
20+
await i.edit_original_response(content=f"{load_text}..")
21+
await asyncio.sleep(1)
22+
await i.edit_original_response(content=f"{load_text}...")
23+
async with aiohttp.ClientSession() as session:
24+
async with session.get(
25+
f"https://api.irucabot.com/imgcheck/check_url?url={urllib.parse.quote(url)}"
26+
) as resp:
27+
resp_data = await resp.json()
28+
if resp_data["status"] == "success":
29+
if resp_data["found"]:
30+
await i.edit_original_response(
31+
content=None,
32+
embed=discord.Embed(
33+
title="これは拾い画です。",
34+
description=f"この画像と一致している画像が{resp_data['count']}個ありました。\n[Google画像検索結果]({resp_data['resulturl']})\n[拾い画チェッカーAPIを使用しています。](https://imgcheck.irucabot.com/api-reference/check_url)",
35+
),
36+
)
37+
elif not resp_data["found"]:
38+
await i.edit_original_response(
39+
content=None,
40+
embed=discord.Embed(
41+
title="これは拾い画ではない可能性が高いです。",
42+
description=f"この画像と一致している画像が0個ありました。\n\n[拾い画チェッカーAPIを使用しています。](https://imgcheck.irucabot.com/api-reference/check_url)",
43+
),
44+
)
45+
else:
46+
await i.edit_original_response(
47+
content=None,
48+
embed=discord.Embed(
49+
title="起るはずの無いことが起こりました。",
50+
description=f"起るはずの無いことが起こったので、結果を表示できません。",
51+
),
52+
)
53+
elif resp_data["status"] == "error":
54+
await i.edit_original_response(
55+
content=None,
56+
embed=discord.Embed(
57+
title="エラーが発生しました。", description=resp_data["message_ja"]
58+
),
59+
)
60+
61+
@app_commands.command(name="img_check", description="拾い画チェッカー。")
62+
async def imgcheck(self, i: discord.Interaction, img: discord.Attachment):
63+
load_text = "拾い画チェッカーAPIに接続しています"
64+
await i.response.send_message(load_text)
65+
await asyncio.sleep(1)
66+
await i.edit_original_response(content=f"{load_text}.")
67+
await asyncio.sleep(1)
68+
await i.edit_original_response(content=f"{load_text}..")
69+
await asyncio.sleep(1)
70+
await i.edit_original_response(content=f"{load_text}...")
71+
async with aiohttp.ClientSession() as session:
72+
async with session.get(
73+
f"https://api.irucabot.com/imgcheck/check_url?url={urllib.parse.quote(img.url)}"
74+
) as resp:
75+
resp_data = await resp.json()
76+
if resp_data["status"] == "success":
77+
if resp_data["found"]:
78+
await i.edit_original_response(
79+
content=None,
80+
embed=discord.Embed(
81+
title="これは拾い画です。",
82+
description=f"この画像と一致している画像が{resp_data['count']}個ありました。\n[Google画像検索結果]({resp_data['resulturl']})\n[拾い画チェッカーAPIを使用しています。](https://imgcheck.irucabot.com/api-reference/check_url)",
83+
),
84+
)
85+
elif not resp_data["found"]:
86+
await i.edit_original_response(
87+
content=None,
88+
embed=discord.Embed(
89+
title="これは拾い画ではない可能性が高いです。",
90+
description=f"この画像と一致している画像が0個ありました。\n\n[拾い画チェッカーAPIを使用しています。](https://imgcheck.irucabot.com/api-reference/check_url)",
91+
),
92+
)
93+
else:
94+
await i.edit_original_response(
95+
content=None,
96+
embed=discord.Embed(
97+
title="起るはずの無いことが起こりました。",
98+
description=f"起るはずの無いことが起こったので、結果を表示できません。",
99+
),
100+
)
101+
elif resp_data["status"] == "error":
102+
await i.edit_original_response(
103+
content=None,
104+
embed=discord.Embed(
105+
title="エラーが発生しました。", description=resp_data["message_ja"]
106+
),
107+
)
108+
109+
110+
async def setup(bot: commands.Bot) -> None:
111+
await bot.add_cog(imgcheck(bot))

cogs/ping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def __init__(self, bot: commands.Bot) -> None:
99

1010
@app_commands.command(name="ping", description="ping値を測定します。")
1111
async def pingpong(self, i: discord.Interaction):
12-
await i.response.send_message(f'{round(self.bot.latency * 1000)}ms')
12+
await i.response.send_message(f"{round(self.bot.latency * 1000)}ms")
1313

1414

1515
async def setup(bot: commands.Bot) -> None:

cogs/role_all.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,38 @@ class roleall(commands.Cog):
1313
def __init__(self, bot: commands.Bot) -> None:
1414
self.bot: commands.Bot = bot
1515

16-
@app_commands.describe(bot='Botにもロールを付与する?')
17-
@app_commands.choices(bot=[
18-
app_commands.Choice(name='はい', value="y"),
19-
app_commands.Choice(name='いいえ', value="f"),
20-
])
16+
@app_commands.describe(bot="Botにもロールを付与する?")
17+
@app_commands.choices(
18+
bot=[
19+
app_commands.Choice(name="はい", value="y"),
20+
app_commands.Choice(name="いいえ", value="f"),
21+
]
22+
)
2123
@app_commands.command(name="role_all_add", description="全メンバーにロールを付与します。")
2224
async def roleall_add(self, i: discord.Interaction, role: discord.Role, bot: str):
23-
if bot == 'y':
25+
if bot == "y":
2426
for member in i.guild.members:
2527
await member.add_roles(role)
26-
elif bot == 'f':
28+
elif bot == "f":
2729
for member in i.guild.members:
2830
if not member.bot:
2931
await member.add_roles(role)
3032

31-
@app_commands.describe(bot='Botのロールも除去する?')
32-
@app_commands.choices(bot=[
33-
app_commands.Choice(name='はい', value='y'),
34-
app_commands.Choice(name='いいえ', value='f'),
35-
])
33+
@app_commands.describe(bot="Botのロールも除去する?")
34+
@app_commands.choices(
35+
bot=[
36+
app_commands.Choice(name="はい", value="y"),
37+
app_commands.Choice(name="いいえ", value="f"),
38+
]
39+
)
3640
@app_commands.command(name="role_all_remove", description="全員からロールを除去します。")
37-
async def roleall_remove(self, i: discord.Interaction, role: discord.Role, bot: str):
38-
if bot == 'y':
41+
async def roleall_remove(
42+
self, i: discord.Interaction, role: discord.Role, bot: str
43+
):
44+
if bot == "y":
3945
for member in i.guild.members:
4046
await member.remove_roles(role)
41-
elif bot == 'f':
47+
elif bot == "f":
4248
for member in i.guild.members:
4349
if not member.bot:
4450
await member.remove_roles(role)

0 commit comments

Comments
 (0)