Files
juniteevee-cogs/reactquote/reactquote.py

37 lines
1.3 KiB
Python
Raw Normal View History

2022-04-09 13:32:53 -04:00
from redbot.core import commands
2022-04-10 16:01:49 -04:00
import discord
2022-04-11 09:33:54 -04:00
from datetime import datetime
2022-04-09 13:32:53 -04:00
class ReactQuote(commands.Cog):
"""Cog to store quotes by reacting with speech bubble"""
def __init__(self, bot):
self.bot = bot
2022-04-10 09:29:34 -04:00
def _wrapQuote(self, msg):
return msg
2022-04-09 13:32:53 -04:00
2022-04-11 09:59:14 -04:00
def _buildQuote(self, message:discord.Message):
2022-04-11 10:07:38 -04:00
quote = "Quoted text will be here\n {message.jump_url}"
2022-04-11 09:54:09 -04:00
timestamp = datetime.now()
embed = discord.Embed(timestamp=timestamp)
2022-04-11 10:04:43 -04:00
embed.set_author(name=message.author.display_name, icon_url=message.author.avatar_url)
2022-04-11 09:50:57 -04:00
embed.add_field(name="#1", value=quote, inline=False)
2022-04-11 09:33:54 -04:00
return embed
2022-04-10 16:01:49 -04:00
@commands.command()
async def quote(self, ctx: commands.Context):
2022-04-10 23:10:05 -04:00
"""Recall Random Quote"""
2022-04-10 16:01:49 -04:00
# Your code will go here
2022-04-11 09:59:14 -04:00
await ctx.send(embed=self._buildQuote(ctx.message))
2022-04-10 16:01:49 -04:00
2022-04-10 23:04:59 -04:00
@commands.Cog.listener()
2022-04-10 16:01:49 -04:00
async def on_raw_reaction_add(self, payload:discord.RawReactionActionEvent):
"""On React"""
2022-04-10 22:37:15 -04:00
if str(payload.emoji) == '💬':
2022-04-10 22:57:13 -04:00
message: discord.Message = await self.bot.get_channel(payload.channel_id).fetch_message(payload.message_id)
2022-04-10 22:37:15 -04:00
user = payload.member
2022-04-10 22:57:13 -04:00
channel: discord.TextChannel = message.channel
2022-04-11 10:09:23 -04:00
await channel.send("I'd quote that if I could...\n{message.jump_url}")