dcchbot 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dcchbot-1.0.0/LICENSE +10 -0
- dcchbot-1.0.0/PKG-INFO +15 -0
- dcchbot-1.0.0/README.md +3 -0
- dcchbot-1.0.0/dcchbot/__init__.py +8 -0
- dcchbot-1.0.0/dcchbot/main.py +168 -0
- dcchbot-1.0.0/dcchbot.egg-info/PKG-INFO +15 -0
- dcchbot-1.0.0/dcchbot.egg-info/SOURCES.txt +11 -0
- dcchbot-1.0.0/dcchbot.egg-info/dependency_links.txt +1 -0
- dcchbot-1.0.0/dcchbot.egg-info/entry_points.txt +2 -0
- dcchbot-1.0.0/dcchbot.egg-info/requires.txt +1 -0
- dcchbot-1.0.0/dcchbot.egg-info/top_level.txt +1 -0
- dcchbot-1.0.0/pyproject.toml +21 -0
- dcchbot-1.0.0/setup.cfg +4 -0
dcchbot-1.0.0/LICENSE
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
10
|
+
|
dcchbot-1.0.0/PKG-INFO
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: dcchbot
|
3
|
+
Version: 1.0.0
|
4
|
+
Summary: 一個簡單的中文 Discord 管理機器人,支援 GUI 按鈕封鎖/禁言/警告
|
5
|
+
Author-email: I_am_from_taiwan <102109040j@gmail.com>
|
6
|
+
License: MIT
|
7
|
+
Requires-Python: >=3.8
|
8
|
+
Description-Content-Type: text/markdown
|
9
|
+
License-File: LICENSE
|
10
|
+
Requires-Dist: discord.py>=2.3.0
|
11
|
+
Dynamic: license-file
|
12
|
+
|
13
|
+
# discordmodbot
|
14
|
+
|
15
|
+
一個支援 GUI 控制面板的 Discord 管理機器人。
|
dcchbot-1.0.0/README.md
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
# v1.0.0
|
2
|
+
import discord
|
3
|
+
from discord.ext import commands
|
4
|
+
from discord import app_commands
|
5
|
+
from datetime import timedelta
|
6
|
+
import os
|
7
|
+
|
8
|
+
intents = discord.Intents.all()
|
9
|
+
intents.guilds = True
|
10
|
+
intents.members = True
|
11
|
+
intents.message_content = True
|
12
|
+
|
13
|
+
token = os.getenv("DC_TOKEN")
|
14
|
+
|
15
|
+
bot = commands.Bot(command_prefix="!", intents=intents)
|
16
|
+
OWNER_ID = '1317800611441283139' # 修改為你的 Discord 使用者 ID
|
17
|
+
|
18
|
+
@bot.event
|
19
|
+
async def on_ready():
|
20
|
+
await bot.wait_until_ready()
|
21
|
+
try:
|
22
|
+
synced = await bot.tree.sync()
|
23
|
+
print(f"已同步 {len(synced)} 個 slash 指令")
|
24
|
+
except Exception as e:
|
25
|
+
print(f"同步 slash 指令失敗:{e}")
|
26
|
+
print(f'機器人上線:{bot.user}')
|
27
|
+
|
28
|
+
|
29
|
+
# 一般指令
|
30
|
+
|
31
|
+
@bot.tree.command(name="hello", description="跟你說哈囉")
|
32
|
+
async def hello(interaction: discord.Interaction):
|
33
|
+
await interaction.response.send_message(f"哈囉 {interaction.user.mention}")
|
34
|
+
|
35
|
+
@bot.tree.command(name="ping", description="顯示延遲")
|
36
|
+
async def ping(interaction: discord.Interaction):
|
37
|
+
await interaction.response.send_message(f"延遲:{round(bot.latency * 1000)}ms")
|
38
|
+
|
39
|
+
@bot.tree.command(name="say", description="讓機器人說話")
|
40
|
+
@app_commands.describe(message="你想說的話")
|
41
|
+
async def say(interaction: discord.Interaction, message: str):
|
42
|
+
await interaction.response.send_message(message)
|
43
|
+
|
44
|
+
|
45
|
+
# 權限檢查
|
46
|
+
|
47
|
+
def is_admin(interaction: discord.Interaction) -> bool:
|
48
|
+
return interaction.user.guild_permissions.administrator
|
49
|
+
|
50
|
+
|
51
|
+
# 管理指令(不含 emoji)
|
52
|
+
|
53
|
+
@bot.tree.command(name="ban", description="封鎖使用者(限管理員)")
|
54
|
+
@app_commands.describe(member="要封鎖的使用者", reason="封鎖原因")
|
55
|
+
async def ban(interaction: discord.Interaction, member: discord.Member, reason: str = "未提供原因"):
|
56
|
+
if not is_admin(interaction):
|
57
|
+
return await interaction.response.send_message("你沒有權限執行此指令。", ephemeral=True)
|
58
|
+
try:
|
59
|
+
await member.ban(reason=reason)
|
60
|
+
await interaction.response.send_message(f"{member.mention} 已被封鎖。原因:{reason}")
|
61
|
+
except discord.Forbidden:
|
62
|
+
await interaction.response.send_message("無法封鎖對方,可能因為權限不足或目標層級過高。", ephemeral=True)
|
63
|
+
|
64
|
+
@bot.tree.command(name="kick", description="踢出使用者(限管理員)")
|
65
|
+
@app_commands.describe(member="要踢出的使用者", reason="踢出原因")
|
66
|
+
async def kick(interaction: discord.Interaction, member: discord.Member, reason: str = "未提供原因"):
|
67
|
+
if not is_admin(interaction):
|
68
|
+
return await interaction.response.send_message("你沒有權限執行此指令。", ephemeral=True)
|
69
|
+
try:
|
70
|
+
await member.kick(reason=reason)
|
71
|
+
await interaction.response.send_message(f"{member.mention} 已被踢出。原因:{reason}")
|
72
|
+
except discord.Forbidden:
|
73
|
+
await interaction.response.send_message("無法封鎖對方,可能因為權限不足或目標層級過高。", ephemeral=True)
|
74
|
+
|
75
|
+
@bot.tree.command(name="timeout", description="暫時禁言使用者(限管理員)")
|
76
|
+
@app_commands.describe(member="要禁言的使用者", seconds="禁言秒數", reason="禁言原因")
|
77
|
+
async def timeout(interaction: discord.Interaction, member: discord.Member, seconds: int, reason: str = "未提供原因"):
|
78
|
+
if not is_admin(interaction):
|
79
|
+
return await interaction.response.send_message("你沒有權限執行此指令。", ephemeral=True)
|
80
|
+
try:
|
81
|
+
await member.timeout_for(timedelta(seconds=seconds), reason=reason)
|
82
|
+
await interaction.response.send_message(f"{member.mention} 已被禁言 {seconds} 秒。原因:{reason}")
|
83
|
+
except Exception as e:
|
84
|
+
await interaction.response.send_message(f"無法禁言:{e}")
|
85
|
+
except discord.Forbidden:
|
86
|
+
await interaction.response.send_message("無法對方,可能因為權限不足或目標層級過高。", ephemeral=True)
|
87
|
+
|
88
|
+
@bot.tree.command(name="warn", description="警告使用者(限管理員)")
|
89
|
+
@app_commands.describe(member="要警告的使用者", reason="警告原因")
|
90
|
+
async def warn(interaction: discord.Interaction, member: discord.Member, reason: str = "未提供原因"):
|
91
|
+
if not is_admin(interaction):
|
92
|
+
return await interaction.response.send_message("你沒有權限執行此指令。", ephemeral=True)
|
93
|
+
await interaction.response.send_message(f"{member.mention} 已被警告。原因:{reason}")
|
94
|
+
try:
|
95
|
+
await member.send(f"你在伺服器 {interaction.guild.name} 被警告:{reason}")
|
96
|
+
except:
|
97
|
+
await interaction.followup.send("無法傳送私人訊息給該用戶。")
|
98
|
+
# ⏹️ GUI 控制面板 View
|
99
|
+
class ModerationView(discord.ui.View):
|
100
|
+
def __init__(self, member: discord.Member, author: discord.Member):
|
101
|
+
super().__init__(timeout=60) # GUI 存活時間秒
|
102
|
+
self.member = member
|
103
|
+
self.author = author
|
104
|
+
|
105
|
+
async def interaction_check(self, interaction: discord.Interaction) -> bool:
|
106
|
+
# 僅限原始執行者互動
|
107
|
+
return interaction.user.id == self.author.id
|
108
|
+
|
109
|
+
@discord.ui.button(label="警告", style=discord.ButtonStyle.secondary)
|
110
|
+
async def warn_button(self, interaction: discord.Interaction, button: discord.ui.Button):
|
111
|
+
try:
|
112
|
+
await self.member.send(f"你在伺服器 {interaction.guild.name} 被警告。請注意言行。")
|
113
|
+
except:
|
114
|
+
pass
|
115
|
+
await interaction.response.send_message(f"{self.member.mention} 已被警告。", ephemeral=True)
|
116
|
+
|
117
|
+
@discord.ui.button(label="禁言 60 秒", style=discord.ButtonStyle.primary)
|
118
|
+
async def timeout_button(self, interaction: discord.Interaction, button: discord.ui.Button):
|
119
|
+
try:
|
120
|
+
await self.member.timeout_for(timedelta(seconds=60), reason="由管理員 GUI 操作禁言")
|
121
|
+
await interaction.response.send_message(f"{self.member.mention} 已被禁言 60 秒。", ephemeral=True)
|
122
|
+
except Exception as e:
|
123
|
+
await interaction.response.send_message(f"禁言失敗:{e}", ephemeral=True)
|
124
|
+
|
125
|
+
@discord.ui.button(label="踢出", style=discord.ButtonStyle.danger)
|
126
|
+
async def kick_button(self, interaction: discord.Interaction, button: discord.ui.Button):
|
127
|
+
try:
|
128
|
+
await self.member.kick(reason="由管理員 GUI 操作踢出")
|
129
|
+
await interaction.response.send_message(f"{self.member.mention} 已被踢出。", ephemeral=True)
|
130
|
+
except Exception as e:
|
131
|
+
await interaction.response.send_message(f"踢出失敗:{e}", ephemeral=True)
|
132
|
+
|
133
|
+
@discord.ui.button(label="封鎖", style=discord.ButtonStyle.danger)
|
134
|
+
async def ban_button(self, interaction: discord.Interaction, button: discord.ui.Button):
|
135
|
+
try:
|
136
|
+
await self.member.ban(reason="由管理員 GUI 操作封鎖")
|
137
|
+
await interaction.response.send_message(f"{self.member.mention} 已被封鎖。", ephemeral=True)
|
138
|
+
except Exception as e:
|
139
|
+
await interaction.response.send_message(f"封鎖失敗:{e}", ephemeral=True)
|
140
|
+
|
141
|
+
|
142
|
+
# ⏹️ Slash 指令:呼叫 GUI 管理面板
|
143
|
+
@bot.tree.command(name="moderate", description="打開管理 GUI 面板")
|
144
|
+
@app_commands.describe(member="要管理的對象")
|
145
|
+
async def moderate(interaction: discord.Interaction, member: discord.Member):
|
146
|
+
if not is_admin(interaction):
|
147
|
+
return await interaction.response.send_message("你沒有權限使用此指令。", ephemeral=True)
|
148
|
+
|
149
|
+
view = ModerationView(member, interaction.user)
|
150
|
+
await interaction.response.send_message(
|
151
|
+
f"請選擇對 {member.mention} 的操作:",
|
152
|
+
view=view,
|
153
|
+
ephemeral=True # 只有執行者看得見
|
154
|
+
)
|
155
|
+
|
156
|
+
|
157
|
+
# 擁有者限定關閉指令
|
158
|
+
|
159
|
+
@bot.tree.command(name="stop", description="關閉機器人(限擁有者)")
|
160
|
+
async def stop(interaction: discord.Interaction):
|
161
|
+
if interaction.user.id != OWNER_ID:
|
162
|
+
return await interaction.response.send_message("只有擁有者可以使用此指令。", ephemeral=True)
|
163
|
+
await interaction.response.send_message("機器人即將關閉。")
|
164
|
+
await bot.close()
|
165
|
+
|
166
|
+
|
167
|
+
# 啟動 Bot
|
168
|
+
bot.run("MTMyMDE4NTExMjY3MTAzMTM0Nw.GypVga.HaCaNcHjTBK2gh35Si8v93eD3aPhGVwyBbVnCg")
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: dcchbot
|
3
|
+
Version: 1.0.0
|
4
|
+
Summary: 一個簡單的中文 Discord 管理機器人,支援 GUI 按鈕封鎖/禁言/警告
|
5
|
+
Author-email: I_am_from_taiwan <102109040j@gmail.com>
|
6
|
+
License: MIT
|
7
|
+
Requires-Python: >=3.8
|
8
|
+
Description-Content-Type: text/markdown
|
9
|
+
License-File: LICENSE
|
10
|
+
Requires-Dist: discord.py>=2.3.0
|
11
|
+
Dynamic: license-file
|
12
|
+
|
13
|
+
# discordmodbot
|
14
|
+
|
15
|
+
一個支援 GUI 控制面板的 Discord 管理機器人。
|
@@ -0,0 +1,11 @@
|
|
1
|
+
LICENSE
|
2
|
+
README.md
|
3
|
+
pyproject.toml
|
4
|
+
dcchbot/__init__.py
|
5
|
+
dcchbot/main.py
|
6
|
+
dcchbot.egg-info/PKG-INFO
|
7
|
+
dcchbot.egg-info/SOURCES.txt
|
8
|
+
dcchbot.egg-info/dependency_links.txt
|
9
|
+
dcchbot.egg-info/entry_points.txt
|
10
|
+
dcchbot.egg-info/requires.txt
|
11
|
+
dcchbot.egg-info/top_level.txt
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
discord.py>=2.3.0
|
@@ -0,0 +1 @@
|
|
1
|
+
dcchbot
|
@@ -0,0 +1,21 @@
|
|
1
|
+
[project]
|
2
|
+
name = "dcchbot"
|
3
|
+
version = "1.0.0"
|
4
|
+
description = "一個簡單的中文 Discord 管理機器人,支援 GUI 按鈕封鎖/禁言/警告"
|
5
|
+
readme = "README.md"
|
6
|
+
license = {text = "MIT"}
|
7
|
+
authors = [
|
8
|
+
{ name = "I_am_from_taiwan", email = "102109040j@gmail.com" }
|
9
|
+
]
|
10
|
+
requires-python = ">=3.8"
|
11
|
+
dependencies = ["discord.py>=2.3.0"]
|
12
|
+
|
13
|
+
[project.scripts]
|
14
|
+
dcchbot = "dcchbot.main"
|
15
|
+
|
16
|
+
[tool.setuptools]
|
17
|
+
packages = ["dcchbot"]
|
18
|
+
|
19
|
+
[build-system]
|
20
|
+
requires = ["setuptools>=61.0"]
|
21
|
+
build-backend = "setuptools.build_meta"
|
dcchbot-1.0.0/setup.cfg
ADDED