Answer the question
In order to leave comments, you need to log in
How to send messages via webhook to a Discord channel?
I have an application written in Visual Studio 2019
And I need to implement sending messages to a specific discord text channel for certain actions while the program is running, how to implement it?
Answer the question
In order to leave comments, you need to log in
A ready-made utility with a solution, code below, and a tutorial
Link to the utility
I've been digging around with the solution for quite some time, rummaged through the floor of Google, spent several hours
And finally I did it!
The author of the question, please mark the answer for the efforts :)
By the way, quite an interesting topic! I will not demolish the developments
And the first thing I want to say is that the program is written in Python , so we need an installed python, and the discord.py
library
Here is a brief tutorial for you:
from discord import Webhook, AsyncWebhookAdapter
import asyncio
import aiohttp
async def send () :
URL = input('Введите URL вашего вебхука: ')
Message = input('Введите ваше сообщение: ')
async with aiohttp.ClientSession() as session:
webhook = Webhook.from_url(URL, adapter=AsyncWebhookAdapter(session))
await webhook.send(Message)
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(send())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question