mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-14 15:53:30 -07:00
parent
d430f77ae1
commit
3740d64601
|
|
@ -29,15 +29,11 @@ public class ExportAllCommand : ExportCommandBase
|
||||||
|
|
||||||
[CommandOption(
|
[CommandOption(
|
||||||
"include-threads",
|
"include-threads",
|
||||||
Description = "Specifies which types of threads should be included.",
|
Description = "Which types of threads should be included.",
|
||||||
Converter = typeof(ThreadInclusionBindingConverter)
|
Converter = typeof(ThreadInclusionBindingConverter)
|
||||||
)]
|
)]
|
||||||
public ThreadInclusion ThreadInclusion { get; init; } = ThreadInclusion.None;
|
public ThreadInclusion ThreadInclusion { get; init; } = ThreadInclusion.None;
|
||||||
|
|
||||||
private bool IncludeThreads => ThreadInclusion != ThreadInclusion.None;
|
|
||||||
|
|
||||||
private bool IncludeArchivedThreads => ThreadInclusion.HasFlag(ThreadInclusion.Archived);
|
|
||||||
|
|
||||||
[CommandOption(
|
[CommandOption(
|
||||||
"data-package",
|
"data-package",
|
||||||
Description = "Path to the personal data package (ZIP file) requested from Discord. "
|
Description = "Path to the personal data package (ZIP file) requested from Discord. "
|
||||||
|
|
@ -74,12 +70,12 @@ public class ExportAllCommand : ExportCommandBase
|
||||||
}
|
}
|
||||||
|
|
||||||
// Threads
|
// Threads
|
||||||
if (IncludeThreads)
|
if (ThreadInclusion != ThreadInclusion.None)
|
||||||
{
|
{
|
||||||
await foreach (
|
await foreach (
|
||||||
var thread in Discord.GetGuildThreadsAsync(
|
var thread in Discord.GetGuildThreadsAsync(
|
||||||
guild.Id,
|
guild.Id,
|
||||||
IncludeArchivedThreads,
|
ThreadInclusion == ThreadInclusion.All,
|
||||||
cancellationToken
|
cancellationToken
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -136,9 +132,9 @@ public class ExportAllCommand : ExportCommandBase
|
||||||
channels.RemoveAll(c => c.Kind.IsGuild());
|
channels.RemoveAll(c => c.Kind.IsGuild());
|
||||||
if (!IncludeVoiceChannels)
|
if (!IncludeVoiceChannels)
|
||||||
channels.RemoveAll(c => c.Kind.IsVoice());
|
channels.RemoveAll(c => c.Kind.IsVoice());
|
||||||
if (!IncludeThreads)
|
if (ThreadInclusion == ThreadInclusion.None)
|
||||||
channels.RemoveAll(c => c.Kind.IsThread());
|
channels.RemoveAll(c => c.Kind.IsThread());
|
||||||
if (!IncludeArchivedThreads)
|
if (ThreadInclusion != ThreadInclusion.All)
|
||||||
channels.RemoveAll(c => c.Kind.IsThread() && c.IsArchived);
|
channels.RemoveAll(c => c.Kind.IsThread() && c.IsArchived);
|
||||||
|
|
||||||
await ExportAsync(console, channels);
|
await ExportAsync(console, channels);
|
||||||
|
|
|
||||||
|
|
@ -21,15 +21,11 @@ public class ExportGuildCommand : ExportCommandBase
|
||||||
|
|
||||||
[CommandOption(
|
[CommandOption(
|
||||||
"include-threads",
|
"include-threads",
|
||||||
Description = "Specifies which types of threads should be included.",
|
Description = "Which types of threads should be included.",
|
||||||
Converter = typeof(ThreadInclusionBindingConverter)
|
Converter = typeof(ThreadInclusionBindingConverter)
|
||||||
)]
|
)]
|
||||||
public ThreadInclusion ThreadInclusion { get; init; } = ThreadInclusion.None;
|
public ThreadInclusion ThreadInclusion { get; init; } = ThreadInclusion.None;
|
||||||
|
|
||||||
private bool IncludeThreads => ThreadInclusion != ThreadInclusion.None;
|
|
||||||
|
|
||||||
private bool IncludeArchivedThreads => ThreadInclusion.HasFlag(ThreadInclusion.Archived);
|
|
||||||
|
|
||||||
public override async ValueTask ExecuteAsync(IConsole console)
|
public override async ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
await base.ExecuteAsync(console);
|
await base.ExecuteAsync(console);
|
||||||
|
|
@ -52,12 +48,12 @@ public class ExportGuildCommand : ExportCommandBase
|
||||||
}
|
}
|
||||||
|
|
||||||
// Threads
|
// Threads
|
||||||
if (IncludeThreads)
|
if (ThreadInclusion != ThreadInclusion.None)
|
||||||
{
|
{
|
||||||
await foreach (
|
await foreach (
|
||||||
var thread in Discord.GetGuildThreadsAsync(
|
var thread in Discord.GetGuildThreadsAsync(
|
||||||
GuildId,
|
GuildId,
|
||||||
IncludeArchivedThreads,
|
ThreadInclusion == ThreadInclusion.All,
|
||||||
cancellationToken
|
cancellationToken
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -23,15 +23,11 @@ public class GetChannelsCommand : DiscordCommandBase
|
||||||
|
|
||||||
[CommandOption(
|
[CommandOption(
|
||||||
"include-threads",
|
"include-threads",
|
||||||
Description = "Specifies which types of threads should be included.",
|
Description = "Which types of threads should be included.",
|
||||||
Converter = typeof(ThreadInclusionBindingConverter)
|
Converter = typeof(ThreadInclusionBindingConverter)
|
||||||
)]
|
)]
|
||||||
public ThreadInclusion ThreadInclusion { get; init; } = ThreadInclusion.None;
|
public ThreadInclusion ThreadInclusion { get; init; } = ThreadInclusion.None;
|
||||||
|
|
||||||
private bool IncludeThreads => ThreadInclusion != ThreadInclusion.None;
|
|
||||||
|
|
||||||
private bool IncludeArchivedThreads => ThreadInclusion.HasFlag(ThreadInclusion.Archived);
|
|
||||||
|
|
||||||
public override async ValueTask ExecuteAsync(IConsole console)
|
public override async ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
await base.ExecuteAsync(console);
|
await base.ExecuteAsync(console);
|
||||||
|
|
@ -50,11 +46,12 @@ public class GetChannelsCommand : DiscordCommandBase
|
||||||
.OrderDescending()
|
.OrderDescending()
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
var threads = IncludeThreads
|
var threads =
|
||||||
|
ThreadInclusion != ThreadInclusion.None
|
||||||
? (
|
? (
|
||||||
await Discord.GetGuildThreadsAsync(
|
await Discord.GetGuildThreadsAsync(
|
||||||
GuildId,
|
GuildId,
|
||||||
IncludeArchivedThreads,
|
ThreadInclusion == ThreadInclusion.All,
|
||||||
cancellationToken
|
cancellationToken
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,8 @@
|
||||||
using System;
|
namespace DiscordChatExporter.Cli.Commands.Shared;
|
||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Commands.Shared;
|
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum ThreadInclusion
|
public enum ThreadInclusion
|
||||||
{
|
{
|
||||||
None = 0,
|
None,
|
||||||
Active = 1,
|
Active,
|
||||||
Archived = 2,
|
All
|
||||||
All = Active | Archived
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
DiscordChatExporter.Gui/Models/ThreadInclusion.cs
Normal file
8
DiscordChatExporter.Gui/Models/ThreadInclusion.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
namespace DiscordChatExporter.Gui.Models;
|
||||||
|
|
||||||
|
public enum ThreadInclusion
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Active,
|
||||||
|
All
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Cogwheel;
|
using Cogwheel;
|
||||||
using DiscordChatExporter.Core.Exporting;
|
using DiscordChatExporter.Core.Exporting;
|
||||||
|
using DiscordChatExporter.Gui.Models;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
|
||||||
namespace DiscordChatExporter.Gui.Services;
|
namespace DiscordChatExporter.Gui.Services;
|
||||||
|
|
@ -16,9 +17,7 @@ public partial class SettingsService : SettingsBase
|
||||||
|
|
||||||
public bool IsTokenPersisted { get; set; } = true;
|
public bool IsTokenPersisted { get; set; } = true;
|
||||||
|
|
||||||
public bool ShouldShowThreads { get; set; }
|
public ThreadInclusion ThreadInclusion { get; set; } = ThreadInclusion.None;
|
||||||
|
|
||||||
public bool ShouldShowArchivedThreads { get; set; }
|
|
||||||
|
|
||||||
public string DateFormat { get; set; } = "MM/dd/yyyy h:mm tt";
|
public string DateFormat { get; set; } = "MM/dd/yyyy h:mm tt";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ using DiscordChatExporter.Core.Discord.Data;
|
||||||
using DiscordChatExporter.Core.Exceptions;
|
using DiscordChatExporter.Core.Exceptions;
|
||||||
using DiscordChatExporter.Core.Exporting;
|
using DiscordChatExporter.Core.Exporting;
|
||||||
using DiscordChatExporter.Core.Utils.Extensions;
|
using DiscordChatExporter.Core.Utils.Extensions;
|
||||||
|
using DiscordChatExporter.Gui.Models;
|
||||||
using DiscordChatExporter.Gui.Services;
|
using DiscordChatExporter.Gui.Services;
|
||||||
using DiscordChatExporter.Gui.Utils;
|
using DiscordChatExporter.Gui.Utils;
|
||||||
using DiscordChatExporter.Gui.ViewModels.Dialogs;
|
using DiscordChatExporter.Gui.ViewModels.Dialogs;
|
||||||
|
|
@ -169,12 +170,12 @@ public class DashboardViewModel : PropertyChangedBase
|
||||||
}
|
}
|
||||||
|
|
||||||
// Threads
|
// Threads
|
||||||
if (_settingsService.ShouldShowThreads)
|
if (_settingsService.ThreadInclusion != ThreadInclusion.None)
|
||||||
{
|
{
|
||||||
await foreach (
|
await foreach (
|
||||||
var thread in _discord.GetGuildThreadsAsync(
|
var thread in _discord.GetGuildThreadsAsync(
|
||||||
SelectedGuild.Id,
|
SelectedGuild.Id,
|
||||||
_settingsService.ShouldShowArchivedThreads
|
_settingsService.ThreadInclusion == ThreadInclusion.All
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using DiscordChatExporter.Gui.Models;
|
||||||
using DiscordChatExporter.Gui.Services;
|
using DiscordChatExporter.Gui.Services;
|
||||||
using DiscordChatExporter.Gui.ViewModels.Framework;
|
using DiscordChatExporter.Gui.ViewModels.Framework;
|
||||||
|
|
||||||
|
|
@ -26,23 +28,13 @@ public class SettingsViewModel : DialogScreen
|
||||||
set => _settingsService.IsTokenPersisted = value;
|
set => _settingsService.IsTokenPersisted = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ShouldShowThreads
|
public IReadOnlyList<ThreadInclusion> AvailableThreadInclusions { get; } =
|
||||||
{
|
Enum.GetValues<ThreadInclusion>();
|
||||||
get => _settingsService.ShouldShowThreads;
|
|
||||||
set => _settingsService.ShouldShowThreads = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ShouldShowArchivedThreads
|
public ThreadInclusion ThreadInclusion
|
||||||
{
|
{
|
||||||
get => _settingsService.ShouldShowArchivedThreads;
|
get => _settingsService.ThreadInclusion;
|
||||||
set
|
set => _settingsService.ThreadInclusion = value;
|
||||||
{
|
|
||||||
_settingsService.ShouldShowArchivedThreads = value;
|
|
||||||
|
|
||||||
// Enabling archived threads implicitly enables threads
|
|
||||||
if (value)
|
|
||||||
ShouldShowThreads = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string DateFormat
|
public string DateFormat
|
||||||
|
|
|
||||||
|
|
@ -82,36 +82,21 @@
|
||||||
IsChecked="{Binding IsTokenPersisted}" />
|
IsChecked="{Binding IsTokenPersisted}" />
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|
||||||
<!-- Show threads -->
|
<!-- Thread inclusion -->
|
||||||
<DockPanel
|
<DockPanel
|
||||||
Margin="16,8"
|
Margin="16,8"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
LastChildFill="False"
|
LastChildFill="False"
|
||||||
ToolTip="Pull threads and show them in the channel list">
|
ToolTip="Which types of threads to show in the channel list">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
DockPanel.Dock="Left"
|
DockPanel.Dock="Left"
|
||||||
Text="Show threads" />
|
Text="Show threads" />
|
||||||
<ToggleButton
|
<ComboBox
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
DockPanel.Dock="Right"
|
DockPanel.Dock="Right"
|
||||||
IsChecked="{Binding ShouldShowThreads}" />
|
ItemsSource="{Binding AvailableThreadInclusions}"
|
||||||
</DockPanel>
|
SelectedItem="{Binding ThreadInclusion}" />
|
||||||
|
|
||||||
<!-- Show archived threads -->
|
|
||||||
<DockPanel
|
|
||||||
Margin="16,8"
|
|
||||||
Background="Transparent"
|
|
||||||
LastChildFill="False"
|
|
||||||
ToolTip="Pull archived threads and show them in the channel list">
|
|
||||||
<TextBlock
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
DockPanel.Dock="Left"
|
|
||||||
Text="Show archived threads" />
|
|
||||||
<ToggleButton
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
DockPanel.Dock="Right"
|
|
||||||
IsChecked="{Binding ShouldShowArchivedThreads}" />
|
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|
||||||
<!-- Date format -->
|
<!-- Date format -->
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue