|
|
@ -47,7 +47,7 @@ def SendInstructions(author):
|
|
|
|
SendModMailEmbed.set_thumbnail(url=author.avatar_url)
|
|
|
|
SendModMailEmbed.set_thumbnail(url=author.avatar_url)
|
|
|
|
SendModMailEmbed.set_footer(text=f"Sent by {author}")
|
|
|
|
SendModMailEmbed.set_footer(text=f"Sent by {author}")
|
|
|
|
|
|
|
|
|
|
|
|
fields = [("**Make sure that the message is above 50 characters!**",
|
|
|
|
fields = [("**Make sure that the message is above **50** and below **1024** characters!**",
|
|
|
|
"**Include as much detail as possible :P**",
|
|
|
|
"**Include as much detail as possible :P**",
|
|
|
|
False)]
|
|
|
|
False)]
|
|
|
|
|
|
|
|
|
|
|
@ -60,14 +60,15 @@ def SendInstructions(author):
|
|
|
|
# Method to let the user know that the message must be above 50 characters
|
|
|
|
# Method to let the user know that the message must be above 50 characters
|
|
|
|
def ErrorHandling(author):
|
|
|
|
def ErrorHandling(author):
|
|
|
|
# Set up embed to let the user know that the message must be above 50 characters
|
|
|
|
# Set up embed to let the user know that the message must be above 50 characters
|
|
|
|
ErrorHandlingEmbed = Embed(title="**Uh Oh! Please make sure the message is above 50 characters!**",
|
|
|
|
ErrorHandlingEmbed = Embed(
|
|
|
|
colour=enso_embedmod_colours,
|
|
|
|
title="Uh Oh! Please make sure the message is above **50** and below **1024** characters!",
|
|
|
|
timestamp=datetime.datetime.utcnow())
|
|
|
|
colour=enso_embedmod_colours,
|
|
|
|
|
|
|
|
timestamp=datetime.datetime.utcnow())
|
|
|
|
|
|
|
|
|
|
|
|
ErrorHandlingEmbed.set_thumbnail(url=author.avatar_url)
|
|
|
|
ErrorHandlingEmbed.set_thumbnail(url=author.avatar_url)
|
|
|
|
ErrorHandlingEmbed.set_footer(text=f"Sent by {author}")
|
|
|
|
ErrorHandlingEmbed.set_footer(text=f"Sent by {author}")
|
|
|
|
|
|
|
|
|
|
|
|
fields = [("Please enter in a message which is above 50 characters!",
|
|
|
|
fields = [("Please enter in a message which is above **50** and below **1024** characters!",
|
|
|
|
"**This helps us reduce spam and allows you to include more detail in your mail!**",
|
|
|
|
"**This helps us reduce spam and allows you to include more detail in your mail!**",
|
|
|
|
False)]
|
|
|
|
False)]
|
|
|
|
|
|
|
|
|
|
|
@ -214,137 +215,156 @@ class Modmail(commands.Cog):
|
|
|
|
mention = await user_channel.send(member.mention)
|
|
|
|
mention = await user_channel.send(member.mention)
|
|
|
|
await mention.delete()
|
|
|
|
await mention.delete()
|
|
|
|
|
|
|
|
|
|
|
|
# Send the embed if they want to remain anonymous or not
|
|
|
|
try:
|
|
|
|
Anon_or_Not = await user_channel.send(embed=AnonOrNot(member))
|
|
|
|
|
|
|
|
# Add reactions to the message
|
|
|
|
|
|
|
|
await Anon_or_Not.add_reaction('✅')
|
|
|
|
|
|
|
|
await Anon_or_Not.add_reaction('❌')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Checking if the user reacted with ✅ with response to sending staff a message
|
|
|
|
# Send the embed if they want to remain anonymous or not
|
|
|
|
def emoji_check(reaction, user):
|
|
|
|
Anon_or_Not = await user_channel.send(embed=AnonOrNot(member))
|
|
|
|
return user == member and str(reaction.emoji) in ['✅', '❌']
|
|
|
|
# Add reactions to the message
|
|
|
|
|
|
|
|
await Anon_or_Not.add_reaction('✅')
|
|
|
|
|
|
|
|
await Anon_or_Not.add_reaction('❌')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Checking if the user reacted with ✅ with response to sending staff a message
|
|
|
|
|
|
|
|
def emoji_check(reaction, user):
|
|
|
|
|
|
|
|
return user == member and str(reaction.emoji) in ['✅', '❌']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Surround with try/except to catch any exceptions that may occur
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
# Wait for the user to add a reaction
|
|
|
|
|
|
|
|
reaction, user = await self.bot.wait_for('reaction_add', check=emoji_check)
|
|
|
|
|
|
|
|
except Exception as ex:
|
|
|
|
|
|
|
|
print(ex)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
if str(reaction.emoji) == "✅":
|
|
|
|
|
|
|
|
self.anon = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Delete the old embed
|
|
|
|
|
|
|
|
await Anon_or_Not.delete()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Tell the user to type their mail into the chat
|
|
|
|
|
|
|
|
instructions = await user_channel.send(embed=SendInstructions(member))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Making sure that the reply is from the author
|
|
|
|
|
|
|
|
def check(m):
|
|
|
|
|
|
|
|
return m.author == payload.member and user_channel.id == instructions.channel.id
|
|
|
|
|
|
|
|
|
|
|
|
# Surround with try/except to catch any exceptions that may occur
|
|
|
|
# Wait for the message from the author
|
|
|
|
try:
|
|
|
|
msg = await self.bot.wait_for('message', check=check)
|
|
|
|
# Wait for the user to add a reaction
|
|
|
|
|
|
|
|
reaction, user = await self.bot.wait_for('reaction_add', check=emoji_check)
|
|
|
|
|
|
|
|
except Exception as ex:
|
|
|
|
|
|
|
|
print(ex)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
if str(reaction.emoji) == "✅":
|
|
|
|
|
|
|
|
self.anon = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Delete the old embed
|
|
|
|
# Making sure that the message is below 50 characters and the message was sent in the channel
|
|
|
|
await Anon_or_Not.delete()
|
|
|
|
while len(msg.content) < 50 and msg.channel == user_channel:
|
|
|
|
|
|
|
|
await user_channel.send(embed=ErrorHandling(member))
|
|
|
|
|
|
|
|
|
|
|
|
# Tell the user to type their mail into the chat
|
|
|
|
# Wait for the message from the author
|
|
|
|
instructions = await user_channel.send(embed=SendInstructions(member))
|
|
|
|
msg = await self.bot.wait_for('message', check=check)
|
|
|
|
|
|
|
|
|
|
|
|
# Making sure that the reply is from the author
|
|
|
|
if len(msg.content) > 50 and msg.channel == user_channel:
|
|
|
|
def check(m):
|
|
|
|
# Delete the previous embed
|
|
|
|
return m.author == payload.member and user_channel.id == instructions.channel.id
|
|
|
|
await instructions.delete()
|
|
|
|
|
|
|
|
|
|
|
|
# Wait for the message from the author
|
|
|
|
# Determine a path for the message logs to be stored
|
|
|
|
msg = await self.bot.wait_for('message', check=check)
|
|
|
|
path = "cogs/modmail/{}.txt".format(payload.member.name)
|
|
|
|
|
|
|
|
with open(path, 'a+') as f:
|
|
|
|
|
|
|
|
# Store the date and content of every message in the text file
|
|
|
|
|
|
|
|
async for message in user_channel.history(limit=300):
|
|
|
|
|
|
|
|
print(f"{message.created_at} : {message.content}", file=f)
|
|
|
|
|
|
|
|
|
|
|
|
# Making sure that the message is below 50 characters and the message was sent in the channel
|
|
|
|
# Send the message to the modmail channel
|
|
|
|
while len(msg.content) < 50 and msg.channel == user_channel:
|
|
|
|
await modmail_channel.send(embed=SendMsgToModMail(self, msg, member),
|
|
|
|
await user_channel.send(embed=ErrorHandling(member))
|
|
|
|
file=File(fp=path))
|
|
|
|
|
|
|
|
|
|
|
|
# Wait for the message from the author
|
|
|
|
# Removing file from the directory after it has been sent
|
|
|
|
msg = await self.bot.wait_for('message', check=check)
|
|
|
|
if os.path.exists(path):
|
|
|
|
|
|
|
|
os.remove(path)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
print("The file does not exist")
|
|
|
|
|
|
|
|
|
|
|
|
if len(msg.content) > 50 and msg.channel == user_channel:
|
|
|
|
# Make sure the user knows that their message has been sent
|
|
|
|
# Delete the previous embed
|
|
|
|
await user_channel.send(embed=MessageSentConfirmation(member))
|
|
|
|
await instructions.delete()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Determine a path for the message logs to be stored
|
|
|
|
# Let the user read the message for 5 seconds
|
|
|
|
path = "cogs/modmail/{}.txt".format(payload.member.name)
|
|
|
|
await asyncio.sleep(5)
|
|
|
|
with open(path, 'a+') as f:
|
|
|
|
|
|
|
|
# Store the date and content of every message in the text file
|
|
|
|
|
|
|
|
async for message in user_channel.history(limit=300):
|
|
|
|
|
|
|
|
print(f"{message.created_at} : {message.content}", file=f)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Send the message to the modmail channel
|
|
|
|
await user_channel.delete()
|
|
|
|
await modmail_channel.send(embed=SendMsgToModMail(self, msg, member),
|
|
|
|
return
|
|
|
|
file=File(fp=path))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Removing file from the directory after it has been sent
|
|
|
|
# If the user types anywhere else, delete the channel
|
|
|
|
if os.path.exists(path):
|
|
|
|
|
|
|
|
os.remove(path)
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print("The file does not exist")
|
|
|
|
await user_channel.delete()
|
|
|
|
|
|
|
|
|
|
|
|
# Make sure the user knows that their message has been sent
|
|
|
|
if str(reaction.emoji) == "❌":
|
|
|
|
await user_channel.send(embed=MessageSentConfirmation(member))
|
|
|
|
self.anon = False
|
|
|
|
|
|
|
|
|
|
|
|
# Let the user read the message for 5 seconds
|
|
|
|
# Delete the old embed
|
|
|
|
await asyncio.sleep(5)
|
|
|
|
await Anon_or_Not.delete()
|
|
|
|
|
|
|
|
|
|
|
|
await user_channel.delete()
|
|
|
|
# Tell the user to type their mail into the chat
|
|
|
|
return
|
|
|
|
instructions = await user_channel.send(embed=SendInstructions(member))
|
|
|
|
|
|
|
|
|
|
|
|
# If the user types anywhere else, delete the channel
|
|
|
|
# Making sure that the reply is from the author
|
|
|
|
else:
|
|
|
|
def check(m):
|
|
|
|
await user_channel.delete()
|
|
|
|
return m.author == payload.member and user_channel.id == instructions.channel.id
|
|
|
|
|
|
|
|
|
|
|
|
if str(reaction.emoji) == "❌":
|
|
|
|
# Wait for the message from the author
|
|
|
|
self.anon = False
|
|
|
|
msg = await self.bot.wait_for('message', check=check, timeout=300)
|
|
|
|
|
|
|
|
|
|
|
|
# Delete the old embed
|
|
|
|
# Making sure that the message is below 50 characters and the message was sent in the channel
|
|
|
|
await Anon_or_Not.delete()
|
|
|
|
while len(msg.content) < 50 and msg.channel == user_channel:
|
|
|
|
|
|
|
|
await user_channel.send(embed=ErrorHandling(member))
|
|
|
|
|
|
|
|
|
|
|
|
# Tell the user to type their mail into the chat
|
|
|
|
# Wait for the message from the author again
|
|
|
|
instructions = await user_channel.send(embed=SendInstructions(member))
|
|
|
|
msg = await self.bot.wait_for('message', check=check, timeout=300)
|
|
|
|
|
|
|
|
|
|
|
|
# Making sure that the reply is from the author
|
|
|
|
if len(msg.content) > 50 and msg.channel == user_channel:
|
|
|
|
def check(m):
|
|
|
|
# Delete the previous embed
|
|
|
|
return m.author == payload.member and user_channel.id == instructions.channel.id
|
|
|
|
await instructions.delete()
|
|
|
|
|
|
|
|
|
|
|
|
# Wait for the message from the author
|
|
|
|
# Determine a path for the message logs to be stored
|
|
|
|
msg = await self.bot.wait_for('message', check=check, timeout=300)
|
|
|
|
path = "cogs/modmail/{}.txt".format(payload.member.name)
|
|
|
|
|
|
|
|
with open(path, 'a+') as f:
|
|
|
|
|
|
|
|
# Store the date and content of every message in the text file
|
|
|
|
|
|
|
|
async for message in user_channel.history(limit=300):
|
|
|
|
|
|
|
|
print(f"{message.created_at} : {message.content}", file=f)
|
|
|
|
|
|
|
|
|
|
|
|
# Making sure that the message is below 50 characters and the message was sent in the channel
|
|
|
|
# Send the message to the modmail channel
|
|
|
|
while len(msg.content) < 50 and msg.channel == user_channel:
|
|
|
|
await modmail_channel.send(embed=SendMsgToModMail(self, msg, member),
|
|
|
|
await user_channel.send(embed=ErrorHandling(member))
|
|
|
|
file=File(fp=path))
|
|
|
|
|
|
|
|
|
|
|
|
# Wait for the message from the author again
|
|
|
|
# Removing file from the directory after it has been sent
|
|
|
|
msg = await self.bot.wait_for('message', check=check, timeout=300)
|
|
|
|
if os.path.exists(path):
|
|
|
|
|
|
|
|
os.remove(path)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
print("The file does not exist")
|
|
|
|
|
|
|
|
|
|
|
|
if len(msg.content) > 50 and msg.channel == user_channel:
|
|
|
|
# Make sure the user knows that their message has been sent
|
|
|
|
# Delete the previous embed
|
|
|
|
await user_channel.send(embed=MessageSentConfirmation(member))
|
|
|
|
await instructions.delete()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Determine a path for the message logs to be stored
|
|
|
|
# Let the user read the message for 5 seconds
|
|
|
|
path = "cogs/modmail/{}.txt".format(payload.member.name)
|
|
|
|
await asyncio.sleep(5)
|
|
|
|
with open(path, 'a+') as f:
|
|
|
|
|
|
|
|
# Store the date and content of every message in the text file
|
|
|
|
|
|
|
|
async for message in user_channel.history(limit=300):
|
|
|
|
|
|
|
|
print(f"{message.created_at} : {message.content}", file=f)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Send the message to the modmail channel
|
|
|
|
await user_channel.delete()
|
|
|
|
await modmail_channel.send(embed=SendMsgToModMail(self, msg, member),
|
|
|
|
return
|
|
|
|
file=File(fp=path))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Removing file from the directory after it has been sent
|
|
|
|
# If the user types anywhere else, delete the channel
|
|
|
|
if os.path.exists(path):
|
|
|
|
|
|
|
|
os.remove(path)
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print("The file does not exist")
|
|
|
|
await user_channel.delete()
|
|
|
|
|
|
|
|
|
|
|
|
# Make sure the user knows that their message has been sent
|
|
|
|
except Exception as ex:
|
|
|
|
await user_channel.send(embed=MessageSentConfirmation(member))
|
|
|
|
print(ex)
|
|
|
|
|
|
|
|
|
|
|
|
# Let the user read the message for 5 seconds
|
|
|
|
# Removing file from the directory after it has been sent
|
|
|
|
await asyncio.sleep(5)
|
|
|
|
if os.path.exists(path):
|
|
|
|
|
|
|
|
os.remove(path)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
print("The file does not exist")
|
|
|
|
|
|
|
|
|
|
|
|
await user_channel.delete()
|
|
|
|
# Send out an error message if the user waited too long
|
|
|
|
return
|
|
|
|
await user_channel.send(
|
|
|
|
|
|
|
|
"Sorry! Something seems to have gone wrong and the modmail will be aborting."
|
|
|
|
|
|
|
|
"\nRemember to make sure it's under **1024** characters!!")
|
|
|
|
|
|
|
|
|
|
|
|
# If the user types anywhere else, delete the channel
|
|
|
|
await asyncio.sleep(5)
|
|
|
|
else:
|
|
|
|
await user_channel.delete()
|
|
|
|
await user_channel.delete()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def setup(bot):
|
|
|
|
def setup(bot):
|
|
|
|