mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-03 08:39:14 +00:00
30 lines
847 B
C#
30 lines
847 B
C#
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using CliFx;
|
|
using CliFx.Attributes;
|
|
using DiscordChatExporter.Core.Services;
|
|
|
|
namespace DiscordChatExporter.Cli.Commands
|
|
{
|
|
[Command("guilds", Description = "Get the list of accessible guilds.")]
|
|
public class GetGuildsCommand : TokenCommandBase
|
|
{
|
|
public GetGuildsCommand(DataService dataService)
|
|
: base(dataService)
|
|
{
|
|
}
|
|
|
|
public override async ValueTask ExecuteAsync(IConsole console)
|
|
{
|
|
// Get guilds
|
|
var guilds = await DataService.GetUserGuildsAsync(Token);
|
|
|
|
// Order guilds
|
|
guilds = guilds.OrderBy(g => g.Name).ToArray();
|
|
|
|
// Print result
|
|
foreach (var guild in guilds)
|
|
console.Output.WriteLine($"{guild.Id} | {guild.Name}");
|
|
}
|
|
}
|
|
} |