我想从我的raspberry pi运行一个不和谐的机器人,这样我就可以让它始终运行,所以我转移到bot文件上。顺便说一下,这个机器人是用蟒蛇制造的。我说no module named discord时出错了。这是因为我没有安装不和谐装置。每当我尝试使用pip3 install discord时,我都会收到一条消息,说它成功了,但是安装在Python3.4下。我需要在Python3.5下安装它,这样我的bot的代码才能正常运行。如果我尝试使用python3 -m pip install discord,就会得到错误/usr/local/bin/python3: No module named p
因此,我对python还不熟悉,更不熟悉如何在不和谐的情况下编写机器人代码。目前我正在使用discord.py和red ()。
目前,我正试图让机器人听一条新消息,并打印响应它的东西,但我就是搞不明白。由于我使用的是red,所以我没有使用client = discord.Client()和在代码本身上设置令牌,所以使用@client.event()似乎不起作用,也不使用@bot.event(),而且我也找不到任何其他方法让机器人侦听on_message()事件。
用我的部分代码编辑:
import discord
from discord.ext import commands
from re
到目前为止,这就是我所拥有的:
from discord import Embed
import os
import discord
bot=discord.Client()
nichDat=["|","~",".",",","!","pls"]
@bot.event
async def on_message(message):
if message.content != "NothingButABot":
return
for guild in
我正在discord.py制造一个不和谐的机器人。我在控制台收到一条警告信息,我不知道该怎么处理。
RuntimeWarning: coroutine 'Command.__call__' was never awaited
print(f"Bot is online {client.user}")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
@client.event
async def on_ready():
await client.chan
这是我的代码 main.py import discord
from discord.ext import commands
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')
@client.event
async def on_message(message):
if client.user == message.author:
retur
我目前正在创建一个不和谐的机器人,它包含两个任务循环,名为check_members和check_music。
当用户输入offline命令时,我想优雅地停止这些循环。我在Cog类中编写了这段代码:
class MusicBot(commands.Cog):
# function called when bot is closing.
See [here](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html?highlight=cog_unload#discord.ext.commands.Cog.c
我开始写一个不和谐的机器人,但我确实遇到了一个问题。我只是写了一些写的小改动,不应该对程序造成太大的影响。我有两个类,主类只获取bot的令牌,然后用
MyBot bot = MyBot(token)
下面是MyBot.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Discord;
using Discord.Commands;
namespace Coding_Bot
{
clas
我知道我是新来的,但我有个问题要问你:
如果您想用Python编写一个带有特殊齿轮的不和谐的机器人,并用以下方式替换默认的help命令,该怎么办:
@commands.command(pass_context=True)
async def help(self,ctx,*cog:str):
"""Gives you info on my cogs *and* their commands."""
if not cog:
halp=discord.Embed(title='Cog Listing and Un
我想做一个简单的音乐机器人。当我执行命令时,我得到以下错误:discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.
这是我的密码:
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix= "-")
class VoiceConnectionError(commands.CommandError):
""
我的Discord机器人使用on_message函数在discord.py上运行。如何创建关闭和重新启动Bot的命令?
我的机器人运行在托管在repl.it上的服务器上。
代码:
if message.content.upper().startswith("!SHUTDOWN"):
if "534116283487223809" in [role.id for role in message.author.roles]:
await client.send_message(message.channel, "*Shutting D