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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ coverage.xml
# Translations
*.mo
*.pot

.vscode/
# Django stuff:
*.log
local_settings.py
Expand Down
32 changes: 20 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
# このBotへ貢献
## Issueを作成するとき
1. その内容のIssueが既に存在していないかを確認して下さい。(クローズ済みのものも)
# この Bot へ貢献

## Issue を作成するとき

1. その内容の Issue が既に存在していないかを確認して下さい。(クローズ済みのものも)
2. 内容を書き込みます。(テンプレートの場合は文字などを変更します)
3. Issueを作成します。
## Pull requestを作成する時
1. その内容のPull requestが既に存在していないかを確認して下さい。(マージ済み、クローズ済みのものも)
3. Issue を作成します。

## Pull request を作成する時

1. その内容の Pull request が既に存在していないかを確認して下さい。(マージ済み、クローズ済みのものも)
2. もう実装されていないか確認して下さい。
3. Forkし、コードを書いて、内容を書き込みます。
4. Pull requestを作成します。
3. Fork し、コードを書いて、内容を書き込みます。
4. Pull request を作成します。<br>
WIP の場合は、`🚧WIP: oo`にしてください。

## コミットメッセージ
何かを作った: `new: ○○`<br>
何かを修正した: `fix: ○○`<br>
何かを変更した: `change: ○○`<br>
何かを更新した: `update: ○○`<br>

何かを作った: `✨new: ○○`<br>
何かを修正した: `🐛fix: ○○`<br>
何かを変更した: `🔄change: ○○`<br>
何かを更新した: `🆙update: ○○`<br>
何かを削除した: `🗑️delete: oo`<br>
2 changes: 1 addition & 1 deletion cogs/5000.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def gosen(
noalpha: str,
rainbow: str,
):
embed = discord.Embed(title="5000兆円ほしい!!").set_image(url=f"https://gsapi.cbrx.io/image?top={urllib.parse.quote(top)}&bottom={urllib.parse.quote(bottom)}&type={urllib.parse.quote(type)}&q={urllib.parse.quote(quality)}&hoshii={urllib.parse.quote(hoshii)}&noalpha={urllib.parse.quote(noalpha)}&rainbow={urllib.parse.quote(rainbow)}")
embed = discord.Embed(title="5000兆円ほしい!!", color=0x3498DB).set_image(url=f"https://gsapi.cbrx.io/image?top={urllib.parse.quote(top)}&bottom={urllib.parse.quote(bottom)}&type={urllib.parse.quote(type)}&q={urllib.parse.quote(quality)}&hoshii={urllib.parse.quote(hoshii)}&noalpha={urllib.parse.quote(noalpha)}&rainbow={urllib.parse.quote(rainbow)}")
await i.response.send_message(
embed=embed
)
Expand Down
10 changes: 5 additions & 5 deletions cogs/afk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from discord import app_commands
from replit import db
import discord
from color import color


def afk_set_db(key, data):
db[f"afk_{key}"] = data
Expand All @@ -25,7 +25,7 @@ async def afks(self, i: discord.Interaction, reason: str):
embed=discord.Embed(
title="<:check_mark:985366958537076766> : 成功",
description="afkをセットしました。",
color=color,
color=0x3498DB,
),
ephemeral=True,
)
Expand All @@ -34,7 +34,7 @@ async def afks(self, i: discord.Interaction, reason: str):
embed=discord.Embed(
title="<:error_mark:985366305156767794> : 失敗",
description="何らかのエラーが発生しました。",
color=color,
color=0x3498DB,
),
ephemeral=True,
)
Expand All @@ -47,7 +47,7 @@ async def afkk(self, i: discord.Interaction):
embed=discord.Embed(
title="<:check_mark:985366958537076766> : 成功",
description="afkを解除しました。",
color=color,
color=0x3498DB,
),
ephemeral=True,
)
Expand All @@ -56,7 +56,7 @@ async def afkk(self, i: discord.Interaction):
embed=discord.Embed(
title="<:error_mark:985366305156767794> : 失敗",
description="何らかのエラーが発生しました。",
color=color,
color=0x3498DB,
),
ephemeral=True,
)
Expand Down
26 changes: 26 additions & 0 deletions cogs/auto-news.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import discord
from discord.ext import commands


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

