TextChannel.send with custom username & avatar? #9202
-
Heyo, I can't find in the API Reference information about setting custom username & avatar for a message. Is there any way to do it? |
Beta Was this translation helpful? Give feedback.
Answered by
GamePlayer-8
Jan 24, 2023
Replies: 2 comments 4 replies
-
That feature is only available for Webhooks so it'd be for |
Beta Was this translation helpful? Give feedback.
0 replies
-
So using import aiohttp
import discord
from discord import Webhook
intents = discord.Intents.all()
intents.members = True
bot = commands.Bot(command_prefix=PREFIX, intents=intents)
@bot.event
async def on_message(message):
if message.author == bot.user:
return
async with aiohttp.ClientSession() as session:
webhook = Webhook.from_url('webhook_url', session=session)
await webhook.send(content=message.content, username=message.author.name, avatar_url=message.author.avatar.url) is the solution. |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
Rapptz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So using
discord.py
+requests
libraries & a script:is the solution.