-
Notifications
You must be signed in to change notification settings - Fork 1
/
modmail.py
50 lines (41 loc) · 1.75 KB
/
modmail.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import discord
from discord.ext import commands
'''
TODO:
function is exclusive to 1 server bc I dont want to build databases :)
format into sleeker looking embeds
guild = await bot.get_guild(ID)
'''
class ModmailCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@bot.event
async def on_message(message):
empty_array = []
modmail_channel = discord.utils.get(bot.get_all_channels(), name="modmail")
if message.author == bot.user:
return
if str(message.channel.type) == "private":
if message.attachments != empty_array:
files = message.attachments
await modmail_channel.send("[" + message.author.display_name + "]")
for file in files:
await modmail_channel.send(file.url)
else:
await modmail_channel.send("[" + message.author.display_name + "] " + message.content)
elif str(message.channel) == "modmail" and message.content.startswith("<"):
member_object = message.mentions[0]
if message.attachments != empty_array:
files = message.attachments
await member_object.send("[" + message.author.display_name + "]")
for file in files:
await member_object.send(file.url)
else:
index = message.content.index(" ")
string = message.content
mod_message = string[index:]
await member_object.send("[" + message.author.display_name + "]" + mod_message)
await bot.process_commands(message)
# Fixed no command process !!!! Keep this at end of on_message event function!!!!
def setup(bot):
bot.add_cog(ModmailCog(bot))