commit
a4f8fed4e5
@ -0,0 +1,5 @@
|
||||
from .firstmessage import FirstMessage
|
||||
|
||||
|
||||
async def setup(bot):
|
||||
bot.add_cog(FirstMessage(bot))
|
@ -0,0 +1,48 @@
|
||||
import logging
|
||||
|
||||
import discord
|
||||
from redbot.core import Config, commands
|
||||
from redbot.core.bot import Red
|
||||
|
||||
log = logging.getLogger("red.fox_v3.firstmessage")
|
||||
|
||||
|
||||
class FirstMessage(commands.Cog):
|
||||
"""
|
||||
Provides a link to the first message in the provided channel
|
||||
|
||||
Less important information about the cog
|
||||
"""
|
||||
|
||||
def __init__(self, bot: Red):
|
||||
super().__init__()
|
||||
self.bot = bot
|
||||
self.config = Config.get_conf(
|
||||
self, identifier=701051141151167710111511597103101, force_registration=True
|
||||
)
|
||||
|
||||
default_guild = {}
|
||||
|
||||
self.config.register_guild(**default_guild)
|
||||
|
||||
async def red_delete_data_for_user(self, **kwargs):
|
||||
"""Nothing to delete"""
|
||||
return
|
||||
|
||||
@commands.command()
|
||||
async def firstmessage(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
||||
if channel is None:
|
||||
channel = ctx.channel
|
||||
try:
|
||||
message: discord.Message = (
|
||||
await channel.history(limit=1, oldest_first=True).flatten()
|
||||
)[0]
|
||||
except (discord.Forbidden, discord.HTTPException):
|
||||
log.exception(f"Unable to read message history for {channel.id=}")
|
||||
await ctx.maybe_send_embed("Unable to read message history for that channel")
|
||||
return
|
||||
|
||||
em = discord.Embed(description=f"[First Message in {channel.mention}]({message.jump_url})")
|
||||
em.set_author(name=message.author.display_name, icon_url=message.author.avatar_url)
|
||||
|
||||
await ctx.send(embed=em)
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"author": [
|
||||
"Bobloy"
|
||||
],
|
||||
"min_bot_version": "3.4.0",
|
||||
"description": "Simple cog to jump to the first message of a channel easily",
|
||||
"hidden": false,
|
||||
"install_msg": "Thank you for installing FirstMessage.\nGet started with `[p]load firstmessage`, then `[p]help FirstMessage`",
|
||||
"short": "Simple cog to jump to first message of a channel",
|
||||
"end_user_data_statement": "This cog does not store any End User Data",
|
||||
"tags": [
|
||||
"bobloy",
|
||||
"utilities",
|
||||
"tool"
|
||||
]
|
||||
}
|
Loading…
Reference in new issue