#webhook delete_after doesn't work
1 messages · Page 1 of 1 (latest)
show full traceback and code
I'm on another way to delete msgs but now i don't know how to get the webhook msg id
even if delete_after would work it's not quite what i'm looking for
how do you plan to get the message?
chat history, stored in database, stored in some variable? or what else
so i would need to get the id from sending the msg over the webhook and store it in a json file
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)
rather go with sqlite
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?
from a webhook?
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)
webhook.send returns you an object of class WebhookMessage
that object will have an attribute called id
so i just print out the webhook?
no?
quite new to python/coding sry
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
this was the simplest anyone could tell lol
store wh_msg.id in a db
nah not for this
i would have a postgres db for that but nah
thanks for the help
no worries
Done with your help thread?
Please close your own help thread by using </close:1009144375709814897> with @old rapids.