Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Discord.py | Publish messages

does someone know how to publish a message by a user? I have already tried a bit and asked on a discord coding server, but I didn't got a good answer.

I tried something like this:

@client.event
async def on_message(message):
    if message.channel.type == discord.ChannelType.news:
        await message.publish
        return
like image 996
bendix9009 Avatar asked Nov 29 '25 18:11

bendix9009


1 Answers

Today I had the same problem and I fixed it with:

@client.command()
async def sendMessage(ctx, message):
    msg = await ctx.send("Published message: " + message)
    await msg.publish()

So I think you forgot the brackets. So this code would work:

@client.event
async def on_message(message):
    if message.channel.type == discord.ChannelType.news:
        await message.publish()
        return