~nova/fletcher

357077bc9028c27b428c5e4947cc00366275005b — Novalinium a month ago 74e643f
Use new fetch_message endpoint
6 files changed, 16 insertions(+), 18 deletions(-)

M commandhandler.py
M janissary.py
M main.py
M schedule.py
M swag.py
M text_manipulators.py
M commandhandler.py => commandhandler.py +5 -5
@@ 239,7 239,7 @@ class CommandHandler:
                    "channel",
                    channel.name if type(channel) is not discord.DMChannel else "DM",
                )
                message = await channel.fetch_message(reaction.message_id)
                message = await channel.fetch_message_fast(reaction.message_id)
                if message.guild:
                    user = message.guild.get_member(reaction.user_id)
                    scope.set_tag("guild", message.guild.name)


@@ 382,7 382,7 @@ class CommandHandler:
                        if metuple is not None:
                            fromGuild = self.client.get_guild(metuple[0])
                            fromChannel = fromGuild.get_channel(metuple[1])
                            fromMessage = await fromChannel.fetch_message(metuple[2])
                            fromMessage = await fromChannel.fetch_message_fast(metuple[2])
                            if fromMessage.author.id in config.get(
                                section="moderation",
                                key="blacklist-user-usage",


@@ 417,7 417,7 @@ class CommandHandler:
                        if metuple is not None:
                            toGuild = self.client.get_guild(metuple[0])
                            toChannel = toGuild.get_channel(metuple[1])
                            toMessage = await toChannel.fetch_message(metuple[2])
                            toMessage = await toChannel.fetch_message_fast(metuple[2])
                            if toMessage.author.id in config.get(
                                section="moderation",
                                key="blacklist-user-usage",


@@ 470,7 470,7 @@ class CommandHandler:
                    user = channel.guild.get_member(reaction.user_id)
                    scope.set_tag("guild", channel.guild.name)
                scope.user = {"id": user.id, "username": str(user)}
                message = await channel.fetch_message(reaction.message_id)
                message = await channel.fetch_message_fast(reaction.message_id)
                if type(channel) is discord.TextChannel:
                    logger.info(
                        f"#{channel.guild.name}:{channel.name} <{user.name}:{user.id}> unreacting with {messageContent} from {message.id}",


@@ 795,7 795,7 @@ class CommandHandler:
        if metuple is not None:
            toGuild = self.client.get_guild(metuple[0])
            toChannel = toGuild.get_channel(metuple[1])
            toMessage = await toChannel.fetch_message(metuple[2])
            toMessage = await toChannel.fetch_message_fast(metuple[2])
            if message.pinned:
                await toMessage.pin()
                return

M janissary.py => janissary.py +2 -2
@@ 1046,12 1046,12 @@ async def chanlog_function(message, client, args):

        if len(args) > 0:
            content += f" before {args[0]}"
            before = await message.channel.fetch_message(id=args[0])
            before = await message.channel.fetch_message_fast(id=args[0])
        else:
            before = None
        if len(args) > 1:
            content += f" after {args[1]}"
            after = await message.channel.fetch_message(id=args[1])
            after = await message.channel.fetch_message_fast(id=args[1])
        else:
            after = None


M main.py => main.py +3 -5
@@ 176,9 176,7 @@ async def load_webhooks(ch=None):
                    ):
                        logger.debug(f"LWH: * {webhook.name}")
                        toChannelName = (
                            guild.name
                            + ":"
                            + str(guild.get_channel(webhook.channel_id))
                                f"{guild.name}:{guild.get_channel(webhook.channel_id).name}"
                        )
                        fromTuple = webhook.name.split("(")[1].split(")")[0].split(":")
                        fromTuple[0] = messagefuncs.expand_guild_name(


@@ 501,7 499,7 @@ async def on_raw_message_edit(payload):
        else:
            fromChannel = client.get_channel(int(message["channel_id"]))
        try:
            fromMessage = await fromChannel.fetch_message(message_id)
            fromMessage = await fromChannel.fetch_message_fast(message_id)
        except discord.NotFound as e:
            exc_type, exc_obj, exc_tb = exc_info()
            extra = {"MESSAGE_ID": str(message_id), "payload": str(payload)}


@@ 629,7 627,7 @@ async def on_raw_message_delete(message):
                toMessage = None
                while not toMessage:
                    try:
                        toMessage = await toChannel.fetch_message(metuple[2])
                        toMessage = await toChannel.fetch_message_fast(metuple[2])
                    except discord.NotFound as e:
                        exc_type, exc_obj, exc_tb = exc_info()
                        logger.error(

M schedule.py => schedule.py +1 -1
@@ 216,7 216,7 @@ async def table_exec_function():
                from_channel = guild.get_channel(channel_id)
                target_message = None
                try:
                    target_message = await from_channel.fetch_message(message_id)
                    target_message = await from_channel.fetch_message_fast(message_id)
                    # created_at is naîve, but specified as UTC by Discord API docs
                except (discord.NotFound, AttributeError) as e:
                    pass

M swag.py => swag.py +2 -2
@@ 605,7 605,7 @@ async def azlyrics_function(message, client, args):
async def dog_function(message, client, args):
    global ch
    try:
        if ch.user_config(message.author.id, None, 'crocodile-is-dog'):
        if ch.user_config(message.author.id, None, "crocodile-is-dog"):
            return await message.channel.send(
                "https://tenor.com/view/crocodile-slow-moving-dangerous-attack-predator-gif-13811045"
            )


@@ 862,7 862,7 @@ async def qdb_add_function(message, client, args):
                    logger.warning("QAF: Fletcher is not in guild ID " + str(guild_id))
                    return
                channel = guild.get_channel(channel_id)
                target_message = await channel.fetch_message(message_id)
                target_message = await channel.fetch_message_fast(message_id)
                content = f"[{target_message.created_at}] #{target_message.channel.name} <{target_message.author.display_name}>: {target_message.content}\n<https://discordapp.com/channels/{target_message.guild.id}/{target_message.channel.id}/{target_message.id}>"
                cur = conn.cursor()
                cur.execute(

M text_manipulators.py => text_manipulators.py +3 -3
@@ 3131,7 3131,7 @@ async def reaction_request_function(message, client, args):
                    logger.warning("QAF: Fletcher is not in guild ID " + str(guild_id))
                    return
                channel = guild.get_channel(channel_id)
                target = await channel.fetch_message(message_id)
                target = await channel.fetch_message_fast(message_id)
        except AttributeError:
            pass
        if len(args) >= 2 and args[1].isnumeric() and int(args[1]) < 1000000:


@@ 3178,7 3178,7 @@ async def reaction_request_function(message, client, args):
                            reason="xreact custom copier",
                        )
        if len(args) >= 2 and args[-1].isnumeric() and int(args[1]) >= 1000000:
            target = await message.channel.fetch_message(int(args[-1]))
            target = await message.channel.fetch_message_fast(int(args[-1]))
        if emoji:
            if target is None:
                async for historical_message in message.channel.history(


@@ 3271,7 3271,7 @@ async def blockquote_embed_function(message, client, args):
                        "I don't have permission to access that message, please check server configuration."
                    )
                channel = guild.get_channel(channel_id)
                target_message = await channel.fetch_message(message_id)
                target_message = await channel.fetch_message_fast(message_id)
                # created_at is naîve, but specified as UTC by Discord API docs
                sent_at = target_message.created_at.strftime("%B %d, %Y %I:%M%p UTC")
                rollup = target_message.content