嗨,我得到了错误
File "C:\Users\Tom\Documents\bot\cogs\misccoms.py", line 28, in giveRole
example = discord.utils.get(ctx.message.server.roles,name='Example')
AttributeError: 'Misccoms' object has no attribute 'message'
从这行代码中
@commands.command(pass_context=True, no_pm=
我正在尝试创建一个命令来删除指定数量的消息。我得到了这个错误:
Ignoring exception in on_message
Traceback (most recent call last):
File "/home/runner/Erlc-Mafia-Bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 38,
如果应用程序无法响应3s内的交互,不和谐将自动超时并触发自定义的“此交互失败”消息。
然而,我正在运行一些稍微长一些的任务,所以我调用了ctx.defer()方法,它给了我更多的时间来响应,并显示了一个"<application_name>正在思考.“动画片不和谐的一面。
如果我的任务引发一些内部异常,我想手动触发“此交互失败”消息。不和谐的API是否公开了这样做的方法?
我想要触发的信息
一个虚拟示例,使用discord-py-slash-command
import discord
from discord.ext import commands
from d
我想做一个简单的音乐机器人。当我执行命令时,我得到以下错误: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):
""
下面是我正在使用的代码: import discord
import random
import asyncio
from discord.ext import commands
from discord.ext.commands import bot
from discord.utils import get
def IsTeam(role):
Value = False
AllTeams = [] # Add all teams in here.
if role in AllTeams:
Value = True
return Value
@bot.co
我试着用discord.py做了一个机器人
bot = commands.Bot(command_prefix='$', description="This is a test bot")
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
@bot.command(name='ping')
async def ping(ctx):
await ctx.send("pong
我有一个用Discord.py编写的预生成代码,它使用Heroku托管,目前它是在线的,只是每当我使用一个命令时,它就什么也不返回,但是当在本地使用Notepad++运行它时,这些命令工作得很好。
main.py
import discord
from discord.ext import commands
token = 'OBVIOUSLY THE TOKEN IS HERE'
prefix = "?"
intents = discord.Intents.default() # or .all() if you ticked all, that is eas
我正在编写一个机器人,下面是完整的代码: print("Loading bot...")
import discord
import time
import asyncio
import datetime
import requests
from discord.ext import commands
from discord.ext import tasks
from discord.utils import get
from webserver import keep_alive
import os
intents = discord.Intents.default
该命令的目的是向上述用户添加一个点(硬币)(如果它们还没有在数据库中,则将它们添加到数据库中),但我得到的是NameError: name 'member‘是没有定义的。
@client.command()
async def gift(ctx,*, member : discord.Member):
with open('users.json', 'r') as f:
users = json.load(f)
await update_data(users, member.id)
await a
所以我试着从另一个公会获取和发送用户的头像,我有一种工作方式,但它在文档中显示为This method is an API call. For general usage, consider get_member() instead.。我想知道这是否可能是不安全的,因为我使用的是一个用户帐户,因为在没有好的服务器的情况下制作机器人是无聊的。
@bot.command(usage="test2", description="test")
async def test2(ctx, user):
await ctx.message.delete()
p
我的机器人有点问题。我正在尝试让bot工作,这样如果它接收到一个带有“上诉”命令的DM,机器人就会将请求发送到服务器的#上诉通道。到目前为止,这就是我所得到的:
@bot.command()
async def appeal(ctx, guild_id, *reasons):
'''Command for a user to DM the bot with an appeal, and have that appeal sent to the corresponding server.'''
# Checking if
所以我现在在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('
如果我使用.join与下面的代码不一致,我会得到以下错误:
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "join" is not found
我不确定如何解决这个问题(这将变成音乐机器人的一部分)。相关代码如下:
import discord
import discord.voice_client
from discord import utils
from discord.ext import commands
from discord.ut
我最近开始尝试使用discord.py进行机器人开发,我一直在与某种情况作斗争,在这种情况下,我在Cogs中使用常规的类方法。下面是一个示例,机器人应该对'-hello‘命令回复"hello Here“: import discord
from discord.ext import commands
import os
from dotenv import load_dotenv
load_dotenv()
class TestCog(commands.Cog):
def __init__(self):
super().__init__()
我正在为一个口袋妖怪服务器制作一个机器人,我正在尝试做出一个命令,将“健身房领袖”的角色交给另一个用户。我尝试使用该命令,并使用test命令,但是服务器和shell中都没有响应。
import os
import discord
from dotenv import load_dotenv
from discord.ext import commands
from discord.utils import get
bot = commands.Bot(command_prefix='b!', case_insensitive=True)
load_dotenv()
TOKE
我正在做一个简单的仲裁机器人,其中一个命令使用Discord.py来操作某个人(将他们的角色提升为版主)。
这是正在讨论的命令,它位于cog内(命令为discord.ext.commands):
commands.command(name='mod', hidden = True)
#just the mods, the bot role and the server creator can use this command, hence why the decorator below:
@commands.has_any_role("role1","r
我正在寻找一种方法,将以下内容添加到我的音乐机器人:
一个队列函数,允许在另一个播放时输入歌曲。然后,在第一首歌曲结束后,能够显示这个队列,然后通过播放函数将歌曲从队列中移除/更改歌曲的位置。
我该怎么做呢?下面是我的密码。
from discord.ext import commands
from dotenv import load_dotenv
from keep_alive import keep_alive
from youtube_dl import YoutubeDL
from discord.utils import get
load_dotenv()
TOKEN = os.