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.

RestVoiceChannel.cs 2.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Discord.Audio;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7. using Model = Discord.API.Channel;
  8. namespace Discord.Rest
  9. {
  10. [DebuggerDisplay(@"{DebuggerDisplay,nq}")]
  11. public class RestVoiceChannel : RestGuildChannel, IVoiceChannel, IRestAudioChannel
  12. {
  13. public int Bitrate { get; private set; }
  14. public int? UserLimit { get; private set; }
  15. internal RestVoiceChannel(BaseDiscordClient discord, IGuild guild, ulong id)
  16. : base(discord, guild, id)
  17. {
  18. }
  19. internal new static RestVoiceChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
  20. {
  21. var entity = new RestVoiceChannel(discord, guild, model.Id);
  22. entity.Update(model);
  23. return entity;
  24. }
  25. internal override void Update(Model model)
  26. {
  27. base.Update(model);
  28. Bitrate = model.Bitrate.Value;
  29. UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null;
  30. }
  31. public async Task ModifyAsync(Action<VoiceChannelProperties> func, RequestOptions options = null)
  32. {
  33. var model = await ChannelHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false);
  34. Update(model);
  35. }
  36. private string DebuggerDisplay => $"{Name} ({Id}, Voice)";
  37. //IAudioChannel
  38. Task<IAudioClient> IAudioChannel.ConnectAsync(bool selfDeaf, bool selfMute, bool external) { throw new NotSupportedException(); }
  39. Task IAudioChannel.DisconnectAsync() { throw new NotSupportedException(); }
  40. //IGuildChannel
  41. Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
  42. => Task.FromResult<IGuildUser>(null);
  43. IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
  44. => AsyncEnumerable.Empty<IReadOnlyCollection<IGuildUser>>();
  45. }
  46. }