mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-23 11:16:59 -04:00
parent
b58e67776c
commit
ae42554621
11 changed files with 37 additions and 13 deletions
|
@ -31,6 +31,10 @@ namespace DiscordChatExporter.Cli.Commands
|
||||||
|
|
||||||
await foreach (var channel in Discord.GetGuildChannelsAsync(guild.Id))
|
await foreach (var channel in Discord.GetGuildChannelsAsync(guild.Id))
|
||||||
{
|
{
|
||||||
|
// Skip non-text channels
|
||||||
|
if (!channel.IsTextChannel)
|
||||||
|
continue;
|
||||||
|
|
||||||
channels.Add(channel);
|
channels.Add(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Threading.Tasks;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using CliFx.Attributes;
|
using CliFx.Attributes;
|
||||||
using CliFx.Infrastructure;
|
using CliFx.Infrastructure;
|
||||||
using DiscordChatExporter.Cli.Commands.Base;
|
using DiscordChatExporter.Cli.Commands.Base;
|
||||||
|
@ -17,9 +18,10 @@ namespace DiscordChatExporter.Cli.Commands
|
||||||
// Get channel metadata
|
// Get channel metadata
|
||||||
await console.Output.WriteLineAsync("Fetching channels...");
|
await console.Output.WriteLineAsync("Fetching channels...");
|
||||||
var channels = await Discord.GetGuildChannelsAsync(Guild.DirectMessages.Id);
|
var channels = await Discord.GetGuildChannelsAsync(Guild.DirectMessages.Id);
|
||||||
|
var textChannels = channels.Where(c => c.IsTextChannel).ToArray();
|
||||||
|
|
||||||
// Export
|
// Export
|
||||||
await ExportAsync(console, channels);
|
await ExportAsync(console, textChannels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Threading.Tasks;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using CliFx.Attributes;
|
using CliFx.Attributes;
|
||||||
using CliFx.Infrastructure;
|
using CliFx.Infrastructure;
|
||||||
using DiscordChatExporter.Cli.Commands.Base;
|
using DiscordChatExporter.Cli.Commands.Base;
|
||||||
|
@ -20,9 +21,10 @@ namespace DiscordChatExporter.Cli.Commands
|
||||||
// Get channel metadata
|
// Get channel metadata
|
||||||
await console.Output.WriteLineAsync("Fetching channels...");
|
await console.Output.WriteLineAsync("Fetching channels...");
|
||||||
var channels = await Discord.GetGuildChannelsAsync(GuildId);
|
var channels = await Discord.GetGuildChannelsAsync(GuildId);
|
||||||
|
var textChannels = channels.Where(c => c.IsTextChannel).ToArray();
|
||||||
|
|
||||||
// Export
|
// Export
|
||||||
await ExportAsync(console, channels);
|
await ExportAsync(console, textChannels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,7 +19,13 @@ namespace DiscordChatExporter.Cli.Commands
|
||||||
{
|
{
|
||||||
var channels = await Discord.GetGuildChannelsAsync(GuildId);
|
var channels = await Discord.GetGuildChannelsAsync(GuildId);
|
||||||
|
|
||||||
foreach (var channel in channels.OrderBy(c => c.Category.Position).ThenBy(c => c.Name))
|
var textChannels = channels
|
||||||
|
.Where(c => c.IsTextChannel)
|
||||||
|
.OrderBy(c => c.Category.Position)
|
||||||
|
.ThenBy(c => c.Name)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
foreach (var channel in textChannels)
|
||||||
{
|
{
|
||||||
// Channel ID
|
// Channel ID
|
||||||
await console.Output.WriteAsync(channel.Id.ToString());
|
await console.Output.WriteAsync(channel.Id.ToString());
|
||||||
|
|
|
@ -16,7 +16,13 @@ namespace DiscordChatExporter.Cli.Commands
|
||||||
{
|
{
|
||||||
var channels = await Discord.GetGuildChannelsAsync(Guild.DirectMessages.Id);
|
var channels = await Discord.GetGuildChannelsAsync(Guild.DirectMessages.Id);
|
||||||
|
|
||||||
foreach (var channel in channels.OrderBy(c => c.Name))
|
var textChannels = channels
|
||||||
|
.Where(c => c.IsTextChannel)
|
||||||
|
.OrderBy(c => c.Category.Position)
|
||||||
|
.ThenBy(c => c.Name)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
foreach (var channel in textChannels)
|
||||||
{
|
{
|
||||||
// Channel ID
|
// Channel ID
|
||||||
await console.Output.WriteAsync(channel.Id.ToString());
|
await console.Output.WriteAsync(channel.Id.ToString());
|
||||||
|
|
|
@ -21,6 +21,8 @@ namespace DiscordChatExporter.Core.Discord.Data
|
||||||
ChannelType.GuildNews or
|
ChannelType.GuildNews or
|
||||||
ChannelType.GuildStore;
|
ChannelType.GuildStore;
|
||||||
|
|
||||||
|
public bool IsVoiceChannel => !IsTextChannel;
|
||||||
|
|
||||||
public Snowflake GuildId { get; }
|
public Snowflake GuildId { get; }
|
||||||
|
|
||||||
public ChannelCategory Category { get; }
|
public ChannelCategory Category { get; }
|
||||||
|
|
|
@ -142,10 +142,6 @@ namespace DiscordChatExporter.Core.Discord
|
||||||
|
|
||||||
var channel = Channel.Parse(channelJson, category, position);
|
var channel = Channel.Parse(channelJson, category, position);
|
||||||
|
|
||||||
// We are only interested in text channels
|
|
||||||
if (!channel.IsTextChannel)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
position++;
|
position++;
|
||||||
|
|
||||||
yield return channel;
|
yield return channel;
|
||||||
|
|
|
@ -99,11 +99,12 @@ namespace DiscordChatExporter.Core.Exporting.Writers.MarkdownVisitors
|
||||||
else if (mention.Kind == MentionKind.Channel)
|
else if (mention.Kind == MentionKind.Channel)
|
||||||
{
|
{
|
||||||
var channel = mentionId?.Pipe(_context.TryGetChannel);
|
var channel = mentionId?.Pipe(_context.TryGetChannel);
|
||||||
|
var symbol = channel?.IsVoiceChannel == true ? "🔊" : "#";
|
||||||
var name = channel?.Name ?? "deleted-channel";
|
var name = channel?.Name ?? "deleted-channel";
|
||||||
|
|
||||||
_buffer
|
_buffer
|
||||||
.Append("<span class=\"mention\">")
|
.Append("<span class=\"mention\">")
|
||||||
.Append("#").Append(HtmlEncode(name))
|
.Append(symbol).Append(HtmlEncode(name))
|
||||||
.Append("</span>");
|
.Append("</span>");
|
||||||
}
|
}
|
||||||
else if (mention.Kind == MentionKind.Role)
|
else if (mention.Kind == MentionKind.Role)
|
||||||
|
|
|
@ -43,6 +43,10 @@ namespace DiscordChatExporter.Core.Exporting.Writers.MarkdownVisitors
|
||||||
var name = channel?.Name ?? "deleted-channel";
|
var name = channel?.Name ?? "deleted-channel";
|
||||||
|
|
||||||
_buffer.Append($"#{name}");
|
_buffer.Append($"#{name}");
|
||||||
|
|
||||||
|
// Voice channel marker
|
||||||
|
if (channel?.IsVoiceChannel == true)
|
||||||
|
_buffer.Append(" [voice]");
|
||||||
}
|
}
|
||||||
else if (mention.Kind == MentionKind.Role)
|
else if (mention.Kind == MentionKind.Role)
|
||||||
{
|
{
|
||||||
|
|
|
@ -135,7 +135,7 @@ namespace DiscordChatExporter.Core.Markdown.Parsing
|
||||||
|
|
||||||
// Capture <#123456>
|
// Capture <#123456>
|
||||||
private static readonly IMatcher<MarkdownNode> ChannelMentionNodeMatcher = new RegexMatcher<MarkdownNode>(
|
private static readonly IMatcher<MarkdownNode> ChannelMentionNodeMatcher = new RegexMatcher<MarkdownNode>(
|
||||||
new Regex("<#(\\d+)>", DefaultRegexOptions),
|
new Regex("<#!?(\\d+)>", DefaultRegexOptions),
|
||||||
(_, m) => new MentionNode(m.Groups[1].Value, MentionKind.Channel)
|
(_, m) => new MentionNode(m.Groups[1].Value, MentionKind.Channel)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,8 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||||
var guildChannelMap = new Dictionary<Guild, IReadOnlyList<Channel>>();
|
var guildChannelMap = new Dictionary<Guild, IReadOnlyList<Channel>>();
|
||||||
await foreach (var guild in discord.GetUserGuildsAsync())
|
await foreach (var guild in discord.GetUserGuildsAsync())
|
||||||
{
|
{
|
||||||
guildChannelMap[guild] = await discord.GetGuildChannelsAsync(guild.Id);
|
var channels = await discord.GetGuildChannelsAsync(guild.Id);
|
||||||
|
guildChannelMap[guild] = channels.Where(c => c.IsTextChannel).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
GuildChannelMap = guildChannelMap;
|
GuildChannelMap = guildChannelMap;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue