I'd like to send a message from a Discord bot whenever an API endpoint gets triggered.
It seems the only way to send messages is in response to discord events, for example using
#client.event
async def on_message(message):
I'd appreciate any pointers on how to send a discord bot message that's not triggered by an async Discord event (using discord.py preferably)
Thanks!
Related
I have subscribed to the channel in discord. sometimes I am missing messages in that discord, is there a code that sends that messages from a specific channels in discord to the phone via sms?
There is.
https://github.com/leogomezz4t/PyTextNow_API
PyTextNow enables you to send SMS from Python. To do this you would do something like:
import discord
import pytextnow
client = discord.Client()
text = pytextnow.Client("username", sid_cookie="sid", srf_cookie="csrf")
#client.event
async def on_message(message):
text.send_sms('number',message.content)
Be sure to read the pytextnow and Discord documentation.
POST https://discord.com/api/webhooks/{webhook.id}/{webhook.token}
I can successfully send messages to the discord channel with this method.
Get Webhook Message
GET/webhooks/{webhook.id}/{webhook.token}/messages/{message.id}
I want to get back the message I sent with this method. But how can I get the messages id automatically?
It suppose to send message upon join but Member_join event isn't working
By the way it's a self bot
Discord.py Version : 1.7.3
My code:
#client.event
async def on_member_join(member):
await member.send("welcome to random server")
print(f"Sent message to {member.username}")
So if you use discord.py-self then your current code will work. it in newer version as in newer version of discord.py they have blocked the access to api thru non bot auth token.
I am using discord.js
The scenario is something like this:
User posts something in one of the channel.
Bot replies to this user in a DM with
msg.author.send("I am the bot, and sending you this message as DM")
now, I want user to reply back to this bot in the DM again and i want bot and this user to communicate in the DM.
It seems like I can't achieve the user to send back the message to bot in the same DM.
I am using discord.js
Any idea ?
to dm a person, you must use message.author.send("Your message here.")
but you must have client code.
I would like to know if it's possible to forward a message received to a one webhook to another webhook
Does Discord messaging API supports this?