public async Task Connect(ulong targetChannelId) { this.Client.Ready += async e => { await Task.Yield(); this.Client.DebugLogger.LogMessage(LogLevel.Info, "DiscordClient", "Ready! Setting status message..", DateTime.Now); var game = new Game() { Name = "魔王降誕の儀式を幻視中", StreamType = 0 }; await this.Client.UpdateStatusAsync(game, UserStatus.Online); this.Client.DebugLogger.LogMessage(LogLevel.Info, "DiscordClient", "Discord Ready", DateTime.Now); }; this.Client.DebugLogger.LogMessage(LogLevel.Info, "DiscordClient", "Connecting", DateTime.Now); await this.Client.ConnectAsync(); this.TargetChannel = await this.Client.GetChannelAsync(targetChannelId); }
/// <summary> /// Sends a message /// </summary> /// <param name="channel">Channel to send to.</param> /// <param name="content">Message content to send.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The Discord Message that was sent.</returns> /// <exception cref="Exceptions.UnauthorizedException">Thrown when the client does not have the <see cref="Permissions.SendMessages"/> permission.</exception> /// <exception cref="Exceptions.NotFoundException">Thrown when the channel does not exist.</exception> /// <exception cref="Exceptions.BadRequestException">Thrown when an invalid parameter was provided.</exception> /// <exception cref="Exceptions.ServerErrorException">Thrown when Discord is unable to process the request.</exception> public Task <DiscordMessage> SendMessageAsync(DiscordChannel channel, string content = null, DiscordEmbed embed = null) => this.ApiClient.CreateMessageAsync(channel.Id, null, null, embed, null);
public DiscordVoiceClient(DiscordClient parentClient, DiscordVoiceConfig config, DiscordChannel channel) { _parent = parentClient; VoiceConfig = config; Channel = channel; InitializeOpusEncoder(); }
/// <summary> /// Creates a mention for specified channel. /// </summary> /// <param name="channel">Channel to mention.</param> /// <returns>Formatted mention.</returns> public static string Mention(DiscordChannel channel) => $"<#{channel.Id.ToString(CultureInfo.InvariantCulture)}>";
/// <summary> /// Sends a message /// </summary> /// <param name="channel">Channel to send to.</param> /// <param name="builder">The Discord Mesage builder.</param> /// <returns>The Discord Message that was sent.</returns> /// <exception cref="Exceptions.UnauthorizedException">Thrown when the client does not have the <see cref="Permissions.SendMessages"/> permission if TTS is false and <see cref="Permissions.SendTtsMessages"/> if TTS is true.</exception> /// <exception cref="Exceptions.NotFoundException">Thrown when the channel does not exist.</exception> /// <exception cref="Exceptions.BadRequestException">Thrown when an invalid parameter was provided.</exception> /// <exception cref="Exceptions.ServerErrorException">Thrown when Discord is unable to process the request.</exception> public Task <DiscordMessage> SendMessageAsync(DiscordChannel channel, DiscordMessageBuilder builder) => this.ApiClient.CreateMessageAsync(channel.Id, builder);