Skip to content
Snippets Groups Projects
support.py 850 B
Newer Older
  • Learn to ignore specific revisions
  • LMzK's avatar
    LMzK committed
    import io
    import os
    
    
    dnns01's avatar
    dnns01 committed
    import disnake
    from disnake.ext import commands
    
    LMzK's avatar
    LMzK committed
    
    
    class Support(commands.Cog):
        def __init__(self, bot):
            self.bot = bot
            self.channel_id = int(os.getenv("DISCORD_SUPPORT_CHANNEL"))
    
        @commands.Cog.listener()
        async def on_message(self, message):
            if message.author == self.bot.user:
                return
    
    
    dnns01's avatar
    dnns01 committed
            if type(message.channel) is disnake.DMChannel:
    
    LMzK's avatar
    LMzK committed
                channel = await self.bot.fetch_channel(self.channel_id)
                files = []
    
                for attachment in message.attachments:
                    fp = io.BytesIO()
                    await attachment.save(fp)
    
    dnns01's avatar
    dnns01 committed
                    files.append(disnake.File(fp, filename=attachment.filename))
    
    LMzK's avatar
    LMzK committed
    
                await channel.send(f"Support Nachricht von <@!{message.author.id}>:")
    
    dnns01's avatar
    dnns01 committed
                await channel.send(message.content, files=files)