Trying different way of executing modmail

Not massive if statements anymore
pull/8/head
sgoudham 4 years ago
parent 6347c48204
commit 454a7adb57

@ -630,6 +630,9 @@ class Guild(Cog):
if str(reaction.emoji) == "": if str(reaction.emoji) == "":
self.anon = True self.anon = True
if str(reaction.emoji) == "":
self.anon = False
# Delete the old embed # Delete the old embed
await Anon_or_Not.delete() await Anon_or_Not.delete()
@ -659,58 +662,11 @@ class Guild(Cog):
file = io.BytesIO(text_bytes) file = io.BytesIO(text_bytes)
# Send the message to the modmail channel file_name = "Anon.txt" if self.anon else f"{member.name}.txt"
await modmail_channel.send(embed=send_modmail(self, msg, member),
file=File(file, 'Anon.txt'))
# Make sure the user knows that their message has been sent
await user_channel.send(embed=message_sent_confirmation(member))
# Let the user read the message for 5 seconds
await asyncio.sleep(5)
# Delete the channel and then stop the function
await user_channel.delete()
# If the user types anywhere else, delete the channel
else:
await user_channel.delete()
return
if str(reaction.emoji) == "":
self.anon = False
# 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=send_instructions(member))
# Wait for the message from the author
msg = await self.bot.wait_for('message', check=check, timeout=300)
# Making sure that the message is below 50 characters and the message was sent in the channel
while len(msg.content) < 50 and msg.channel == user_channel:
await user_channel.send(embed=error_handling(member))
# Wait for the message from the author again
msg = await self.bot.wait_for('message', check=check, timeout=300)
if len(msg.content) > 50 and msg.channel == user_channel:
# Delete the previous embed
await instructions.delete()
# Store all text in the channel in a bytesio object
text = ""
async for message in user_channel.history(limit=300):
text = "".join(f"{message.created_at} : {message.content}\n")
text_bytes = str.encode(text)
file = io.BytesIO(text_bytes)
# Send the message to the modmail channel # Send the message to the modmail channel
await modmail_channel.send(embed=send_modmail(self, msg, member), await modmail_channel.send(embed=send_modmail(self, msg, member),
file=File(file, f'{member.name}.txt')) file=File(file, file_name))
# Make sure the user knows that their message has been sent # Make sure the user knows that their message has been sent
await user_channel.send(embed=message_sent_confirmation(member)) await user_channel.send(embed=message_sent_confirmation(member))
@ -718,7 +674,7 @@ class Guild(Cog):
# Let the user read the message for 5 seconds # Let the user read the message for 5 seconds
await asyncio.sleep(5) await asyncio.sleep(5)
# Delete the channel # Delete the channel and then stop the function
await user_channel.delete() await user_channel.delete()
# If the user types anywhere else, delete the channel # If the user types anywhere else, delete the channel

Loading…
Cancel
Save