From 0c97052b67f03411f3f2b40c77548bf35a922cdf Mon Sep 17 00:00:00 2001 From: sgoudham Date: Thu, 2 Jul 2020 04:47:59 +0100 Subject: [PATCH] Getting rid of echo dms feature for now --- main.py | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/main.py b/main.py index 761a045c..fd3eb76f 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,10 @@ import asyncio import datetime +import random import discord from decouple import config -from discord import Embed, Colour +from discord import Embed, Colour, DMChannel from discord.ext import commands from discord.ext.commands import is_owner @@ -86,20 +87,29 @@ async def on_message(message): if message.author == client.user: return - # Setting the id of myself - author = message.author.id + # Get the mod-mail channel + channel = client.get_channel(728083016290926623) - # Checking if the message is not sent in server - if message.guild is None: - # Checking if the owner is sending the message - if author == client.owner_id: - - # Send message to #general - channel = client.get_channel(663651584399507481) - await channel.send(message.content) + if isinstance(message.channel, DMChannel): + if len(message.content) < 50: + await message.channel.send("Your message should be at least 50 characters in length.") else: - return + # member = discord.guild.get_member(message.author.id) + embed = Embed(title="**Modmail**", + colour=Colour(random.choice(settings.colour_list)), + timestamp=datetime.datetime.utcnow()) + + embed.set_thumbnail(url=message.author.avatar_url) + + fields = [("Member", message.author.name, False), + ("Message", message.content, False)] + + for name, value, inline in fields: + embed.add_field(name=name, value=value, inline=inline) + + await channel.send(embed=embed) + await message.channel.send("**Message relayed to Staff! Thank you for your input!**") await client.process_commands(message)