Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cogs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .starboard import setup_starboard
from .faq import setup_faq
from .votedelete import setup_votedelete
from .sherpmail import setup_SherpMailbox_cog

import asyncio
from aiohttp import ClientSession
Expand All @@ -23,4 +24,5 @@ async def setup_all_cogs(bot, guilds, client=None):
setup_starboard(bot, guilds),
setup_faq(bot, guilds),
setup_votedelete(bot, guilds),
setup_SherpMailbox_cog(bot, guilds)
)
72 changes: 72 additions & 0 deletions cogs/sherpmail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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.name}** sent you the following:",
description = f"{msg}",
colour = discord.Colour.gold()
)
embed.set_footer(text = f"From: {interaction.user} | UID: {interaction.user.id}")
await self.sherp.send(embed = embed)

embed = discord.Embed(
title = f"📫 Outgoing! The following message has been mailed to Sherp:",
description = f"{msg}",
colour = discord.Colour.green()
)
embed.set_footer(text = f"From: {interaction.user} | UID: {interaction.user.id}")
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.channel.type.name == "private") and (message.author.id == 212613981465083906):
try:
embed = discord.Embed(
title = "📬 You've got mail! This is what Sherp said:",
description = f"{message.content}",
colour = discord.Colour.gold()
)
embed.set_footer(text = f"Another task completed by the Sherpmail distribution system.")
# 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()
)
embed.set_footer(text = f"Another task completed by the Sherpmail distribution system.")
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)