忽略命令中的异常无:discord.ext.commands.errors.CommandNotFound:找不到命令“ send_dm”

时间:2020-06-08 19:52:19

标签: python discord discord.py-rewrite

我正在Atom中使用 discord.py 进行编码。我收到错误

忽略命令None中的异常:
discord.ext.commands.errors.CommandNotFound:找不到命令“ send_dm”

,但命令仍在运行。

我想知道出什么问题了,因为它可能会解决我遇到的其他问题,例如答复重复出现问题。 send_dm与我运行的命令互换。

这是我的代码:

import discord
import os
import random
from discord.ext import commands, tasks
from itertools import cycle

client = commands.Bot(command_prefix = ',')
status = cycle(['Status 1', 'Status 2'])
@client.event
async def on_ready():
    print('Bot is connected to discord!')
    game = discord.Game("BlueBot ALPHA")
    await client.change_presence(status=discord.Status.idle, activity=game)

@client.event
async def on_member_join(member):
    print(f'{member} has joined a server')

@client.event
async def on_member_remove(member):
    print(f'{member} has left a server')

@client.command()
async def ping(ctx):
    await ctx.send(f'Pong! {client.latency}ms')

@client.command(alieses= '8ball')
async def _8ball(ctx, *, question):
    responses = ["It is certain.",
                "It is decidedly so.",
                "Without a doubt.",
                "Yes - definitely.",
                "You may rely on it.",
                "As I see it, yes.",
                "Most likely.",
                "Outlook good.",
                "Yes.",
                "Signs point to yes.",
                "Reply hazy, try again.",
                "Ask again later.",
                "Better not tell you now.",
                "Cannot predict now.",
                "Concentrate and ask again.",
                "Don't count on it.",
                "My reply is no.",
                "My sources say no.",
                "Outlook not so good.",
                "Very doubtful."]

    await ctx.send(f'Question: {question}\nAnswer: {random.choice(responses)}')


@client.command()
async def clear(ctx, amount=1 + 1):
    if ctx.author.guild_permissions.administrator:
        await ctx.channel.purge(limit=amount)

@client.command()
async def kick(ctx, member : discord.Member, *, reason=None):
    if ctx.author.guild_permissions.kick_members:
        await member.kick(reason=reason)


def ban_bypass(ctx):
    return ctx.author.id == 279030251995136000


@client.command()
@commands.check(ban_bypass)
async def ban(ctx, member : discord.Member, *, reason=None):
    if ctx.author.guild_permissions.ban_members:
        await member.ban(reason=reason)
        await ctx.send (f'Banned {member.mention}')


@client.command()
async def unban(ctx, *, member):
    if ctx.author.guild_permissions.ban_members:
        banned_users = await cx.guild.bans()
        member_name , member_discriminator = member.split('#')

        for ban_entry in banned_users:
            user = ban_entry.banned_users

            if(user.name , user.discriminator) -- (member_name, member_discriminator):
                await ctx.guild.unban(user)
                await ctx.send(f'Unbanned {member.mention}')
                return

@client.command()
async def send_dm(ctx, member: discord.Member, *, content):
    channel = await member.create_dm()
    await channel.send(content)

@client.command(pass_context = True)
async def say(ctx, *args):
    mesg = ' '.join(args)
    await client.delete_message(ctx.message)
    return await client.say(mesg)
client.run('Bot token')

0 个答案:

没有答案