You can not select more than 25 topics
Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using Discord.Rest;
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Linq;
-
- namespace Discord
- {
- /// <summary>
- /// Gets or creates a guild to use for testing.
- /// </summary>
- public class RestGuildFixture : DiscordRestClientFixture
- {
- public RestGuild Guild { get; private set; }
-
- public RestGuildFixture() : base()
- {
- var guilds = Client.GetGuildsAsync().Result.Where(x => x.OwnerId == Client.CurrentUser.Id).ToList();
- if (guilds.Count == 0)
- {
- // create a new guild if none exists already
- var region = Client.GetOptimalVoiceRegionAsync().Result;
- Guild = Client.CreateGuildAsync("DNET INTEGRATION TEST", region).Result;
- RemoveAllChannels();
- }
- else
- {
- // get the first one if there is a guild already created
- Guild = guilds.First();
- }
- }
-
- /// <summary>
- /// Removes all channels in the guild.
- /// </summary>
- private void RemoveAllChannels()
- {
- foreach (var channel in Guild.GetChannelsAsync().Result)
- {
- channel.DeleteAsync().Wait();
- }
- }
- }
- }
|