Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread names get exported as #deleted-channel in mentions #1261

Open
4 of 6 tasks
ShadowJonathan opened this issue Jul 16, 2024 · 1 comment · May be fixed by #1288
Open
4 of 6 tasks

Thread names get exported as #deleted-channel in mentions #1261

ShadowJonathan opened this issue Jul 16, 2024 · 1 comment · May be fixed by #1288
Labels

Comments

@ShadowJonathan
Copy link

Version

2.43.3

Flavor

CLI (Command-Line Interface)

Platform

Linux (Debian)

Export format

HTML

Steps to reproduce

  • Make a mention to a thread in a channel
  • Export that channel
  • Observe the mention being converted to #deleted-channel

Details

This piece of code is relevant;

var name = channel?.Name ?? "deleted-channel";

It only looks for a name of the channel, not of a thread.

Even discord seems to struggle, not fetching a corresponding thread, only saying #unknown

Checklist

  • I have looked through existing issues to make sure that this bug has not been reported before
  • I have provided a descriptive title for this issue
  • I have made sure that this bug is reproducible on the latest version of the application
  • I have provided all the information needed to reproduce this bug as efficiently as possible
  • I have sponsored this project
  • I have not read any of the above and just checked all the boxes to submit the issue
@Tyrrrz
Copy link
Owner

Tyrrrz commented Jul 16, 2024

The issue is that we don't preload all threads as we do with channels, so we can't resolve the mentions the same way:

public async ValueTask PopulateChannelsAndRolesAsync(
CancellationToken cancellationToken = default
)
{
await foreach (
var channel in Discord.GetGuildChannelsAsync(Request.Guild.Id, cancellationToken)
)
{
_channelsById[channel.Id] = channel;
}
await foreach (var role in Discord.GetGuildRolesAsync(Request.Guild.Id, cancellationToken))
{
_rolesById[role.Id] = role;
}
}

We should employ a strategy similar to members:

// Because members cannot be pulled in bulk, we need to populate them on demand
private async ValueTask PopulateMemberAsync(
Snowflake id,
User? fallbackUser,
CancellationToken cancellationToken = default
)
{
if (_membersById.ContainsKey(id))
return;
var member = await Discord.TryGetGuildMemberAsync(Request.Guild.Id, id, cancellationToken);
// User may have left the guild since they were mentioned.
// Create a dummy member object based on the user info.
if (member is null)
{
var user = fallbackUser ?? await Discord.TryGetUserAsync(id, cancellationToken);
// User may have been deleted since they were mentioned
if (user is not null)
member = Member.CreateFallback(user);
}
// Store the result even if it's null, to avoid re-fetching non-existing members
_membersById[id] = member;
}
public async ValueTask PopulateMemberAsync(
Snowflake id,
CancellationToken cancellationToken = default
) => await PopulateMemberAsync(id, null, cancellationToken);
public async ValueTask PopulateMemberAsync(
User user,
CancellationToken cancellationToken = default
) => await PopulateMemberAsync(user.Id, user, cancellationToken);

@Tyrrrz Tyrrrz changed the title Thread names get exported as #deleted-channel Thread names get exported as #deleted-channel in mentions Jul 16, 2024
@maxgsf maxgsf linked a pull request Sep 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants