示例#1
0
def context(
    dpy_guild: discord.Guild,
    dpy_channel: discord.TextChannel,
    dpy_author: discord.User,
    dpy_message: discord.Message,
) -> discord.Interaction:
    stub = AsyncMock(spec=commands.Context)
    stub.guild = dpy_guild
    stub.channel = dpy_channel
    stub.channel_id = dpy_channel.id
    stub.author = dpy_author
    stub.message = dpy_message
    return stub
示例#2
0
def build_interaction(
    guild: discord.Guild,
    channel: discord.TextChannel,
    author: discord.User,
) -> discord.Interaction:
    stub = AsyncMock(spec=discord.Interaction)
    stub.response = AsyncMock()
    stub.followup = AsyncMock()
    stub.guild = guild
    stub.guild_id = guild.id
    stub.channel = channel
    stub.channel_id = channel.id
    stub.user = author
    stub.original_message = AsyncMock(
        return_value=build_message(guild, channel, author))
    return stub