Hey guys im making a discord bot with discord.py rewrite and i have a command when mention the bot it will send you the prefix
i dont want the bot to send the prefix when there's others text in the message
This is the code:
import discord
from discord.ext import commands
class Support(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_message(self, message):
if self.client.user.mentioned_in(message):
mention = discord.Embed(
title = "The prefix is `,help`",
colour = 0xeeffee
)
await message.channel.send(embed = mention)
def setup(client):
client.add_cog(Support(client))
Here are two ideas how it could work :)
import discord
from discord.ext import commands
class Support(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_message(self, message):
if self.client.user.mentioned_in(message):
checkMessage = message.content.split("@")
if checkMessage[0] == "@":
mention = discord.Embed(
title = "The prefix is `,help`",
colour = 0xeeffee
)
await message.channel.send(embed = mention)
def setup(client):
client.add_cog(Support(client))
import discord
from discord.ext import commands
class Support(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_message(self, message):
if self.client.user.mentioned_in(message):
if message.content.startswith("@"):
mention = discord.Embed(
title = "The prefix is `,help`",
colour = 0xeeffee
)
await message.channel.send(embed = mention)
def setup(client):
client.add_cog(Support(client))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.