#Send message to specific guild-channel from extension task?
1 messages · Page 1 of 1 (latest)
Get the channel from the guild and send it there
you do probably want to use get/fetch_channel
(depending on how your cache is set up, either one could work)
if it errors out... that probably suggest other things are going wrong
@ornate ember
-
You will need some way of storing data outside of the loop like you say. I'd recommend some sort of disk storage (like a database, or even JSON depending on your scalability needs). If you store the data in memory only (like a Python dictionary), you won't know whether you've posted a message once the bot restarts. This is unrelated to the library though, and is just general Python.
-
Your method for having a repeating task works, but I don't see why you'd do that over ipy's tasks implementation. I may be mistaken, though I think ipy's tasks do have proper error handling, scheduling and are more flexible.
SQLite would be a good shout :)
sqlite is great for small bots, yeah
postgres is always a good option, and mysql... certainly is an option too (i have my opinions)
regardless, once you know one, you know the others decently well
I'm not sure why your code isn't reaching your ctx.send part, but you should make sure you close the db connection.
aiosqlite recommends using a context manager async with... or you should use a try, finally to make sure the connection closes.
Regarding your issue: You're executing using a cursor object. I'm not 100% sure whether that would work. Aiosqlite's documentation uses the db connection to execute, and then the cursor to fetch data.
Yeah sorry for the confusion with the message edit. I don't think there is a problem with where your db.commit is.
That error message is saying.. well, exactly what it says. That database is locked and cannot be edited. This is probably because you never closed the connection.
If you look at your ctx.send and the guild_channel, you'll notice you're trying to send an object. In the docs, the channel object has a .mention, so guild_channel.mention should be your fix 😄