Bot activity

This commit is contained in:
Guams 2025-03-07 23:50:16 +01:00
parent 6573710066
commit 0900d8ed68

47
main.py
View File

@ -18,6 +18,32 @@ API_URL: str = "https://discord.com/api/v10"
TOKEN: str = CONFIG["TOKEN"]
async def create_button():
body: dict = {
"content": "This is a message with components",
"components": [
{
"type": 1,
"components": [
{
"type": 2,
"label": "Click me!",
"style": 1,
"custom_id": "click_one"
}
]
}
]
}
res = requests.post(f"{API_URL}/channels/840107060901052426/messages", json=body,
headers={"Authorization": f"Bot {TOKEN}"})
if res.status_code != 201:
print(res.json())
async def create_command():
body: dict = {
"name": "poll",
@ -87,7 +113,6 @@ async def create_poll(interaction_id: int, interaction_token: str, components: l
print(res)
async def identify(websocket):
payload: dict = {
"op": OpCode.IDENTIFY,
@ -98,6 +123,15 @@ async def identify(websocket):
"browser": "gambling",
"device": "gambling"
},
"presence": {
"activities": [{
"name": "son argent flamber",
"type": 3,
}],
"status": "dnd",
"since": 91879201,
"afk": False
},
"intents": 50364416,
}
}
@ -204,11 +238,14 @@ async def get_event(response: Any):
case EventTitle.MESSAGE_CREATE:
print(f'{response["d"]["author"]["username"]}: {response["d"]["content"]}')
case EventTitle.INTERACTION_CREATE:
print(response["d"]["data"].keys())
if "custom_id" in response["d"]["data"].keys():
if response["d"]["data"]["custom_id"] == "poll_id_create":
await create_poll(int(response["d"]["id"]), response["d"]["token"], response["d"]["data"]["components"])
await create_poll(
int(response["d"]["id"]),
response["d"]["token"],
response["d"]["data"]["components"]
)
print(response)
await create_poll_form(int(response["d"]["id"]), response["d"]["token"])
case _:
print(response)
@ -235,7 +272,7 @@ async def connect():
async def main():
gateway_connect = asyncio.create_task(connect())
# await init_commands()
# await create_poll(840107060901052426, "f", [])
# await create_button()
await gateway_connect