staticky-bot/cogs/cog_fun.py

37 lines
1.4 KiB
Python

import discord
import random
from discord import app_commands
from discord.app_commands import Choice
from discord.ext import commands
from classes.my_cog import MyCog
class Fun(MyCog):
def __init__(self, bot):
super().__init__(bot)
self.bot = bot
@app_commands.command(name="chuchoter")
async def chuchoter(self, interaction: discord.Interaction, channel: discord.TextChannel, message: str):
"""
Chuchote à Staticky un message qu'il partagera (attention ne lui faites pas aveuglément confiance)
:param interaction: discord interaction
:param channel: Salon dans lequel le message sera partagé
:param message: Message à partagerE
"""
try:
to_send = f"**Quelqu'un m'a chuchoter :** \"{message}\""
if random.randint(1, 6) == 1:
to_send += f"\nJe balance, c'est {interaction.user.mention} !"
await channel.send(to_send)
await interaction.response.send_message(f"Message envoyé dans {channel.mention}\n>>> {message}",
ephemeral=True)
except Exception as e:
await interaction.response.send_message(f"Le message n'a pas pu être envoyé...\n`Erreur : {e}`",
ephemeral=True)
async def setup(bot):
await bot.add_cog(Fun(bot))