@commands.Cog.listener(name="on_message")
async def msg_auto_news(self, msg: discord.Message):
if msg.channel.type == discord.ChannelType.news:
if msg.channel.topic:
if msg.channel.topic.startswith("eight-auto-news"):
await msg.publish()
await msg.add_reaction("✅")
return
else:
return
else:
return
else:
return


async def setup(bot: commands.Bot) -> None:
await bot.add_cog(auto_news(bot))
5 changes: 4 additions & 1 deletion cogs/ban_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ async def ban_members(self, i: discord.Interaction):
send_content = "".join(m)
elif len(m) == 0:
send_content = "Banされたユーザーはいません。"
await i.response.send_message(send_content)
try:
await i.response.send_message(embed=discord.Embed(title="Banされたユーザー", description=send_content, color=0x3498DB), ephemeral=True)
except:
await i.response.send_message(embed=discord.Embed(title="Banされたユーザー", description="取得できませんでした。", color=0x3498DB), ephemeral=True)


async def setup(bot: commands.Bot) -> None:
Expand Down
2 changes: 1 addition & 1 deletion cogs/bot_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, bot: commands.Bot) -> None:
@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(
embed=discord.Embed(title="Botの情報", color=0x3498DB).add_field(
name="全コマンドの合計実行数", value=str(bot_command_all_count_db_get())
),
ephemeral=True,
Expand Down
39 changes: 23 additions & 16 deletions cogs/bot_invite.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ def db_set(key, data):
def db_get(key):
return db[f"bot_invite_db_id_{key}"]


class MyView(discord.ui.View):
@discord.ui.select(
placeholder="招待するBotの権限を選択して下さい",
def __init__(self):
super().__init__(timeout=None)
self.add_item(MySelect())

class MySelect(discord.ui.Select):
def __init__(self):
super().__init__(placeholder="招待するBotの権限を選択して下さい",
min_values=1,
custom_id="bot_invite_myview_select_menu",
max_values=1,
options=[
discord.SelectOption(
Expand All @@ -29,26 +34,28 @@ class MyView(discord.ui.View):
discord.SelectOption(
label="権限なし", description="全ての権限をなしにしたURLを生成します。", value="none"
),
],
)
async def select_callback(self, select, i):
])

async def callback(self, i: discord.Interaction):
bot_id = db_get(i.message.id)
d = select.values[0]
d = self.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.send_message(
ephemeral=True,
content=f"[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.send_message(
ephemeral=True,
content=f"[Botを招待]({discord.utils.oauth_url(int(bot_id), permissions=discord.Permissions(permissions=discord.Permissions.all().value))})"
)
elif d == "none":
await i.response.edit_message(
f"セレクトメニューをクリックして選択してください\n[Botを招待]({discord.utils.oauth_url(int(bot_id))})"
await i.response.send_message(
ephemeral=True,
content=f"[Botを招待]({discord.utils.oauth_url(int(bot_id))})"
)
else:
await i.response.edit_message("セレクトメニューをクリックして選択してください\n不明なパラメーターが選択されました。")

await i.response.send_message("不明なパラメーターが選択されました。", ephemeral=True)

class bot_invite(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
Expand All @@ -68,7 +75,7 @@ async def botinvite(self, i: discord.Interaction, bot: discord.User = None):
else:
await i.response.send_message("セレクトメニューをクリックして選択してください")
msg = await self.bot.get_channel(i.channel.id).send(view=MyView())
db_set(int(msg.id), int(self.bot.id))
db_set(int(msg.id), int(self.bot.user.id))
self.bot.add_view(MyView(), message_id=msg.id)


Expand Down
18 changes: 12 additions & 6 deletions cogs/bot_process.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import discord
from discord.ext import commands
from discord import app_commands
from replit import db


Expand All @@ -9,15 +8,22 @@ def bot_command_count_get(data):


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


def bot_command_all_count_db_get():
return db[f"bot_command_all_count_db"]
return db["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
try:
db["bot_command_all_count_db"] = int(bot_command_all_count_db_get()) + 1
return
except KeyError:
db["bot_command_all_count_db"] = 0 + 1


class bot_process(commands.Cog):
Expand All @@ -28,8 +34,8 @@ def __init__(self, bot: commands.Bot) -> None:
async def interaction(self, i: discord.Interaction):
if i.type == discord.InteractionType.application_command:
bot_command_count_p1()
if self.bot.tree.get_command(i.command.name):
bot_command_count(i.command.name)
if i.command:
bot_command_count(data=i.command.name)
else:
return

Expand Down
80 changes: 80 additions & 0 deletions cogs/embed.py
Original file line number Diff line number Diff line change
@@ -1 +1,81 @@
from discord.ext import commands
from discord import app_commands
import discord
from discord import ui, TextStyle


class Modal(ui.Modal, title='Embed作成パネル'):
titles = ui.TextInput(label="タイトル", style=TextStyle.long,
placeholder="埋め込みのタイトル。256文字まで", max_length=256, required=False)
description = ui.TextInput(label="説明", style=TextStyle.long,
placeholder="埋め込みの説明。4000文字まで", max_length=4000, required=True)
set_footer_text = ui.TextInput(label="フッターテキスト", style=TextStyle.long,
placeholder="フッターテキスト。2048文字まで", max_length=2048, required=False)
f_icon_url = ui.TextInput(label="フッターアイコン", style=TextStyle.short,
placeholder="フッターアイコンのURL。Http(s)のみ", required=False)
samuneiru = ui.TextInput(label="サムネイル", style=TextStyle.short,
placeholder="埋め込みコンテンツのサムネイル。Http(s)のみ", required=False)

async def on_submit(self, interaction: discord.Interaction):
if str(self.f_icon_url).startswith("http://") or str(self.samuneiru).startswith("http://") or str(self.f_icon_url).startswith("https://") or str(self.samuneiru).startswith("https://"):
await interaction.response.send_message("URLはhttp(s)から始まります。", ephemeral=True)
return
embed = discord.Embed(title=self.titles, description=self.description)
embed.set_footer(text=self.set_footer_text, icon_url=self.f_icon_url)
embed.set_thumbnail(url=self.samuneiru)
buttonView = discord.ui.View(timeout=None)
buttonView.add_item(discord.ui.Button(
label="Discord Color", style=discord.ButtonStyle.primary, custom_id="color_01"
))
buttonView.add_item(
discord.ui.Button(
label="灰色", style=discord.ButtonStyle.secondary, custom_id="color_02"
))
buttonView.add_item(
discord.ui.Button(
label="緑", style=discord.ButtonStyle.success, custom_id="color_03"
))
buttonView.add_item(
discord.ui.Button(
label="赤", style=discord.ButtonStyle.danger, custom_id="color_04"
))
await interaction.response.send_message(embed=embed, view=buttonView)


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

@commands.Cog.listener(name="on_interaction")
async def color_interaction(self, i: discord.Interaction):
if i.data.get("custom_id") == "color_01":
em = i.message.embeds[0]
em.color = 0x5865F2
await i.message.edit(embed=em)
return await i.response.send_message("完了!", ephemeral=True)
if i.data.get("custom_id") == "color_02":
em = i.message.embeds[0]
em.color = 0x4F545C
await i.message.edit(embed=em)
return await i.response.send_message("完了!", ephemeral=True)
if i.data.get("custom_id") == "color_03":
em = i.message.embeds[0]
em.color = 0x43B581
await i.message.edit(embed=em)
return await i.response.send_message("完了!", ephemeral=True)
if i.data.get("custom_id") == "color_04":
em = i.message.embeds[0]
em.color = 0xF04747
await i.message.edit(embed=em)
return await i.response.send_message("完了!", ephemeral=True)

else:
return

@app_commands.command(name="embed_make", description="Embedを作成し、送信します。")
async def embed_make(self, i: discord.Interaction):
await i.response.send_modal(Modal())


async def setup(bot: commands.Bot) -> None:
await bot.add_cog(embed_make(bot))
Loading