Skip to content
This repository was archived by the owner on Jul 4, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cogs/afk.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ async def afkk(self, i: discord.Interaction):
except:
await i.response.send_message("afkを解除できませんでした。", ephemeral=True)

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

Expand Down
10 changes: 5 additions & 5 deletions cogs/ban_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ def __init__(self, bot: commands.Bot) -> None:
async def ban_members(self, i: discord.Interaction):
m = []
async for entry in i.guild.bans(limit=999999):
m.append(f"{entry.user.name}, ")
m.append(f"{entry.user.name}, ")
if not len(m) == 0:
end = len(m) - 1
m[end] = m[end].split(', ')[0]
send_content = "".join(m)
end = len(m) - 1
m[end] = m[end].split(", ")[0]
send_content = "".join(m)
elif len(m) == 0:
send_content = "Banされたユーザーはいません。"
send_content = "Banされたユーザーはいません。"
await i.response.send_message(send_content)


Expand Down
20 changes: 12 additions & 8 deletions cogs/bot_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
from discord import app_commands
from replit import db


def bot_command_count_get(data):
return db[f"bot_command_{data}_count_db"]


def bot_command_all_count_db_get():
return db[f"bot_command_all_count_db"]

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

@app_commands.command(
name="bot_info",
description="Botの情報を表示します。"
)
async def botinfo(
self, i: discord.Interaction
):
await i.response.send_message(embed=discord.Embed(title='Botの情報').add_field(name='全コマンドの合計実行数', value=str(bot_command_all_count_db_get())), ephemeral=True)
@app_commands.command(name="bot_info", description="Botの情報を表示します。")
async def botinfo(self, i: discord.Interaction):
await i.response.send_message(
embed=discord.Embed(title="Botの情報").add_field(
name="全コマンドの合計実行数", value=str(bot_command_all_count_db_get())
),
ephemeral=True,
)


async def setup(bot: commands.Bot) -> None:
await bot.add_cog(bot_info(bot))
23 changes: 12 additions & 11 deletions cogs/bot_invite.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,28 @@ class MyView(discord.ui.View):
value="admin",
),
discord.SelectOption(
label="権限選択式",
description="全ての権限を選択式にしたURLを生成します。",
value="all"
label="権限選択式", description="全ての権限を選択式にしたURLを生成します。", value="all"
),
discord.SelectOption(
label="権限なし",
description="全ての権限をなしにしたURLを生成します。",
value="none"
label="権限なし", description="全ての権限をなしにしたURLを生成します。", value="none"
),

]
],
)
async def select_callback(self, select, i):
bot_id = db_get(i.message.id)
d = select.values[0]
if d == "admin":
await i.response.edit_message(f"セレクトメニューをクリックして選択してください\n[Botを招待]({discord.utils.oauth_url(int(bot_id), permissions=discord.Permissions(permissions=discord.Permissions.administrator.flag))})")
await i.response.edit_message(
f"セレクトメニューをクリックして選択してください\n[Botを招待]({discord.utils.oauth_url(int(bot_id), permissions=discord.Permissions(permissions=discord.Permissions.administrator.flag))})"
)
elif d == "all":
await i.response.edit_message(f"セレクトメニューをクリックして選択してください\n[Botを招待]({discord.utils.oauth_url(int(bot_id), permissions=discord.Permissions(permissions=discord.Permissions.all()))})")
await i.response.edit_message(
f"セレクトメニューをクリックして選択してください\n[Botを招待]({discord.utils.oauth_url(int(bot_id), permissions=discord.Permissions(permissions=discord.Permissions.all()))})"
)
elif d == "none":
await i.response.edit_message(f"セレクトメニューをクリックして選択してください\n[Botを招待]({discord.utils.oauth_url(int(bot_id))})")
await i.response.edit_message(
f"セレクトメニューをクリックして選択してください\n[Botを招待]({discord.utils.oauth_url(int(bot_id))})"
)
else:
await i.response.edit_message("セレクトメニューをクリックして選択してください\n不明なパラメーターが選択されました。")

Expand Down
7 changes: 6 additions & 1 deletion cogs/bot_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
from discord import app_commands
from replit import db


def bot_command_count_get(data):
return db[f"bot_command_{data}_count_db"]


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


def bot_command_all_count_db_get():
return db[f"bot_command_all_count_db"]


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

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

@commands.Cog.listener(name='on_interaction')
@commands.Cog.listener(name="on_interaction")
async def interaction(self, i: discord.Interaction):
if i.type == discord.InteractionType.application_command:
bot_command_count_p1()
Expand All @@ -29,5 +33,6 @@ async def interaction(self, i: discord.Interaction):
else:
return


async def setup(bot: commands.Bot) -> None:
await bot.add_cog(bot_process(bot))
1 change: 1 addition & 0 deletions cogs/embed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

9 changes: 3 additions & 6 deletions cogs/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from discord.ext import commands
import Paginator
from discord import app_commands

a = "Tips: `/help コマンド名`でコマンドを検索できます。"


Expand All @@ -19,16 +20,12 @@ async def help(self, i: discord.Interaction, cmd: str = None) -> None:
if not cmd:
he = discord.Embed(title="ページ2", color=discord.Colour.blurple())
he.add_field(name="help", value="helpを表示します。")
he.set_footer(
text=a
)
he.set_footer(text=a)
embeds = [
discord.Embed(
title="ページ1",
color=discord.Colour.blurple(),
).set_footer(
text=a
),
).set_footer(text=a),
he,
]
return await Paginator.Simple().start(i, pages=embeds)
Expand Down
111 changes: 111 additions & 0 deletions cogs/imgcheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
from discord.ext import commands
from discord import app_commands
import discord
import aiohttp
import urllib.parse
import asyncio


class imgcheck(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot: commands.Bot = bot

@app_commands.command(name="img_url_check", description="URLの画像から拾い画かチェックするコマンド。")
async def img_url_check(self, i: discord.Interaction, url: str):
load_text = "拾い画チェッカーAPIに接続しています"
await i.response.send_message(load_text)
await asyncio.sleep(1)
await i.edit_original_response(content=f"{load_text}.")
await asyncio.sleep(1)
await i.edit_original_response(content=f"{load_text}..")
await asyncio.sleep(1)
await i.edit_original_response(content=f"{load_text}...")
async with aiohttp.ClientSession() as session:
async with session.get(
f"https://api.irucabot.com/imgcheck/check_url?url={urllib.parse.quote(url)}"
) as resp:
resp_data = await resp.json()
if resp_data["status"] == "success":
if resp_data["found"]:
await i.edit_original_response(
content=None,
embed=discord.Embed(
title="これは拾い画です。",
description=f"この画像と一致している画像が{resp_data['count']}個ありました。\n[Google画像検索結果]({resp_data['resulturl']})\n[拾い画チェッカーAPIを使用しています。](https://imgcheck.irucabot.com/api-reference/check_url)",
),
)
elif not resp_data["found"]:
await i.edit_original_response(
content=None,
embed=discord.Embed(
title="これは拾い画ではない可能性が高いです。",
description=f"この画像と一致している画像が0個ありました。\n\n[拾い画チェッカーAPIを使用しています。](https://imgcheck.irucabot.com/api-reference/check_url)",
),
)
else:
await i.edit_original_response(
content=None,
embed=discord.Embed(
title="起るはずの無いことが起こりました。",
description=f"起るはずの無いことが起こったので、結果を表示できません。",
),
)
elif resp_data["status"] == "error":
await i.edit_original_response(
content=None,
embed=discord.Embed(
title="エラーが発生しました。", description=resp_data["message_ja"]
),
)

@app_commands.command(name="img_check", description="拾い画チェッカー。")
async def imgcheck(self, i: discord.Interaction, img: discord.Attachment):
load_text = "拾い画チェッカーAPIに接続しています"
await i.response.send_message(load_text)
await asyncio.sleep(1)
await i.edit_original_response(content=f"{load_text}.")
await asyncio.sleep(1)
await i.edit_original_response(content=f"{load_text}..")
await asyncio.sleep(1)
await i.edit_original_response(content=f"{load_text}...")
async with aiohttp.ClientSession() as session:
async with session.get(
f"https://api.irucabot.com/imgcheck/check_url?url={urllib.parse.quote(img.url)}"
) as resp:
resp_data = await resp.json()
if resp_data["status"] == "success":
if resp_data["found"]:
await i.edit_original_response(
content=None,
embed=discord.Embed(
title="これは拾い画です。",
description=f"この画像と一致している画像が{resp_data['count']}個ありました。\n[Google画像検索結果]({resp_data['resulturl']})\n[拾い画チェッカーAPIを使用しています。](https://imgcheck.irucabot.com/api-reference/check_url)",
),
)
elif not resp_data["found"]:
await i.edit_original_response(
content=None,
embed=discord.Embed(
title="これは拾い画ではない可能性が高いです。",
description=f"この画像と一致している画像が0個ありました。\n\n[拾い画チェッカーAPIを使用しています。](https://imgcheck.irucabot.com/api-reference/check_url)",
),
)
else:
await i.edit_original_response(
content=None,
embed=discord.Embed(
title="起るはずの無いことが起こりました。",
description=f"起るはずの無いことが起こったので、結果を表示できません。",
),
)
elif resp_data["status"] == "error":
await i.edit_original_response(
content=None,
embed=discord.Embed(
title="エラーが発生しました。", description=resp_data["message_ja"]
),
)


async def setup(bot: commands.Bot) -> None:
await bot.add_cog(imgcheck(bot))
2 changes: 1 addition & 1 deletion cogs/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self, bot: commands.Bot) -> None:

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


async def setup(bot: commands.Bot) -> None:
Expand Down
36 changes: 21 additions & 15 deletions cogs/role_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,38 @@ class roleall(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot: commands.Bot = bot

@app_commands.describe(bot='Botにもロールを付与する?')
@app_commands.choices(bot=[
app_commands.Choice(name='はい', value="y"),
app_commands.Choice(name='いいえ', value="f"),
])
@app_commands.describe(bot="Botにもロールを付与する?")
@app_commands.choices(
bot=[
app_commands.Choice(name="はい", value="y"),
app_commands.Choice(name="いいえ", value="f"),
]
)
@app_commands.command(name="role_all_add", description="全メンバーにロールを付与します。")
async def roleall_add(self, i: discord.Interaction, role: discord.Role, bot: str):
if bot == 'y':
if bot == "y":
for member in i.guild.members:
await member.add_roles(role)
elif bot == 'f':
elif bot == "f":
for member in i.guild.members:
if not member.bot:
await member.add_roles(role)

@app_commands.describe(bot='Botのロールも除去する?')
@app_commands.choices(bot=[
app_commands.Choice(name='はい', value='y'),
app_commands.Choice(name='いいえ', value='f'),
])
@app_commands.describe(bot="Botのロールも除去する?")
@app_commands.choices(
bot=[
app_commands.Choice(name="はい", value="y"),
app_commands.Choice(name="いいえ", value="f"),
]
)
@app_commands.command(name="role_all_remove", description="全員からロールを除去します。")
async def roleall_remove(self, i: discord.Interaction, role: discord.Role, bot: str):
if bot == 'y':
async def roleall_remove(
self, i: discord.Interaction, role: discord.Role, bot: str
):
if bot == "y":
for member in i.guild.members:
await member.remove_roles(role)
elif bot == 'f':
elif bot == "f":
for member in i.guild.members:
if not member.bot:
await member.remove_roles(role)
Expand Down
4 changes: 2 additions & 2 deletions cogs/role_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ def __init__(self, bot: commands.Bot) -> None:
async def rolelists(self, i: discord.Interaction):
guild = i.guild
if len(guild.roles) > 1:
role = '\n'.join([r.mention for r in guild.roles][1:])
role = "\n".join([r.mention for r in guild.roles][1:])
embed = discord.Embed(title="ロール一覧", description=f"{role}")
await i.response.send_message(embed=embed)
else:
await i.response.send_message('ロールが見つかりませんでした。')
await i.response.send_message("ロールが見つかりませんでした。")


async def setup(bot: commands.Bot) -> None:
Expand Down
Loading