discord.py运行“commands.group()”会在指向第二个命令时发送帮助命令
很难让标题完美无瑕,但差不多。把它连接起来!!changelog是主命令,它将发送所有可用命令的列表,但我得到的问题是。无论什么时候我都会跑!!changelog message命令,将显示预设的帮助消息 图片如下: 无论何时发送消息,我只想让它说一些类似于您的消息已发送的内容 这是我的密码:discord.py运行“commands.group()”会在指向第二个命令时发送帮助命令,discord.py,discord.py-rewrite,Discord.py,Discord.py Rewrite,很难让标题完美无瑕,但差不多。把它连接起来!!changelog是主命令,它将发送所有可用命令的列表,但我得到的问题是。无论什么时候我都会跑!!changelog message命令,将显示预设的帮助消息 图片如下: 无论何时发送消息,我只想让它说一些类似于您的消息已发送的内容 这是我的密码: @commands.group(invoke_without_command=True) async def changelog(self, ctx): await ctx.send('Avai
@commands.group(invoke_without_command=True)
async def changelog(self, ctx):
await ctx.send('Available Setup Commands: \nSet Channel: <#channel>\nChangelog Message: <message>')
@changelog.command()
async def channel(self, ctx, channel: discord.TextChannel):
if ctx.message.author.guild_permissions.administrator:
db = sqlite3.connect('main.sqlite')
cursor = db.cursor()
cursor.execute(
f'SELECT channel_id FROM main WHERE guild_id = {ctx.guild.id}')
result = cursor.fetchone()
if result is None:
sql = ('INSERT INTO main(guild_id, channel_id) VALUES(?,?)')
val = (ctx.guild.id, channel.id)
await ctx.send(f'Channel has been set to {channel.mention}')
elif result is not None:
sql = ('UPDATE main SET channel_id = ? WHERE guild_id = ?')
val = (channel.id, ctx.guild.id)
await ctx.send(f'Channel has been updated to {channel.mention}')
cursor.execute(sql, val)
db.commit()
cursor.close()
db.close()
@changelog.command()
async def message(self, ctx, *, text):
if ctx.message.author.guild_permissions.manage_messages:
est = timezone('EST')
db = sqlite3.connect('main.sqlite')
cursor = db.cursor()
cursor.execute(f'SELECT channel_id FROM main WHERE 1')
channel = cursor.fetchone()
channel_id = self.client.get_channel(int(channel[0]))
message = text.capitalize()
embed = discord.Embed(
title="Changelog", description=f"● {message}", color=0)
embed.set_footer(
text=f'Published: {datetime.now(est).strftime("%Y-%m-%d %H:%M:%S")}')
await channel_id.send(embed=embed)
cursor.close()
db.close()
您可以使用ctx.u子命令检查是否正在组中运行子命令:
async def changelog(self, ctx):
if ctx.invoked_subcommand is None:
await ctx.send('Available Setup Commands: \nSet Channel <#channel>\nChangelog Message: <message>')