简体   繁体   English

discord.py, RuntimeWarning: 启用 tracemalloc 以获取发送消息时的对象分配回溯

[英]discord.py, RuntimeWarning: Enable tracemalloc to get the object allocation traceback on sending message

Ok so I have a problem like this: I wrote a code that's meant to send message on discord server every(just for now, for testing) 10 seconds, and when I try to execute command on discord:好的,所以我遇到了这样的问题:我编写了一个代码,旨在每隔 10 秒(现在,用于测试)在不和谐服务器上发送消息,当我尝试在不和谐上执行命令时:

import os
import sched
import time

from discord.ext import commands
from dotenv import load_dotenv

import Library

load_dotenv()
TOKEN = os.getenv('discordToken')

bot = commands.Bot(command_prefix='Question')
lastEmbed = None
s = sched.scheduler(time.time, time.sleep)


async def do_something(sc):
    channel = bot.get_channel(416238248445214720)
    await channel.send("And what?")
    s.enter(10, 1, do_something, (sc,))


@bot.event
async def on_ready():
    print(f'{bot.user.name} has connected to Discord!')
    s.enter(10, 1, do_something, (s,))
    s.run()

Every time I get error like this:每次我收到这样的错误:

C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\sched.py:151: RuntimeWarning: coroutine 'do_something' was never awaited
  action(*argument, **kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Okay, thank you @FrozenAra and @derw for your help, although I found a tottaly different way of solving the problem I used discord.Client library and Tasks so now it looks like this:好的,谢谢@FrozenAra 和@derw 的帮助,虽然我找到了一种完全不同的方法来解决我使用 discord.Client 库和任务的问题,所以现在看起来像这样:

@tasks.loop(minutes=30)
async def reminder():
    channel = client.get_channel(692724253237313576)
    await channel.send("So what?")
    await channel.send(preembed)

And everything works just great.一切都很好。 Thanks for your help Guys :)感谢您的帮助伙计们:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 RuntimeWarning:启用tracemalloc以获取对象分配回溯 - RuntimeWarning: Enable tracemalloc to get the object allocation traceback RuntimeWarning:启用 tracemalloc 以使用 asyncio.sleep 获取对象分配回溯 - RuntimeWarning: Enable tracemalloc to get the object allocation traceback with asyncio.sleep 如何修复 RuntimeWarning:启用 tracemalloc 以获取 object 分配回溯错误 - How to fix RuntimeWarning: Enable tracemalloc to get the object allocation traceback error 使用tornado.httpclient.AsyncHTTPClient时,如何修复“RuntimeWarning:启用tracemalloc以获取对象分配回溯”? - How to fix “RuntimeWarning: Enable tracemalloc to get the object allocation traceback” when using tornado.httpclient.AsyncHTTPClient? 为什么我会收到 RuntimeWarning: Enable tracemalloc to get the object allocation traceback from asyncio.run? - Why am i getting RuntimeWarning: Enable tracemalloc to get the object allocation traceback from asyncio.run? “RuntimeWarning: Enable tracemalloc to get the object allocation traceback”是什么意思? 我知道如何修复,寻找意义 - What does "RuntimeWarning: Enable tracemalloc to get the object allocation traceback" mean? I know how to fix, looking for the meaning 启用 tracemalloc 以获取 object 分配回溯 PYTHON - Enable tracemalloc to get the object allocation traceback PYTHON Python Selenium - ResourceWarning:启用 tracemalloc 以获取对象分配回溯 - Python Selenium - ResourceWarning: Enable tracemalloc to get the object allocation traceback Discord.py 回溯 - Discord.py Traceback Discord.Py 没有在 Discord 中发送我的消息 - Discord.Py Not Sending My Message In Discord
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM