簡體   English   中英

當我嘗試運行我的 discord 機器人時,它告訴我一個模塊錯誤

[英]when i try to run my discord bot it tells gives me a module error

    import discord 
from discord.ext import commands


client = commands.bot(command_prefix = '%')

@client.command(name='scp')
async def scp(context):
    mods_channel = client.get_channel(806352117442543616)
    
    scp = discord.embed(title="scp wiki", description="http://www.scpwiki.com/scp-series", color=0xCC0000)

    await context.message.channel.send(embed=scp)

@client.event
async def on_ready():
    #do stuff

    mods_channel = client.get_channel(806352117442543616)
    await mods_channel.send('i work! ')

@client.event
async def on_typing():
    mods_channel = client.get_channel(806352117442543616)
    await mods_channel.send('i wonder what you are going to say :thinking:')

@client.event
async def on_message(message):
    if message.content == 'hello Irantu' or message.content == 'hello irantu':
        mods_channel = client.get_channel(806352117442543616)
        await mods_channel.send('HI! :smile:')
#run client

每當我運行它時,它都會給我TypeError: 'module' object is not callable 這是一個 discord 機器人,我正在為一個以 scp 為主題的 discord 服務器制作這一切都是使用 Python 3.9.4 使用 Visual Studio Code 完成的。

您正在嘗試調用discord.ext.commands.bot ,這是一個模塊。 您可能正在尋找discord.ext.commands.Bot

from discord.ext import commands

client = commands.Bot(command_prefix="%")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM