![](/img/trans.png)
[英]RuntimeWarning: Enable tracemalloc to get the object allocation traceback
[英]discord.py, RuntimeWarning: Enable tracemalloc to get the object allocation traceback on sending message
好的,所以我遇到了这样的问题:我编写了一个代码,旨在每隔 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()
每次我收到这样的错误:
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
好的,谢谢@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)
一切都很好。 感谢您的帮助伙计们:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.