-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sherpmail #88
base: master
Are you sure you want to change the base?
Sherpmail #88
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,68 @@ | ||||||
import discord | ||||||
from discord.ext import commands | ||||||
from discord import app_commands | ||||||
|
||||||
# I couldn't work out replying directly to the initial messages so this is not the best | ||||||
# Nonetheless it is nearly 6am and I felt the need to complete this | ||||||
# I hope it works out and nobody abuses it lol good luck | ||||||
|
||||||
class sherpMailbox(commands.Cog): | ||||||
def __init__(self, bot): | ||||||
self.bot = bot | ||||||
self.sherp = "" | ||||||
|
||||||
async def cog_load(self): | ||||||
await super().cog_load() | ||||||
print("Sherpmail loaded.") | ||||||
|
||||||
@app_commands.command( | ||||||
name = "sherpmail", | ||||||
description = "Leave a message directly to Sherp's DMs" | ||||||
) | ||||||
@app_commands.describe( | ||||||
msg = "The message you would like to leave for Sherp (be respectful)" | ||||||
) | ||||||
async def sendMessage(self, interaction: discord.Interaction, msg: str): | ||||||
# Sherp's Discord ID is currently 212613981465083906 | ||||||
self.sherp = await interaction.client.fetch_user(212613981465083906) | ||||||
try: | ||||||
embed = discord.Embed( | ||||||
title = f"📬 You've got mail! **@{interaction.user} | ID: {interaction.user.id}** sent you the following:", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems incorrect, unless discord.py has some special There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The unique UID and user would prevent someone from writing stupid things as they would know that their identifiers were also being sent to Sherp. I did rewrite it and have it stated in the footer of the embed instead. |
||||||
description = f"{msg}", | ||||||
colour = discord.Colour.gold() | ||||||
) | ||||||
await self.sherp.send(embed = embed) | ||||||
|
||||||
embed = discord.Embed( | ||||||
title = f"📫 Outgoing! The following message has been mailed to {self.sherp.display_name}:", | ||||||
description = f"{msg}", | ||||||
colour = discord.Colour.green() | ||||||
) | ||||||
await interaction.response.send_message(embed = embed) | ||||||
except: | ||||||
await interaction.response.send_message(f"❌ An unexpected error has occurred!") | ||||||
|
||||||
@commands.Cog.listener() | ||||||
async def on_message(self, message: discord.Message): | ||||||
if (message.guild == None) and (message.author.id == 214657501193306112): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think this is clearer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adjusted to |
||||||
try: | ||||||
embed = discord.Embed( | ||||||
title = "📬 You've got mail! This is what Sherp said:", | ||||||
description = f"{message.content}", | ||||||
colour = discord.Colour.gold() | ||||||
) | ||||||
# I used the ID 1183281507842924645 from the channel "non-cs-nonsense" | ||||||
ch = self.bot.get_channel(1183281507842924645) | ||||||
await ch.send(embed = embed) | ||||||
|
||||||
embed = discord.Embed( | ||||||
title = f"📫 Outgoing! The following reply was sent:", | ||||||
description = f"{message.content}", | ||||||
colour = discord.Colour.green() | ||||||
) | ||||||
await message.reply(embed = embed, mention_author = False) | ||||||
except: | ||||||
await message.reply(f"❌ An unexpected error has occurred!") | ||||||
|
||||||
async def setup_sherpMailbox_cog(bot, guilds): | ||||||
await bot.add_cog(sherpMailbox(bot), guilds=guilds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(style)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! Applied to the incoming commit.