Disord Bot离开服务器

时间:2020-11-06 00:55:49

标签: python discord discord.py

当您运行命令离开时,我试图使我的机器人离开服务器。刚开始,我试图让我的机器人自行启动,但是那没有用,所以我在这里找到了Client.leave_server命令,因此我尝试使用它,但是它总是出现与Bot没有属性leaves_server相同的错误。有人知道正确的命令吗?

我的代码:

import discord
from discord.ext import commands
from discord import Member, client
from discord.ext.commands import bot, has_permissions
from discord.ext import tasks
import asyncio

Client = commands.Bot(command_prefix = "+")

Client.event
async def on_ready():
    print("Bot is ready")

@Client.command()
@commands.is_owner()
async def leave(ctx):
    role = "Nuggie"
    await ctx.send("Leaving the server!")
    await asyncio.sleep(0.5)
    await Client.leave_server()

Client.run("My_Token")

错误:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'leave_server'

0 个答案:

没有答案