好的,所以我正在制造一个不和谐的机器人,但是当我输入k!帮助这个消息出现:
No Category:
help Shows this message
info
kill
mention
prank
repeat
roast
say
Type k!help command for more info on a command.
You can also type k!help category for more info on a category.
我注意到了上面的no category,我想知道我是否能为命
我最近才在使用discord.py和discord.ext命令扩展来制作机器人时遇到一个问题 当我调用一个命令时,它会运行两次,导致许多错误和错误。它仅在添加此命令后才开始发生 @commands.command()
async def afk(self, ctx, userMessage):
#if user is already afk, remove them from the afk dict, if not add them to it
if ctx.message.author in self.afkUsers:
下面是一个使用discord.py api解决不和谐问题的工作支持票证机器人。有一个斜杠命令来启动系统,它会弹出一个按钮来提交一个票证,当点击它时会创建一个新的文本通道,其中只有票证创建者和管理员可以访问。此外,在创建票证(通道)时,通知将发送到web钩子,而通知弹出将发送给公会。管理员或票证创建者可以选择在会话中添加或删除频道(票证)中的成员,当操作结束时,将有一个按钮关闭和/或创建可下载的抄本。它就像现在一样工作。我只想知道它是否有任何漏洞或领域需要改进,或者仅仅是糟糕的代码实践。谢谢。
import discord, os
from datetime import datetime
fr
我有一个命令,它让用户为某件东西下订单,当这个命令被放置时,它会将订单的消息发送到特定的频道。现在,我已经在我的main.py文件中这样做了,但这是在一个齿轮,我有一些问题。我不明白这里有什么问题。
await client.wait_until_ready()
channel = ctx.client.get_channel(851150407849213992)
await channel.send(order) # order is already defined previously
是否可以使用不同文件夹中的齿轮,例如commands/和economy_commands/。
我的代码是
for extension in os.listdir('commands/') and os.listdir('economy_commands/'):
if extension.endswith('.py'):
print('loaded ' + extension)
client.load_extension(f'commands.{exte
这是带有错误的代码行:
number = await self.client.wait_for("message", check=lambda m: m.author == ctx.author and m.channel == ctx.channel, timeout=20.0)
这一行位于“Shop”类中,如下所示:
class Shop(commands.Cog, name="Shop"):
"""asks for a number of how much to buy"""
def __in
在使用cogs的同时,如何在discord.py中使用命令组(子命令)?它会和平常一样吗?不使用齿轮的正常含义?或者我需要做些额外的事情。我已经查看了discord.py文档,但似乎什么也找不到。如果有人能给我展示一个如何使用带有齿轮的命令组的例子,那就太好了。 我尝试过以下几种方法: #This is in a cog
@bot.group(pass_context=True) 但是我的代码linter一直说机器人是未定义的。 当我尝试的时候: #This is in a cog
@self.bot.group(pass_context=True) 它说的“自我”是不确定的。
我有一个小问题,你可以跳过,不会给你一个大错误,不让你运行机器人,它是非常令人沮丧的。 代码: import asyncio
import discord
from discord.ext import commands
from main import db
^^^^ Unable to import 'main' [pylint(import-error)]
import datetime
import random 我使用的是cogs,所以这就是我从main导入的原因。
让我们假设on_member_join事件 @commands.Cog.listener()
async def on_member_join(self, member):
# On member joins we find a channel called general and if it exists,
# send an embed welcoming them to our guild
channel = discord.utils.get(member.guild.text_channels, name="welcome")
if
我的ping命令中的bot.latency有问题。
首先,我宣布了我的机器人实例如下:
bot = commands.Bot(
description='Genos Bot Help Section - prefix: ^ ',
command_prefix='^',
case_insensitive=True,
guild_subscriptions=True,
intents=intents
) # I have this in one line in my program, but I wrote it like that in order t
所以我现在在discord.py中,每当我直接编辑bot.py (我的主文件)时,我就可以实现建议命令的一个版本。
@bot.command(name = 'suggest', help = 'Use this command to give a suggestion to the server')
async def suggest(ctx, content):
channel = discord.utils.get(bot.guilds[0].channels, name = 'suggestions')
print('
所以,我的代码看起来有点像这样
main.py
import (all the required imports are here)
@bot.event
async def on_ready():
print('----------')
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
bot.load_extension(f'cogs.{filename[:-3]}')
bot.run('