Skip to content
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: 1 addition & 1 deletion discord/ext/test/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ async def edit_message(self, channel_id: int, message_id: int, **fields: typing.
locs = _get_higher_locs(1)
message = locs.get("self", None)

await callbacks.dispatch_event("edit_message", message.channel, message, fields)
await callbacks.dispatch_event("send_message", message)

out = facts.dict_from_message(message)
out.update(fields)
Expand Down
21 changes: 21 additions & 0 deletions tests/internal/cogs/edit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from discord.ext.commands import Cog, command
from asyncio import sleep


class Edit(Cog):

# Silence the default on_error handler
async def cog_command_error(self, ctx, error):
pass

@command()
async def edit(self, ctx, text: str):
msg = await ctx.send(text)
print("Something")
reversed = text[::-1]
response = await msg.edit(content=reversed) # reverse the output of the command



def setup(bot):
bot.add_cog(Edit())
24 changes: 24 additions & 0 deletions tests/test_edit_cog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

import pytest
import discord.ext.test as test

@pytest.mark.asyncio
async def test_edit(bot):
guild = bot.guilds[0]
channel = guild.channels[0]

mes = await channel.send("Test Message")
await mes.edit(content="New Message")

assert mes.content == "New Message"

@pytest.mark.asyncio
@pytest.mark.cogs("cogs.edit")
async def test_edit_cog(bot):
guild = bot.guilds[0]
member = guild.members[0]
dm = await member.create_dm()
await test.message("!edit Ah-Ha!", dm)

assert test.verify().message().content("Ah-Ha!")
assert test.verify().message().content("!aH-hA")