Skip to content
Snippets Groups Projects
Commit 21c9d039 authored by dnns01's avatar dnns01
Browse files

fix: $121 - add support functionality that mirrors all private messages sent...

fix: $121 - add support functionality that mirrors all private messages sent to the bot to a specified support channel, to be reviewd by a mod.
parent fff61a8c
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@ from appointments_cog import AppointmentsCog
from christmas_cog import ChristmasCog
from poll_cog import PollCog
from roles_cog import RolesCog
from support_cog import SupportCog
from text_commands_cog import TextCommandsCog
from tops_cog import TopsCog
from welcome_cog import WelcomeCog
......@@ -43,6 +44,7 @@ bot.add_cog(tops_cog)
bot.add_cog(roles_cog)
bot.add_cog(welcome_cog)
bot.add_cog(christmas_cog)
bot.add_cog(SupportCog(bot))
# bot.add_cog(welcome_cog)
......
import io
import os
import discord
from discord.ext import commands
class SupportCog(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 type(message.channel) is discord.DMChannel:
channel = await self.bot.fetch_channel(self.channel_id)
files = []
for attachment in message.attachments:
fp = io.BytesIO()
await attachment.save(fp)
files.append(discord.File(fp, filename=attachment.filename))
await channel.send(f"Support Nachricht von <@!{message.author.id}>:")
await channel.send(message.content, files=files)
......@@ -51,4 +51,3 @@ class WelcomeCog(commands.Cog):
f"Wir würden uns sehr freuen, wenn du dich in <#{os.getenv('DISCORD_VORSTELLUNGSCHANNEL')}> allen kurz vorstellen würdest. Es gibt nicht viele Regeln zu beachten, doch die Regeln, die aufgestellt sind, findest du hier: https://discordapp.com/channels/353315134678106113/697729059173433344/709475694157234198 .\n"
f"Dir dürfte außerdem schon aufgefallen sein, dass du derzeit nur drei Channels siehst. Wir haben natürlich mehr als diese drei. Um die restlichen Channels angezeigt zu bekommen, müsstest du dir lediglich eine Studiengangs-Rolle im Channel <#{os.getenv('DISCORD_ROLLEN_CHANNEL')}> zuweisen. Wir würden uns natürlich am meisten darüber freuen, wenn du dir die Rolle, die zu deinem Studiengang passt zuweisen würdest, falls du das aber nicht möchtest, ist mindestens die Rolle Studentin notwendig.\n\n"
f"Abschließend bleibt mir nur noch, dir hier viel Spaß zu wünschen, und falls du bei etwas hilfe brauchen solltest, schreib mir doch eine private Nachricht, das Moderatoren Team wird sich dann darum kümmern.")
print(member)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment