mirror of
https://github.com/kurbezz/discord-bot.git
synced 2025-12-06 15:15:37 +01:00
Update
This commit is contained in:
@@ -119,11 +119,13 @@ async def create_discord_event(event: CreateDiscordEvent):
|
|||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
response = await client.post(
|
response = await client.post(
|
||||||
f"https://discord.com/api/v10/guilds/{config.DISCORD_GUILD_ID}/scheduled-events",
|
f"https://discord.com/api/v10/guilds/{config.DISCORD_GUILD_ID}/scheduled-events",
|
||||||
data=event.model_dump_json(),
|
data=event.model_dump(),
|
||||||
headers={"Authorization": f"Bot {config.DISCORD_BOT_TOKEN}"}
|
headers={"Authorization": f"Bot {config.DISCORD_BOT_TOKEN}"}
|
||||||
)
|
)
|
||||||
|
|
||||||
response.raise_for_status()
|
if response.status_code == 400:
|
||||||
|
raise ValueError(response.json())
|
||||||
|
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
|
|
||||||
@@ -143,9 +145,11 @@ async def edit_discord_event(event_id: str, event: UpdateDiscordEvent):
|
|||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
response = await client.patch(
|
response = await client.patch(
|
||||||
f"https://discord.com/api/v10/guilds/{config.DISCORD_GUILD_ID}/scheduled-events/{event_id}",
|
f"https://discord.com/api/v10/guilds/{config.DISCORD_GUILD_ID}/scheduled-events/{event_id}",
|
||||||
data=event.model_dump_json(),
|
data=event.model_dump(),
|
||||||
headers={"Authorization": f"Bot {config.DISCORD_BOT_TOKEN}"}
|
headers={"Authorization": f"Bot {config.DISCORD_BOT_TOKEN}"}
|
||||||
)
|
)
|
||||||
|
|
||||||
response.raise_for_status()
|
if response.status_code == 400:
|
||||||
|
raise ValueError(response.json())
|
||||||
|
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|||||||
Reference in New Issue
Block a user