#webhook delete_after doesn't work

1 messages · Page 1 of 1 (latest)

worn pivot
#

this gives me this error: RuntimeWarning: coroutine 'Webhook.send.<locals>.delete' was never awaited

#

delete_after also shows up as Unexpected argument

worn pivot
#

even if delete_after would work it's not quite what i'm looking for

scenic bolt
#

chat history, stored in database, stored in some variable? or what else

worn pivot
#

so i would need to get the id from sending the msg over the webhook and store it in a json file

scenic bolt
#

?nojson

#

?tag nojson

trim streamBOT
#

Why not to use json files for data storage
JSON files are commonly used to store data that is read by a program, however, they are unsuitable for storing dynamic data due to a number of reasons.
It is recommended to use a DBMS (Database Management System) as they come with optimized technologies for storing and retrieving information.

Advantages of using a database:
- Database tables can be related, making it easy to separate your information into multiple tables and only fetch what you need
- Databases allow you to use a query/data processing language to make complex data operations easier with less code
- One misplaced character will corrupt an entire file. A database very rarely experiences corruptions due to their automatic handling of data integrity
- Transactions in SQL databases allow you to revert unwanted changes and prevent data corruption in the case of an error
- Databases have support for indexes, allowing retrieval of some data to be extremely fast
- It is very easy to update existing data in a database, as opposed to re-writing a file
- Databases are reliable

Popular database management systems:

  • SQLite3 (File based, no need for a server setup, SQLite is the most used database engine in the world)
  • MongoDB (Stores data in documents a similar manner to JSON format, easy for beginners)
  • PostgreSQL (Very popular and robust SQL based database management system)
  • MySQL (Another popular SQL based system, good start for learning SQL)
scenic bolt
#

rather go with sqlite

worn pivot
#

after for ex. i have 50 ids in it i start to delete the oldest ones

#

so i just need to figure out how to get the id

#

you know how i get the id from sending the msg?

scenic bolt
#

thats it

worn pivot
#

from a webhook?

scenic bolt
#

yeah

marble stormBOT
worn pivot
#
class WebhookInfo:
    def __init__(self, **kwargs):
        self.img_url = kwargs.get('img_url')
        self.webhook_url = kwargs.get('webhook_url')


    async def send_info(self, **kwargs):
        info = kwargs.get('info')
        description = kwargs.get('description')
        async with aiohttp.ClientSession() as session:
            webhook = Webhook.from_url(url=self.webhook_url, session=session)
            await webhook.send(content=description, username=info, avatar_url=self.img_url)
scenic bolt
#

webhook.send returns you an object of class WebhookMessage

#

that object will have an attribute called id

worn pivot
#

so i just print out the webhook?

scenic bolt
#

no?

worn pivot
#

quite new to python/coding sry

scenic bolt
#

wh_msg = await webhook.send(...)
wh_msg.id <- this has the id

#

its a good idea to learn some python concepts before stating a discord bot

#

discord bots are not a good first project

worn pivot
#

i mean i code for about a year now but this made me crazy

#

little embarrassing

scenic bolt
#

store wh_msg.id in a db

worn pivot
#

i would have a postgres db for that but nah

#

thanks for the help

scenic bolt
#

no worries

marble stormBOT
#

Done with your help thread?

Please close your own help thread by using </close:1009144375709814897> with @old rapids.