Implement webhook support for message replies and enhance reaction handling
This commit is contained in:
parent
5c7a6f8ab0
commit
93077e7d49
1 changed files with 31 additions and 2 deletions
|
@ -60,9 +60,18 @@ async def reply(message):
|
||||||
f"{random.choice(word_list)}",
|
f"{random.choice(word_list)}",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
fct = random.choice((message.reply, message.channel.send))
|
|
||||||
|
|
||||||
await fct(content)
|
if random.random() < 0.1:
|
||||||
|
await send_as_webhook(
|
||||||
|
message.channel,
|
||||||
|
message.author.display_name,
|
||||||
|
message.author.avatar.url,
|
||||||
|
content,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
fct = random.choice((message.reply, message.channel.send))
|
||||||
|
|
||||||
|
await fct(content)
|
||||||
|
|
||||||
|
|
||||||
async def ai_reply(message):
|
async def ai_reply(message):
|
||||||
|
@ -82,6 +91,8 @@ async def ai_reply(message):
|
||||||
|
|
||||||
|
|
||||||
async def react(message: discord.Message) -> None:
|
async def react(message: discord.Message) -> None:
|
||||||
|
if message.guild is None:
|
||||||
|
return
|
||||||
await message.add_reaction(random.choice(message.guild.emojis))
|
await message.add_reaction(random.choice(message.guild.emojis))
|
||||||
|
|
||||||
|
|
||||||
|
@ -301,4 +312,22 @@ async def chan(ctx, file: discord.Attachment):
|
||||||
logger.info("FIN CHAN")
|
logger.info("FIN CHAN")
|
||||||
|
|
||||||
|
|
||||||
|
async def send_as_webhook(
|
||||||
|
channel: discord.TextChannel,
|
||||||
|
name: str,
|
||||||
|
avatar_url: str,
|
||||||
|
content: str,
|
||||||
|
embed: discord.Embed = None,
|
||||||
|
):
|
||||||
|
webhooks = await channel.webhooks()
|
||||||
|
webhook = discord.utils.get(webhooks, name="BotbotbotHook")
|
||||||
|
|
||||||
|
if webhook is None:
|
||||||
|
webhook = await channel.create_webhook(name="BotbotbotHook")
|
||||||
|
|
||||||
|
await webhook.send(
|
||||||
|
content=content, username=name, avatar_url=avatar_url, embed=embed
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
bot.run(config.get("token"))
|
bot.run(config.get("token"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue