简体   繁体   中英

Enable tracemalloc to get the object allocation traceback PYTHON

I have simple music bot but it says this:"RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited bot.load_extension('dismusic') RuntimeWarning: Enable tracemalloc to get the object allocation traceback"

" RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited bot.load_extension('dch') RuntimeWarning: Enable tracemalloc to get the object allocation traceback "

Code:

import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='>', intents=intents)

bot.lava_nodes = [
    {
        'host': 'lava.link',
        'port': 80,
        'rest_uri': f'http://lava.link:80',
        'indetifier': 'MAIN',
        'password': 'anything',
        'region': 'singapore'
    }
]

@bot.event
async def on_ready():
    print('Bot is ready')
    bot.load_extension('dismusic')
    bot.load_extension('dch')
    
    
bot.run("OTg5OTI5Mjkxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");

You just need to replace bot.load_extension with await bot.load_extension - you haven't awaited a function. Otherwise, your code looks fine. (By the way, discord is moving away from text based commands, you might want to look into slash commands)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM