S
S
Satare2021-01-10 18:01:48
Bots
Satare, 2021-01-10 18:01:48

How to make the bot accept a message from the user and send it on its own behalf?

Hello, how can I make the bot receive messages in the discord chat and immediately delete and send on my behalf.
The user will write briefly in the chat, but the bot will delete this message and send it on its own behalf, so that the chat participants do not see who wrote this message.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
Zagir Majidov, 2021-01-10
@Satare

The bot accepts the command say!
Usage: [prefix]say [message]
CODE:

@client.command()
@commands.has_permissions(view_audit_log = True) #права команды: Просматривать аудит логи
async def say(ctx, *, arg = None):
    emb = discord.Embed(description = f'{arg}', color = 0x0944d9) #цвет синий

    await ctx.send(embed = emb) #отправка сообщения

@say.error #если у участника нету прав просматривать аудит лог то пишем ему то что у вас не достаточно прав!
async def say_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        emb = discord.Embed(titile = f'Ошибка', description = f'**У вас недостаточно прав!**', color = RED)
        emb.set_footer(text = f'{client.user.name} © 2020 | Все права защищены', icon_url = client.user.avatar_url)
        await ctx.send(embed = emb, delete_after = 15)

P
Pdnky, 2021-01-11
@Pdnky

@bot.command(pass_context=True)  # разрешаем передавать агрументы
async def повтор(ctx, arg):  # создаем асинхронную фунцию бота
    await ctx.send(arg)  # отправляем обратно аргумент
    await ctx.message.delete() # удаление сообщения

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question