我有一个命令,可以禁用特定通道中的特定命令。因此,我将其保存在一个json文件中。然后,我要检查是否执行了一个命令,以及该命令是否在json文件中。如果这个命令在json文件中,它应该打印一条消息。否则,它应该执行该命令。
我的代码:
@bot.event
async def on_command(ctx):
with open('commandchannels.json', 'r') as fcheck:
check = json.load(fcheck)
if f'{ctx.guild.id}' in chec
你好,我正在用一种方法创建一个机器人,它从文本文件中读取列表,如果用户发送消息,机器人将禁止或踢掉该用户,而不需要键入命令。它的工作与删除,所以我使它类似于ban或kick方法,似乎没有错误,但事件不运行,这是我所拥有的,是的,我把读取的txt文件在代码中,所以它正在读取txt文件,而不是踢或禁止。
@client.event
async def kick(member : discord.member,message):
for kickable_word in kickable_words:
if kickable_word in message.content:
因此,当用户指定Youtube URL时,我正在创建一个播放音乐的音乐机器人,代码如下:
@commands.command() # I'm creating this command in a cog by the way
async def play(self, ctx, url: str):
# Stop the current track if a song was playing.
ctx.voice_client.stop()
# Just some stuff that help the bot play the specified so
用于不一致的机器人库,
bot.on('messageCreate', msg => {
// do some stuff
bot.removeListener('messageCreate', msg);
});
我经常遇到的一个错误是listener must be a function。messageCreate在收到消息时触发,msg是对消息类的引用,其中包含消息id、作者等。
我想要得到的是等待用户回复的机器人,比如Yes或No。
我试图找到一种方法来编程我的机器人,以清除特定数量的消息在一个渠道。但是,我不知道如何让我的机器人根据用户的输入数据运行它的代码。例如,假设我是一个用户,希望清除特定数量的消息,比如15条消息。我想让我的机器人清除15条信息,不多,不少。我该怎么做?
if message.content == "{clear":
await message.channel.send("Okay")
await message.channel.send("How many messages should I clear my dear sir?
有没有办法在单元测试通过时显示一条消息。例如它正在测试的内容。
我知道我可以在消息无法通过时显示该消息
function testOne (testCase)
% some test here
msg = 'This will show what it fails';
testCase.assertEqual(properties(Object), expProp, msg);
end
我一直在考虑在我的不和谐机器人中制作一个21点游戏,但我遇到了一个障碍。
显然,我有一个用命令.blackjack调用的游戏,它在生成随机值和发送消息方面工作得很好。但是,我不知道怎么做,所以玩家能够在发牌的消息发出后说点击或站立,例如。
@client.command()
async def blackjack(ctx):
# (insert all random number gens, etc. here)
await ctx.send(f"{dface1}{dsuit1} ({dvalue1}), {dface2}{dsuit2} ({dvalue2}
我一直在寻找一个适用于我的代码的答案,但我真的找不到答案。我知道如何创建按钮并将它们添加到嵌入的底部,但我无法让它们发送隐藏的消息。这是我的按钮代码:
buttons = [
create_button(style=ButtonStyle.green, label="I liked it"),
create_button(style=ButtonStyle.grey, label="I'm neutral"),
create_button(style=ButtonStyle.red, label="I did not like i
好的,所以我正在制造一个不和谐的机器人,但是当我输入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,我想知道我是否能为命
我的命令可以工作,但它也显示了这个奇怪的错误消息。当我执行p!help时,我会得到响应和错误消息:
No Category:
clean
help Shows this message
sudo
Type p!help command for more info on a command.
You can also type p!help category for more info on a category.