My problem is similar to this, but it's not into a class.
My code is this (after removing some ininfluent lines):
@Bot.command()
async def Limonate(ctx, secondi, menzione = Nonemenzione=None):
global attesa
global canale
attesa = float(secondi)
canale = ctx.channel
This is a command, and I need that part to do this:
@Bot.event
async def on_ready():
print(Bot.user, " è ora online ", "ID: ", Bot.user.id)
attesa = 100
global canale #The problem is there
while (True):
frase = choice(frasi_ad_effetto)
await sleep(attesa)
global canale # Here's the problem
global menzione
await canale.send(menzione + ', ' + frase) #
So, the problem is that, if the function is alreadyBot has just started, the global keywork doesn't work, because when (and the bot is readycommand Limonate was never executed), the canale variable "canale" is empty.
Do you know any way to solve my problem?
If there's not a way to do that, I'll avoid it just using the ID of a random-choiced channel.