Discord.py tasks.loop不起作用,并且不返回任何错误

2024-04-18 23:09:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直试图在Discord.py中创建循环,但一直失败。更难的是它不会返回错误

这就是代码

import discord
import datetime
import time
import threading
import os
import json
import random
import asyncio
from discord.ext import commands
from discord.ext.commands import has_permissions
from discord.ext.tasks import loop
import keep_alive

prefix = "s."
token = str(os.getenv("TOKEN"))
client = commands.Bot(command_prefix = prefix)
client.remove_command("help")
os.chdir(r".")
ownerId = [219567539049594880]
logChn = 705181132672729098
secondsUp = 0

@loop(seconds=1)
async def add_second():
    secondsUp+=1
    print("+1 Second")

控制台不打印任何内容。没有错误。我有什么遗漏吗


Tags: 代码frompyimportclientloopprefixos