bendix9009
bendix9009

Reputation: 31

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

Upvotes: 2

Views: 1963

Answers (2)

user17090454
user17090454

Reputation:

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

Upvotes: 1

Gunner
Gunner

Reputation: 19

I don't yet have the reputation to reply to Phoenix Doom directly. However I think bendix9009 is likely referring to the 'Publish' option that you get when typing messages into 'Announcement' text channels.

When you or a bot send a message into these channels, they are not published to any other channels that are following them by default.

It'd be useful to know whether you can just add some sort of flag onto the below line to publish those messages automatically.

client.channels.cache.get(channelId).send; (Mine's written in javascript)

Upvotes: 1

Related Questions