Added implementation for guild and channel selection with identified strings
This commit is contained in:
parent
801a0da615
commit
5e940c09bd
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
@ -8,7 +9,9 @@ using Discord;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using DML.AppCore.Classes;
|
using DML.AppCore.Classes;
|
||||||
using DML.Application.Classes;
|
using DML.Application.Classes;
|
||||||
|
using DML.Application.Helper;
|
||||||
using DML.Client;
|
using DML.Client;
|
||||||
|
using static DML.Client.DMLClient;
|
||||||
using static SweetLib.Utils.Logger.Logger;
|
using static SweetLib.Utils.Logger.Logger;
|
||||||
|
|
||||||
namespace DML.Application
|
namespace DML.Application
|
||||||
|
@ -57,7 +60,9 @@ namespace DML.Application
|
||||||
if (cbGuild.Items.Count == 0)
|
if (cbGuild.Items.Count == 0)
|
||||||
{
|
{
|
||||||
Trace("Adding guilds to component...");
|
Trace("Adding guilds to component...");
|
||||||
cbGuild.Items.AddRange(DMLClient.Client.Guilds.Where(g => g.Name != null).OrderBy(g => g.Name).Select(g => g.Name).ToArray());
|
|
||||||
|
cbGuild.Items.AddRange(DMLClient.Client.Guilds.Where(g => g.Name != null).OrderBy(g => g.Name).Select(g => new IdentifiedString<ulong>(g.Id, g.Name)).ToArray());
|
||||||
|
|
||||||
cbGuild.SelectedIndex = 0;
|
cbGuild.SelectedIndex = 0;
|
||||||
Trace("Guild component initialized.");
|
Trace("Guild component initialized.");
|
||||||
}
|
}
|
||||||
|
@ -153,7 +158,7 @@ namespace DML.Application
|
||||||
UseWaitCursor = true;
|
UseWaitCursor = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var guild = FindServerByName(cbGuild.Text);
|
var guild = FindServerById(((IdentifiedString<ulong>)cbGuild.SelectedItem).Id);
|
||||||
|
|
||||||
if (guild != null)
|
if (guild != null)
|
||||||
{
|
{
|
||||||
|
@ -161,7 +166,9 @@ namespace DML.Application
|
||||||
cbChannel.Items.Clear();
|
cbChannel.Items.Clear();
|
||||||
|
|
||||||
Trace("Adding new channels...");
|
Trace("Adding new channels...");
|
||||||
cbChannel.Items.AddRange(guild.TextChannels.OrderBy(c => c.Position).Select(c => c.Name).ToArray());
|
|
||||||
|
cbChannel.Items.AddRange(guild.TextChannels.OrderBy(c => c.Position).Select(c => new IdentifiedString<ulong>(c.Id, c.Name)).ToArray());
|
||||||
|
|
||||||
Trace($"Added {cbChannel.Items.Count} channels.");
|
Trace($"Added {cbChannel.Items.Count} channels.");
|
||||||
|
|
||||||
cbChannel.SelectedIndex = 0;
|
cbChannel.SelectedIndex = 0;
|
||||||
|
@ -183,8 +190,8 @@ namespace DML.Application
|
||||||
{
|
{
|
||||||
var job = new Job
|
var job = new Job
|
||||||
{
|
{
|
||||||
GuildId = FindServerByName(cbGuild.Text).Id,
|
GuildId = ((IdentifiedString<ulong>)cbGuild.SelectedItem).Id,
|
||||||
ChannelId = FindChannelByName(FindServerByName(cbGuild.Text), cbChannel.Text).Id
|
ChannelId = ((IdentifiedString<ulong>)cbChannel.SelectedItem).Id
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!(from j in Core.Scheduler.JobList
|
if (!(from j in Core.Scheduler.JobList
|
||||||
|
|
Loading…
Reference in a new issue