discord-net / Discord.Net

An unofficial .Net wrapper for the Discord API (https://discord.com/)
https://discordnet.dev
MIT License
3.34k stars 737 forks source link

[Bug]: Can't edit ephemeral messages #2830

Open FemLolStudio opened 10 months ago

FemLolStudio commented 10 months ago

Check The Docs

Verify Issue Source

Check your intents

Description

I have some command in my bot where I used this method to inform the user about the current stage from the process, but today I noticed somewhy now it's not working.

Maybe something changed about the Discord API, because I get the same problem on the previous Discord.NET versions.

The problem exists in 3.9.0 too, that was the lowest what I was able to go with my current bot codes, so maybe it's something about the Discord API.

Version

3.13.0

Logs

guid:4c60 : 07:34:48 Command     Command: ephemeral-test, User: femlol
guid:e291 : 07:34:49 App Command Discord.Net.HttpException: The server responded with error 10008: Unknown Message
   at Discord.Net.Queue.RequestBucket.SendAsync(RestRequest request)
   at Discord.Net.Queue.RequestQueue.SendAsync(RestRequest request)
   at Discord.API.DiscordRestApiClient.SendInternalAsync(String method, String endpoint, RestRequest request)
   at Discord.API.DiscordRestApiClient.SendJsonAsync[TResponse](String method, String endpoint, Object payload, BucketId bucketId, ClientBucketType clientBucket, RequestOptions options)
   at Discord.Rest.RestUserMessage.ModifyAsync(Action`1 func, RequestOptions options)
   at ChibiMation.Command.BaseCommands.Test(Boolean ephemeral) in /src/Command/BaseCommands.cs:line 68
   at Discord.Interactions.Builders.ModuleClassBuilder.<>c__DisplayClass11_0.<<CreateCallback>g__ExecuteCallback|1>d.MoveNext()
guid:4c60 : 07:34:57 Command     Command: ephemeral-test, User: femlol

Sample

[SlashCommand("ephemeral-test", "Testing bug")]
public async Task Test(bool ephemeral)
{
    await DeferAsync(ephemeral: ephemeral);
    IUserMessage msg = await FollowupAsync("Test", ephemeral: ephemeral);
    await msg.ModifyAsync(x => x.Content = "Test success");
}

Result for true and false: image

Packages

<ItemGroup>
    <PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.300" />
    <PackageReference Include="AWSSDK.S3" Version="3.7.305.14" />
    <PackageReference Include="Betalgo.OpenAI" Version="7.4.3" />
    <PackageReference Include="Discord.Net" Version="3.13.0" />
    <PackageReference Include="Google.Apis.YouTube.v3" Version="1.66.0.3205" />
    <PackageReference Include="InnerTube" Version="1.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1">
        <PrivateAssets>all</PrivateAssets>
        <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.Extensions.Configuration.Yaml" Version="2.0.0-preview2" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
    <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="8.0.1" />
    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
    <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0-beta.2" />
    <PackageReference Include="SixLabors.ImageSharp" Version="3.1.2" />
    <PackageReference Include="YamlDotNet" Version="13.7.1" />
</ItemGroup>

Environment

Misha-133 commented 10 months ago

iirc FollowupAsync returns a RestFollowupMessage. So try using this type instead.

FemLolStudio commented 10 months ago

Hmm, okey. Yeah now its working. But it's actually returning an IUserMessage instead of RestFollowupMessage so thats confusing.

image

Now in this form it's working:

[SlashCommand("ephemeral-test", "Testing bug")]
public async Task Test(bool ephemeral)
{
    await DeferAsync(ephemeral: ephemeral);
    RestFollowupMessage msg = (RestFollowupMessage)await FollowupAsync("Test", ephemeral: ephemeral);
    await msg.ModifyAsync(x => x.Content = "Test success");
}
Misha-133 commented 10 months ago

But it's actually returning an IUserMessage instead of RestFollowupMessage so thats confusing.

Hmm yeah, that's because of an abstraction layer. Actual method impls in Rest/SocketInteraction return a RestFollowupMessage. I'll see if we can change this.

realdisplyy commented 5 months ago

How could you first not respond with a file and then afterwards modifying it with a uploading a file to the message?

SylveonDeko commented 5 months ago

How could you first not respond with a file and then afterwards modifying it with a uploading a file to the message?

How could you not ask for support in the discord

realdisplyy commented 5 months ago

Okay sorry