Reputation: 43
I've been trying to make loops in Discord.py, but I keep failing. What makes it harder is that it returns no errors.
This is the code;
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")
The console does not print anything. No errors. Is there anything I'm missing?
Upvotes: 0
Views: 1119
Reputation: 394
In discord.py, you must call the .start()
method on every loop that you create. In this case, add_seconds.start()
. Also, try adding global secondsUp
to the top of your function definition.
Upvotes: 1