### Start Lavalink Server Source: https://docs.dcs.aitsys.dev/articles/modules/audio/lavalink_v4/setup Execute this command in your terminal from the Lavalink directory to start the server. Ensure Java is installed and accessible. ```bash java -jar Lavalink.jar ``` -------------------------------- ### SampleHostname Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordVoiceRegion.SampleHostname.html Gets an example server hostname for this region. ```APIDOC ## Property SampleHostname ### Description Gets an example server hostname for this region. ### Property Value string ``` -------------------------------- ### Complete Lavalink Bot Main File Example Source: https://docs.dcs.aitsys.dev/articles/modules/audio/lavalink_v4/configuration A full example of a bot's main file demonstrating the setup, configuration, and connection to both Discord and Lavalink. Ensure the Lavalink connection happens after the Discord client connects. ```csharp using System.Threading.Tasks; using Microsoft.Extensions.Logging; using DisCatSharp; using DisCatSharp.Net; using DisCatSharp.Lavalink; namespace FirstLavalinkBot; public class Program { public static DiscordClient Discord { get; internal set; } public static void Main(string[] args = null) { MainAsync(args).ConfigureAwait(false).GetAwaiter().GetResult(); } public static async Task MainAsync(string[] args) { Discord = new DiscordClient(new DiscordConfiguration { Token = "", TokenType = TokenType.Bot, MinimumLogLevel = LogLevel.Debug }); var endpoint = new ConnectionEndpoint { Hostname = "127.0.0.1", // From your server configuration. Port = 2333 // From your server configuration }; var lavalinkConfig = new LavalinkConfiguration { Password = "youshallnotpass", // From your server configuration. RestEndpoint = endpoint, SocketEndpoint = endpoint }; var lavalink = Discord.UseLavalink(); await Discord.ConnectAsync(); await lavalink.ConnectAsync(lavalinkConfig); // Make sure this is after Discord.ConnectAsync(). await Task.Delay(-1); } } ``` -------------------------------- ### Setup(DiscordClient) Source: https://docs.dcs.aitsys.dev/api/DisCatSharp.Interactivity/DisCatSharp.Interactivity.InteractivityExtension.Setup.html Setups the Interactivity Extension for the Discord client. ```APIDOC ## Setup(DiscordClient) ### Description Setups the Interactivity Extension. ### Method protected override void ### Parameters #### Parameters - **client** (DiscordClient) - Required - The Discord client instance to set up the extension with. ``` -------------------------------- ### Complete Main Method Configuration Source: https://docs.dcs.aitsys.dev/articles/modules/commandsnext/intro This is a complete example of the MainAsync method, including Discord client setup, CommandsNext configuration with prefixes, command module registration, and connecting to Discord. ```csharp internal static async Task MainAsync() { var discord = new DiscordClient(new DiscordConfiguration()); var commands = discord.UseCommandsNext(new CommandsNextConfiguration() { StringPrefixes = new List() { "!" } }); commands.RegisterCommands(); await discord.ConnectAsync(); await Task.Delay(-1); } ``` -------------------------------- ### Basic ApplicationCommands Module Setup Source: https://docs.dcs.aitsys.dev/articles/modules/audio/lavalink_v4/commands Define a basic class that inherits from ApplicationCommandsModule to start using application commands. ```csharp using DisCatSharp.ApplicationCommands; namespace FirstLavalinkBot; public class MyFirstLavalinkCommands : ApplicationCommandsModule { } ``` -------------------------------- ### Download .NET Install Script Source: https://docs.dcs.aitsys.dev/articles/misc/hosting Download the official .NET installation script using Wget and make it executable. This script simplifies the .NET installation process. ```bash wget https://dot.net/v1/dotnet-install.sh -O dotnet.sh && chmod +x ./dotnet.sh ``` -------------------------------- ### Integrate Serilog with DisCatSharp Source: https://docs.dcs.aitsys.dev/articles/topics/logging/third_party This complete example shows how to set up Serilog and integrate it with DisCatSharp by configuring the DiscordClient. Ensure Serilog and Serilog.Extensions.Logging are installed. ```csharp using Microsoft.Extensions.Logging; using Serilog; public async Task MainAsync() { Log.Logger = new LoggerConfiguration() .WriteTo.Console() .CreateLogger(); var logFactory = new LoggerFactory().AddSerilog(); var discord = new DiscordClient(new DiscordConfiguration() { LoggerFactory = logFactory }); } ``` -------------------------------- ### Install .NET 9 Source: https://docs.dcs.aitsys.dev/articles/misc/hosting Execute the downloaded script to install the .NET 9 SDK. This command installs the specified .NET channel. ```bash ./dotnet.sh --channel 9.0 ``` -------------------------------- ### Enabled Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordServerGuide.Enabled.html Gets whether the server guide is enabled. ```APIDOC ## Property Enabled ### Description Gets whether the server guide is enabled. ### Property Value - **Enabled** (bool) - Indicates if the server guide is enabled. ``` -------------------------------- ### Setup(DiscordClient) Source: https://docs.dcs.aitsys.dev/api/DisCatSharp.CommandsNext/DisCatSharp.CommandsNext.CommandsNextExtension.Setup.html This method is part of the internal setup process for CommandsNext and should not be invoked directly by users. It is protected and intended for framework use. ```APIDOC ## Setup(DiscordClient) ### Description This method is part of the internal setup process for CommandsNext and should not be invoked directly by users. It is protected and intended for framework use. ### Method protected override void Setup(DiscordClient client) ### Parameters #### client - **client** (DiscordClient) - The Discord client instance to set up CommandsNext with. ### Exceptions - **InvalidOperationException** - Thrown if the setup is attempted in an invalid state. ``` -------------------------------- ### Install and Use Screen for Background Processes Source: https://docs.dcs.aitsys.dev/articles/misc/hosting Install the `screen` utility to keep your bot running in the background even after closing Termux. Start a new screen session, run your bot, and detach. ```bash apt install screen -y screen -S mybot dotnet run ``` -------------------------------- ### Install Git and Wget Source: https://docs.dcs.aitsys.dev/articles/misc/hosting Install essential command-line tools, Git for version control and Wget for downloading files, within the Debian VM. ```bash apt install git wget -y ``` -------------------------------- ### StartedAt Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.EventArgs.TypingStartEventArgs.StartedAt.html Gets the date and time at which the user started typing. ```APIDOC ## StartedAt Property ### Description Gets the date and time at which the user started typing. ### Property Value DateTimeOffset ``` -------------------------------- ### CommandsNext Voice Integration Example Source: https://docs.dcs.aitsys.dev/articles/modules/audio/voice/transmit Example commands for joining a voice channel, playing audio from a file, and leaving the voice channel using CommandsNext. ```csharp [Command("join")] public static async Task JoinAsync(CommandContext ctx) { var channel = ctx.Member?.VoiceState?.Channel ?? throw new InvalidOperationException("Join a voice channel first."); await channel.ConnectAsync(); } [Command("play")] public static async Task PlayAsync(CommandContext ctx, string path) { var voice = ctx.Client.GetVoice() ?? throw new InvalidOperationException("Voice is not enabled."); var connection = voice.GetConnection(ctx.Guild) ?? throw new InvalidOperationException("Bot is not connected."); await PlayFileAsync(connection, path, CancellationToken.None); } [Command("leave")] public static Task LeaveAsync(CommandContext ctx) { var connection = ctx.Client.GetVoice()?.GetConnection(ctx.Guild); connection?.Disconnect(); return Task.CompletedTask; } ``` -------------------------------- ### List Available Distributions Source: https://docs.dcs.aitsys.dev/articles/misc/hosting Verify the installation of proot-distro by listing the available Linux distributions that can be installed. 'debian' should be among them. ```bash proot-distro list ``` -------------------------------- ### TypingStartEventArgs.StartedAt Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.EventArgs.TypingStartEventArgs.StartedAt.html Gets the date and time at which the user started typing. ```csharp public DateTimeOffset StartedAt { get; } ``` -------------------------------- ### Lavalink Play Command Example Source: https://docs.dcs.aitsys.dev/articles/modules/audio/lavalink_v4/queue A complete slash command example for playing music, handling track loading, queueing, and playback. ```csharp [SlashCommand("play", "Play a track")] public async Task PlayAsync(InteractionContext ctx, [Option("query", "The query to search for")] string query) { await ctx.CreateResponseAsync(InteractionResponseType.DeferredChannelMessageWithSource); if (ctx.Member.VoiceState == null || ctx.Member.VoiceState.Channel == null) { await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent("You are not in a voice channel.")); return; } var lavalink = ctx.Client.GetLavalink(); var guildPlayer = lavalink.GetGuildPlayer(ctx.Guild); if (guildPlayer == null) { await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent("Lavalink is not connected.")); return; } var loadResult = await guildPlayer.LoadTracksAsync(LavalinkSearchType.Youtube, query); if (loadResult.LoadType == LavalinkLoadResultType.Empty || loadResult.LoadType == LavalinkLoadResultType.Error) { await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent($"Track search failed for {query}.")); return; } LavalinkTrack track = loadResult.LoadType switch { LavalinkLoadResultType.Track => loadResult.GetResultAs(), LavalinkLoadResultType.Playlist => loadResult.GetResultAs().Tracks.First(), LavalinkLoadResultType.Search => loadResult.GetResultAs>().First(), _ => throw new InvalidOperationException("Unexpected load result type.") }; if (guildPlayer.CurrentTrack == null) { guildPlayer.AddToQueue(track); guildPlayer.PlayQueue(); await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent($"Now playing {query}!")); } else { guildPlayer.AddToQueue(track); await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent($"Track added to queue {track.Info.Title}!")); } } ``` -------------------------------- ### GuildInstall Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordIntegrationTypesConfig.GuildInstall.html Gets or sets the guild install configuration. This property is disabled when it is null and defaults to null. ```APIDOC ## Property GuildInstall ### Description Gets or sets the guild install configuration. Disabled when null. Defaults to null. ### Type DiscordApplicationIntegrationTypeConfiguration? ``` -------------------------------- ### Clone Example Repository Source: https://docs.dcs.aitsys.dev/articles/misc/hosting Clone the DisCatSharp.Examples repository from GitHub to obtain sample code. This is a prerequisite for deploying example bots. ```bash git clone https://github.com/Aiko-IT-Systems/DisCatSharp.Examples/ cd DisCatSharp.Examples ``` -------------------------------- ### IntegrationType Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp.Hosting.AspNetCore/DisCatSharp.Hosting.AspNetCore.Ingress.DiscordWebhookApplicationAuthorizedEventData.IntegrationType.html Gets the authorization installation context when Discord provided it. ```APIDOC ## Property IntegrationType ### Description Gets the authorization installation context when Discord provided it. ### Property Value ApplicationCommandIntegrationTypes? ``` -------------------------------- ### Lavalink v4 Startup Log Output Source: https://docs.dcs.aitsys.dev/articles/modules/audio/lavalink_v4/setup This is an example of the expected log output when Lavalink v4 starts successfully. It confirms the version, loaded plugins, and successful initialization. ```log INFO 1 --- [Lavalink] [ main] lavalink.server.Launcher : Starting Launcher v4.0.8 using Java 18.0.2.1 with PID 1 (/opt/Lavalink/Lavalink.jar started by lavalink in /opt/Lavalink) INFO 1 --- [Lavalink] [ main] lavalink.server.Launcher : No active profile set, falling back to 1 default profile: "default" INFO 1 --- [Lavalink] [ main] l.server.bootstrap.PluginManager : Found plugin 'lavasearch-plugin' version 1.0.0 INFO 1 --- [Lavalink] [ main] l.server.bootstrap.PluginManager : Found plugin 'lavasrc-plugin' version 4.3.0 INFO 1 --- [Lavalink] [ main] l.server.bootstrap.PluginManager : Found plugin 'sponsorblock-plugin' version 3.0.0 INFO 1 --- [Lavalink] [ main] l.server.bootstrap.PluginManager : Found plugin 'youtube-plugin' version 1.11.3 INFO 1 --- [Lavalink] [ main] l.server.bootstrap.PluginManager : Loaded lavasearch-plugin-1.0.0.jar (20 classes) INFO 1 --- [Lavalink] [ main] l.server.bootstrap.PluginManager : Loaded lavasrc-plugin-4.3.0.jar (168 classes) INFO 1 --- [Lavalink] [ main] l.server.bootstrap.PluginManager : Loaded sponsorblock-plugin-3.0.0.jar (90 classes) INFO 1 --- [Lavalink] [ main] l.server.bootstrap.PluginManager : Loaded youtube-plugin-1.11.3.jar (16 classes) INFO 1 --- [Lavalink] [ main] lavalink.server.Launcher : Started Launcher in 2.194 seconds (process running for 2.752) INFO 1 --- [Lavalink] [ main] lavalink.server.Launcher : . _ _ _ _ __ _ _ /\ | | __ ___ ____ _| (_)_ __ | | __\ \ \ \ ( ( )| |/ _` \ \ / / _` | | | '_ \| |/ / \ \ \ \ \/ | | (_| |\ V / (_| | | | | | | < ) ) ) ) ' |_|\__,_| \_/ \__,_|_|_|_| |_|_|\_\ / / / / =========================================/_/_/_/ Version: 4.0.8 Build time: 20.09.2024 20:20:10 UTC Branch HEAD Commit: 2946608 Commit time: 20.09.2024 20:17:58 UTC JVM: 18.0.2.1 Lavaplayer 2.2.2 INFO 1 --- [Lavalink] [ main] lavalink.server.Launcher : No active profile set, falling back to 1 default profile: "default" WARN 1 --- [Lavalink] [ main] io.undertow.websockets.jsr : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used INFO 1 --- [Lavalink] [ main] io.undertow.servlet : Initializing Spring embedded WebApplicationContext INFO 1 --- [Lavalink] [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 712 ms INFO 1 --- [Lavalink] [ main] c.g.t.lavasrc.plugin.LavaSrcPlugin : Loading LavaSrc plugin... INFO 1 --- [Lavalink] [ main] c.g.t.lavasrc.plugin.LavaSrcPlugin : Registering Youtube Source audio source manager... INFO 1 --- [Lavalink] [ main] c.g.t.lavasrc.plugin.LavaSrcPlugin : Registering Spotify search manager... INFO 1 --- [Lavalink] [ main] c.g.t.lavasrc.plugin.LavaSrcPlugin : Registering Youtube search manager... INFO 1 --- [Lavalink] [ main] c.g.t.lavasrc.plugin.LavaSrcPlugin : Registering Yandex Music search manager... INFO 1 --- [Lavalink] [ main] c.s.d.l.tools.GarbageCollectionMonitor : GC monitoring enabled, reporting results every 2 minutes. INFO 1 --- [Lavalink] [ main] c.g.t.lavasrc.plugin.LavaSrcPlugin : Registering Spotify audio source manager... INFO 1 --- [Lavalink] [ main] c.g.t.lavasrc.plugin.LavaSrcPlugin : Registering Yandex Music audio source manager... INFO 1 --- [Lavalink] [ main] c.g.t.lavasrc.plugin.LavaSrcPlugin : Registering Flowery TTS audio source manager... WARN 1 --- [Lavalink] [ main] d.l.youtube.plugin.ClientProvider : Failed to resolve M_WEB into a Client INFO 1 --- [Lavalink] [ main] d.l.youtube.plugin.YoutubePluginLoader : YouTube source initialised with clients: WEB, WEB_REMIX, WEB_EMBEDDED_PLAYER, ANDROID_VR, TVHTML5, TVHTML5_SIMPLY_EMBEDDED_PLAYER INFO 1 --- [Lavalink] [ main] d.l.youtube.http.YoutubeOauth2Handler : ================================================== INFO 1 --- [Lavalink] [ main] d.l.youtube.http.YoutubeOauth2Handler : !!! DO NOT AUTHORISE WITH YOUR MAIN ACCOUNT, USE A BURNER !!! ``` -------------------------------- ### AutoStart Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordScheduledEvent.AutoStart.html Gets whether the scheduled event auto starts. ```APIDOC ## Property AutoStart ### Description Gets whether the scheduled event auto starts. ### Property Value - **AutoStart** (bool) - Indicates if the scheduled event will automatically start. ``` -------------------------------- ### Install Screen in Debian Source: https://docs.dcs.aitsys.dev/articles/misc/hosting If the `screen` command is not found, ensure you are logged into Debian and install it using `apt`. ```bash apt install screen -y ``` -------------------------------- ### Install Latest DisCatSharp Project Templates Source: https://docs.dcs.aitsys.dev/articles/getting_started/templates Use this command to install the most recent version of the DisCatSharp project templates. Ensure you have the .NET SDK installed. ```bash dotnet new --install DisCatSharp.ProjectTemplates ``` -------------------------------- ### Verify .NET Installation Source: https://docs.dcs.aitsys.dev/articles/misc/hosting Check if .NET has been installed correctly by running the 'dotnet --version' command. This should display the installed .NET version (e.g., 9.x.x). ```bash dotnet --version ``` -------------------------------- ### Get Installed PCM Filters Source: https://docs.dcs.aitsys.dev/api/DisCatSharp.Voice/DisCatSharp.Voice.Entities.VoiceTransmitSink.GetInstalledFilters.html Retrieves the collection of installed PCM filters, in order of their execution. This method is part of the VoiceTransmitSink class. ```csharp public IEnumerable GetInstalledFilters() ``` -------------------------------- ### StartAsync() Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.DiscordShardedClient.StartAsync.html Initializes and connects all shards. ```APIDOC ## StartAsync() ### Description Initializes and connects all shards. ### Method `public Task StartAsync()` ### Returns Task ### Exceptions - AggregateException - InvalidOperationException ``` -------------------------------- ### VoiceStartTime Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.EventArgs.VoiceChannelStartTimeUpdateEventArgs.VoiceStartTime.html Gets the new voice start time. This property returns a DateTimeOffset value representing the time the voice channel started. ```APIDOC ## VoiceStartTime Property ### Description Gets the new voice start time. ### Property Value DateTimeOffset? ``` -------------------------------- ### VoiceStartTime Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordChannel.VoiceStartTime.html Gets the voice channel start time. This property returns a nullable DateTimeOffset representing the time the voice channel was started. ```APIDOC ## Property VoiceStartTime ### Description Gets the voice channel start time. ### Property Value DateTimeOffset? ### Example ```csharp DateTimeOffset? startTime = channel.VoiceStartTime; ``` ``` -------------------------------- ### DiscordOnboardingPrompt Constructor Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordOnboardingPrompt.-ctor.html Constructs a new onboarding prompt with the specified parameters. ```APIDOC ## DiscordOnboardingPrompt Constructor ### Description Constructs a new onboarding prompt. ### Method Signature `public DiscordOnboardingPrompt(ulong id, string title, List options, bool singleSelect = false, bool required = true, bool inOnboarding = true, PromptType type = PromptType.MultipleChoice)` ### Parameters #### Path Parameters - **id** (ulong) - The prompt ID. Starts at `0` unless provided by Discord. - **title** (string) - The prompt title. - **options** (List) - The prompt options. - **singleSelect** (bool) - Whether the prompt is single select. Defaults to false. - **required** (bool) - Whether the prompt is required. Defaults to true. - **inOnboarding** (bool) - Whether the prompt is shown in onboarding. Defaults to true. - **type** (PromptType) - The prompt type. Defaults to MultipleChoice. ``` -------------------------------- ### DiscordMessage.Thread Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordMessage.Thread.html Gets the thread that was started from this message. If you're looking to get the actual thread channel this message was send in, call Channel and convert it to a DiscordThreadChannel. ```APIDOC ## Property Thread ### Description Gets the thread that was started from this message. ##### warning If you're looking to get the actual thread channel this message was send in, call Channel and convert it to a DiscordThreadChannel. ### Signature ```csharp [JsonIgnore] public DiscordThreadChannel Thread { get; } ``` ### Property Value Returns `DiscordThreadChannel`. ``` -------------------------------- ### DiscordOnboardingPrompt Constructor Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordOnboardingPrompt.-ctor.html Constructs a new onboarding prompt. Use this to create a DiscordOnboardingPrompt instance with specified properties. ```csharp public DiscordOnboardingPrompt(ulong id, string title, List options, bool singleSelect = false, bool required = true, bool inOnboarding = true, PromptType type = PromptType.MultipleChoice) ``` -------------------------------- ### Guild Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp.Lavalink/DisCatSharp.Lavalink.EventArgs.LavalinkTrackStartedEventArgs.Guild.html Gets the guild where the Lavalink track started playing. ```APIDOC ## Guild Property ### Description Gets the guild where the Lavalink track started playing. ### Property Value `DiscordGuild` - The guild object. ### Example ```csharp public DiscordGuild Guild { get; } ``` ``` -------------------------------- ### DiscordOnboarding.Prompts Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordOnboarding.Prompts.html Retrieves the list of onboarding prompts for a Discord server. ```APIDOC ## Property Prompts ### Description Gets the onboarding prompts. ### Property Value `List` - A list of DiscordOnboardingPrompt objects representing the prompts. ### Example ```csharp // Assuming 'guild' is a DiscordGuild object var prompts = guild.Onboarding.Prompts; ``` ``` -------------------------------- ### Full Discord Configuration Example Source: https://docs.dcs.aitsys.dev/articles/topics/configuration Demonstrates a comprehensive configuration for Discord client with nested properties for API, Gateway, Rest, Cache, Logging, Diagnostics, and Telemetry. ```csharp var config = new DiscordConfiguration { Token = "your-token", TokenType = TokenType.Bot, Intents = DiscordIntents.AllUnprivileged | DiscordIntents.MessageContents, Api = { Channel = ApiChannel.Stable, Locale = DiscordLocales.AMERICAN_ENGLISH }, Gateway = { AutoReconnect = true, ShardCount = 1, CompressionLevel = GatewayCompressionLevel.Stream, Advanced = { DispatchMode = GatewayDispatchMode.ConcurrentHandlers, HeartbeatZombieThreshold = 5 } }, Rest = { RequestTimeout = TimeSpan.FromSeconds(20), Advanced = { MaxRetries = 5, CircuitBreakerThreshold = 10 } }, Cache = { MessageCacheSize = 1024, AlwaysCacheMembers = true }, Logging = { MinimumLogLevel = LogLevel.Information }, Diagnostics = { UpdateChecks = { Mode = VersionCheckMode.NuGet } }, Telemetry = { EnableSentry = true, AttachUserInfo = true } }; ``` -------------------------------- ### ScheduledStartTime Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordScheduledEvent.ScheduledStartTime.html Gets the scheduled start time of the scheduled event. ```APIDOC ## ScheduledStartTime Property ### Description Gets the scheduled start time of the scheduled event. ### Property Value DateTimeOffset? ### Code Example ```csharp [JsonIgnore] public DateTimeOffset? ScheduledStartTime { get; } ``` ``` -------------------------------- ### Install Opus and Libsodium on Debian/Ubuntu Source: https://docs.dcs.aitsys.dev/articles/modules/audio/voice/prerequisites If not using packaged natives, install the Opus and Libsodium libraries on Debian/Ubuntu systems using apt-get. ```bash sudo apt-get install libopus0 libopus-dev sudo apt-get install libsodium23 libsodium-dev ``` -------------------------------- ### Install DisCatSharp NuGet Packages Source: https://docs.dcs.aitsys.dev/articles/modules/audio/lavalink_v4/bridge Install the necessary DisCatSharp packages for Lavalink and Voice support, including the native components. ```xml ``` -------------------------------- ### DiscordSku.Price Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordSku.Price.html Gets the sku price. ```APIDOC ## Property Price ### Description Gets the sku price. ### Property Value SkuPrice ``` -------------------------------- ### Guild Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp.Hosting.AspNetCore/DisCatSharp.Hosting.AspNetCore.Ingress.DiscordWebhookApplicationAuthorizedEventData.Guild.html Gets the guild the application was authorized for when the install target was a guild. ```APIDOC ## Guild Property ### Description Gets the guild the application was authorized for when the install target was a guild. ### Property Value DiscordWebhookAuthorizedGuild ``` -------------------------------- ### DiscordOnboardingPrompt.Title Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordOnboardingPrompt.html Gets the title of the onboarding prompt. ```APIDOC ## Property Title ### Description Gets the title. ### Property Value string ``` -------------------------------- ### Permissions Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordOAuth2InstallParams.Permissions.html Gets or sets the permissions for the Discord OAuth2 installation. This property is nullable. ```APIDOC ## Property Permissions ### Description Gets or sets the permissions. ### Property Value Permissions? ### Code Example ```csharp [JsonProperty("permissions", NullValueHandling = NullValueHandling.Ignore)] public Permissions? Permissions { get; } ``` ``` -------------------------------- ### WelcomeMessage Constructor Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.WelcomeMessage.-ctor.html Constructs a new welcome message for the server guide. Use `[@username]` to mention the new member. ```csharp public WelcomeMessage(ulong authorId, string message) ``` -------------------------------- ### UsernameWithDiscriminator Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordUser.UsernameWithDiscriminator.html Gets this user's username with the discriminator. Example: Discord#0000 ```APIDOC ## Property UsernameWithDiscriminator ### Description Gets this user's username with the discriminator. Example: Discord#0000 ### Signature ```csharp [JsonIgnore] public virtual string UsernameWithDiscriminator { get; } ``` ### Property Value string ``` -------------------------------- ### Permissions Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordApplicationInstallParams.Permissions.html Gets or sets the permissions for the Discord application installation. This property is optional and can be null. ```APIDOC ## Permissions Property ### Description Gets or sets the permissions for the Discord application installation. ### Property Value `Permissions?` - An optional `Permissions` object representing the granted permissions. ``` -------------------------------- ### CurrentPeriodStartsAt Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordSubscription.CurrentPeriodStartsAt.html Gets the start of the current subscription period. This property returns a nullable DateTimeOffset. ```APIDOC ## Property CurrentPeriodStartsAt ### Description Gets the start of the current subscription period. ### Property Value `DateTimeOffset?` - The start date and time of the current subscription period, or null if not applicable. ``` -------------------------------- ### Quick Start: Initialize Discord Client and Voice Module Source: https://docs.dcs.aitsys.dev/articles/modules/audio/voice/index.html Initialize the Discord client with necessary intents and enable the voice module. Ensure GuildVoiceStates intent is included for voice operations. ```csharp using DisCatSharp; using DisCatSharp.Voice; using DisCatSharp.Voice.Entities; var client = new DiscordClient(new DiscordConfiguration { Token = "...", TokenType = TokenType.Bot, Intents = DiscordIntents.AllUnprivileged | DiscordIntents.GuildVoiceStates }); client.UseVoice(new VoiceConfiguration { EnableIncoming = true, EnableDebugLogging = false }); // Later, once you have a DiscordChannel (voice/stage): VoiceConnection connection = await channel.ConnectAsync(); VoiceTransmitSink sink = connection.GetTransmitSink(); // Optional: enable extra diagnostics only for this specific connection. connection.EnableDebugLogging = true; ``` -------------------------------- ### Initialize and Use DiscordOAuth2Client Source: https://docs.dcs.aitsys.dev/articles/modules/oauth2/oauth2_client Demonstrates client registration, event handling for errors, and generating an OAuth2 URL for authorization. It also shows how to exchange an authorization code for an access token, retrieve user information, and fetch user connections. ```csharp // Client registration internal DiscordClient Client { get; private set; } // We assume you registered it somewhere internal static DiscordOAuth2Client OAuth2Client { get; private set; } internal static Uri RequestUri { get; set; } // ... OAuth2Client = new(3218382190382813, "thisistotallylegitsecret", "http://127.0.0.1:42069/oauth/"); // Event registration OAuth2Client.OAuth2ClientErrored += (sender, args) => { Client.Logger.LogError(args.Exception, "OAuth2 Client error in {Event}. Exception: {Exception}", args.EventName, args.Exception.Message); return Task.CompletedTask; }; // Some command class [SlashCommand("test_oauth2", "Tests OAuth2")] public static async Task TestOAuth2Async(InteractionContext ctx) { await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AsEphemeral().WithContent("Please wait..")); var state = OAuth2Client.GenerateState(); RequestUri = OAuth2Client.GenerateOAuth2Url("identify connections", state); await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent(RequestUri.AbsoluteUri)); } // Somewhere were you handle web stuff var uri; // we assume you got the uri in your http handler if (!OAuth2Client.ValidateState(RequestUri, uri)) // Validate the state return; var token = await OAuth2Client.ExchangeAccessTokenAsync(OAuth2Client.GetCodeFromUri(uri)); // Exchange the code for an access token var user = await OAuth2Client.GetCurrentUserAsync(token); // Get the user // Work with your token. I.e. get the users connections var connections = await OAuth2Client.GetCurrentUserConnectionsAsync(token); ``` -------------------------------- ### CurrentPeriodStartsAt Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordSubscription.CurrentPeriodStartsAt.html Gets the start of the current subscription period. This property is nullable and returns a DateTimeOffset. ```csharp [JsonIgnore] public DateTimeOffset? CurrentPeriodStartsAt { get; } ``` -------------------------------- ### Login to Debian and Verify Files Source: https://docs.dcs.aitsys.dev/articles/misc/hosting Access your Debian VM and list the root directory to confirm that your project files have been successfully moved. ```bash proot-distro login debian ls ``` -------------------------------- ### Install Debian Virtual Machine Source: https://docs.dcs.aitsys.dev/articles/misc/hosting Install the Debian Linux distribution as a virtual machine within Termux using proot-distro. This process may take time depending on your internet speed. ```bash proot-distro install debian ``` -------------------------------- ### IntegrationType Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp.Hosting.AspNetCore/DisCatSharp.Hosting.AspNetCore.Ingress.DiscordWebhookApplicationAuthorizedEventData.IntegrationType.html Gets the authorization installation context when Discord provided it. This property is nullable and ignored if null. ```csharp [JsonProperty("integration_type", NullValueHandling = NullValueHandling.Ignore)] public ApplicationCommandIntegrationTypes? IntegrationType { get; } ``` -------------------------------- ### Build .NET Project Source: https://docs.dcs.aitsys.dev/articles/misc/hosting Compile your .NET project. Ensure any old build artifacts like `bin/` and `obj/` are deleted beforehand to avoid potential issues. ```bash dotnet build ``` -------------------------------- ### DiscordApplicationInstallParams Constructor Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordApplicationInstallParams.Permissions Initializes a new instance of the DiscordApplicationInstallParams class. ```APIDOC ## DiscordApplicationInstallParams(List?, Permissions?) ### Description Initializes a new instance of the DiscordApplicationInstallParams class. ### Parameters - **scopes** (List?): An optional list of strings representing the scopes. - **permissions** (Permissions?): An optional Permissions object representing the permissions. ``` -------------------------------- ### DiscordShortlink.Guidelines Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Enums.DiscordShortlink.Guidelines.html Gets the shortlink to the guidelines. ```APIDOC ## Field Guidelines ### Description Gets the shortlink to the guidelines. ### Returns string - Your library to write discord bots in C# with focus on always providing access to the latest discord features. ``` -------------------------------- ### ScheduledStartTime Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordScheduledEvent.ScheduledStartTime.html Gets the scheduled start time of the scheduled event. This property is ignored during JSON serialization. ```csharp [JsonIgnore] public DateTimeOffset? ScheduledStartTime { get; } ``` -------------------------------- ### DiscordChannel VoiceStartTime Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordChannel.VoiceStartTime.html Gets the voice channel start time. This property is ignored during JSON serialization. ```csharp [JsonIgnore] public DateTimeOffset? VoiceStartTime { get; } ``` -------------------------------- ### StartAsync Method Signature Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.DiscordShardedClient.StartAsync.html This is the signature for the StartAsync method. It initializes and connects all shards. ```csharp public Task StartAsync() ``` -------------------------------- ### Async Main Method Setup Source: https://docs.dcs.aitsys.dev/articles/getting_started/first_bot This code sets up an asynchronous Main method required for DisCatSharp operations. It ensures that asynchronous tasks can be properly awaited. ```csharp static void Main(string[] args) { MainAsync().GetAwaiter().GetResult(); } static async Task MainAsync() { } ``` -------------------------------- ### Get DiscordServerGuide Enabled Status Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordServerGuide.Enabled.html Retrieves the boolean value indicating if the server guide is enabled. This property is read-only. ```csharp [JsonProperty("enabled", NullValueHandling = NullValueHandling.Ignore)] public bool Enabled { get; } ``` -------------------------------- ### ScheduledStartTime Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordScheduledEventException.ScheduledStartTime.html Gets the rescheduled start time, if one exists. This property is part of the DiscordScheduledEventException class and is of type DateTimeOffset?. ```APIDOC ## Property ScheduledStartTime ### Description Gets the rescheduled start time, if one exists. ### Property Value DateTimeOffset? ``` -------------------------------- ### Register Entry Point Command Source: https://docs.dcs.aitsys.dev/api/DisCatSharp.ApplicationCommands/DisCatSharp.ApplicationCommands.ExtensionMethods.RegisterEntryPointCommand.html Use this method to register the 'launch' entry point command. It configures the command's description, allowed contexts, integration types, handler type, default member permissions, and localizations. Only one entry point command is permitted per application. ```csharp public static void RegisterEntryPointCommand(this IReadOnlyDictionary extensions, string? description = null, List? allowedContexts = null, List? integrationTypes = null, ApplicationCommandHandlerType? handlerType = null, Permissions? defaultMemberPermissions = null, DiscordApplicationCommandLocalization? nameLocalizations = null, DiscordApplicationCommandLocalization? descriptionLocalizations = null) ``` -------------------------------- ### DiscordSku.CreatedAt Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordSku.CreatedAt.html Gets when the sku was created. ```APIDOC ## Property CreatedAt ### Description Gets when the sku was created. ### Property Value DateTimeOffset? ``` -------------------------------- ### ResourceChannels Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordServerGuide.ResourceChannels.html Gets the resource channels associated with the Discord server guide. This property returns a list of ResourceChannel objects. ```APIDOC ## Property ResourceChannels ### Description Gets the resource channels. ### Property Value `List` - A list of `ResourceChannel` objects representing the resource channels. ``` -------------------------------- ### Cursor Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp.Experimental/DisCatSharp.Experimental.Entities.DiscordGuildMessageSearchParams.Cursor.html Gets or sets the cursor for pagination. This property is used to specify the starting point for retrieving message search results. ```APIDOC ## Property Cursor ### Description Gets or sets the cursor for pagination. ### Property Value string ### Code Example ```csharp [JsonProperty("cursor", NullValueHandling = NullValueHandling.Ignore)] public string? Cursor { get; set; } ``` ``` -------------------------------- ### WelcomeMessage(ulong, string) Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.WelcomeMessage.-ctor.html Constructs a new welcome message for the server guide. ```APIDOC ## WelcomeMessage(ulong authorId, string message) ### Description Constructs a new welcome message for the server guide. ### Method Constructor ### Parameters #### Parameters - **authorId** (ulong) - The author id. - **message** (string) - The message. Use `[@username]` to mention the new member. Required. ``` -------------------------------- ### VoiceStartTime Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordChannelInfo.VoiceStartTime.html Gets the voice start time of the channel, if applicable. This property is part of the DiscordChannelInfo class within the DisCatSharp.Entities namespace. ```APIDOC ## Property VoiceStartTime ### Description Gets the voice start time of the channel, if applicable. ### Property Value DateTimeOffset? ### JSON Property `voice_start_time` ``` -------------------------------- ### UseApplicationCommands Source: https://docs.dcs.aitsys.dev/api/DisCatSharp.ApplicationCommands/DisCatSharp.ApplicationCommands.ExtensionMethods.UseApplicationCommands Enables application commands on this DiscordClient. Registration is started from the gateway ready lifecycle and is not triggered by HTTP ingress alone. ```APIDOC ## UseApplicationCommands ### Description Enables application commands on this DiscordClient. Registration is started from the gateway ready lifecycle and is not triggered by HTTP ingress alone. ### Method Signature `public static ApplicationCommandsExtension UseApplicationCommands(this DiscordClient client, ApplicationCommandsConfiguration? config = null)` ### Parameters #### Path Parameters - **client** (DiscordClient) - Required - Client to enable application commands for. - **config** (ApplicationCommandsConfiguration) - Optional - Configuration to use. ### Returns - **ApplicationCommandsExtension** - Created ApplicationCommandsExtension. ``` -------------------------------- ### ScheduledStartTime Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Net.Models.ScheduledEventExceptionEditModel.ScheduledStartTime.html Gets or sets the new scheduled start time for the exception. This property uses an Optional wrapper to indicate if the value has been set. ```APIDOC ## ScheduledStartTime Property ### Description Gets or sets the new scheduled start time for the exception. ### Property Value Optional ``` -------------------------------- ### Complete Slash Command with Choice Provider Source: https://docs.dcs.aitsys.dev/articles/modules/application_commands/options A comprehensive example combining a slash command with a custom choice provider, demonstrating the full implementation for dynamic command options. ```csharp public class MyCommand : ApplicationCommandsModule { [SlashCommand("my_command", "This is description of the command.")] public static async Task MySlashCommand(InteractionContext ctx, [ChoiceProvider(typeof(MyChoiceProvider))] [Option("option", "Description")] long option) { } } public class MyChoiceProvider : IChoiceProvider { public Task> Provider() { var options = new List { new DiscordApplicationCommandOptionChoice("First option", 1), new DiscordApplicationCommandOptionChoice("Second option", 2) }; return Task.FromResult(options.AsEnumerable()); } } ``` -------------------------------- ### DiscordVoiceRegion SampleHostname Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordVoiceRegion.SampleHostname.html Gets an example server hostname for this region. This property is part of the DiscordVoiceRegion class and is typically used internally or for informational purposes. ```csharp [JsonProperty("sample_hostname", NullValueHandling = NullValueHandling.Ignore)] public string SampleHostname { get; } ``` -------------------------------- ### DiscordSpotifyAsset Constructor Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordSpotifyAsset.Url Initializes a new instance of the DiscordSpotifyAsset class. ```APIDOC ## Constructor DiscordSpotifyAsset() ### Description Initializes a new instance of the DiscordSpotifyAsset class. ### Method Constructor ### Parameters None ``` -------------------------------- ### ScheduledStartTime Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Net.Models.ScheduledEventExceptionCreateModel.ScheduledStartTime.html Gets or sets the new scheduled start time for the exception. This property uses Optional to represent a potentially unset value. ```csharp public Optional ScheduledStartTime { get; set; } ``` -------------------------------- ### DiscordApplicationInstallParams Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordApplication.InstallParams.html Represents the installation parameters for adding a Discord application to a guild. ```APIDOC ## Property InstallParams ### Description Install parameters for adding the application to a guild. ### Property Value `DiscordApplicationInstallParams` ``` -------------------------------- ### ApplicationCommandsExtension Setup Method Source: https://docs.dcs.aitsys.dev/api/DisCatSharp.ApplicationCommands/DisCatSharp.ApplicationCommands.ApplicationCommandsExtension.Setup.html This method is part of the ApplicationCommands extension and should not be called manually. It is used internally by DisCatSharp to set up the application commands functionality. ```csharp protected override void Setup(DiscordClient client) ``` -------------------------------- ### Accessing the DiscordColor Red Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordColor.Red.html Use this property to get the predefined Discord color red. No setup or imports are required beyond having access to the DiscordColor type. ```csharp public static DiscordColor Red { get; } ``` -------------------------------- ### ScheduledStartTime Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Net.Models.ScheduledEventExceptionCreateModel.ScheduledStartTime.html Gets or sets the new scheduled start time for the exception. This property uses an Optional type to handle cases where the time might not be set. ```APIDOC ## Property ScheduledStartTime ### Description Gets or sets the new scheduled start time for the exception. ### Property Value Optional ### Example ```csharp // Assuming 'exceptionModel' is an instance of ScheduledEventExceptionCreateModel exceptionModel.ScheduledStartTime = Optional.FromValue(DateTimeOffset.UtcNow.AddHours(1)); // To check if a value is present: if (exceptionModel.ScheduledStartTime.HasValue) { DateTimeOffset startTime = exceptionModel.ScheduledStartTime.Value; // Use startTime } ``` ``` -------------------------------- ### Build() Source: https://docs.dcs.aitsys.dev/api/DisCatSharp.CommandsNext/DisCatSharp.CommandsNext.Converters.DefaultHelpFormatter.Build.html Constructs the help message for commands. ```APIDOC ## Build() ### Description Construct the help message. ### Method ```csharp public override CommandHelpMessage Build() ``` ### Returns CommandHelpMessage Data for the help message. ``` -------------------------------- ### DiscordOAuth2InstallParams Constructor Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordOAuth2InstallParams.-ctor.html Initializes a new instance of the DiscordOAuth2InstallParams class with optional scopes and permissions. ```APIDOC ## DiscordOAuth2InstallParams(List? scopes, Permissions? permissions) ### Description Initializes a new instance of the DiscordOAuth2InstallParams class. ### Parameters #### Parameters - **scopes** (List?) - The scopes. - **permissions** (Permissions?) - The permissions. ``` -------------------------------- ### Enabling Application Commands with UseApplicationCommands Source: https://docs.dcs.aitsys.dev/api/DisCatSharp.ApplicationCommands/DisCatSharp.ApplicationCommands.ExtensionMethods.UseApplicationCommands.html Use this extension method to enable application commands on your DiscordClient. Registration starts with the gateway's ready event. You can optionally provide a configuration object. ```csharp public static ApplicationCommandsExtension UseApplicationCommands(this DiscordClient client, ApplicationCommandsConfiguration? config = null) ``` -------------------------------- ### Respond to Messages Source: https://docs.dcs.aitsys.dev/articles/getting_started/first_bot Implement message content checking and response logic within the `MessageCreated` event handler. This example makes the bot reply with 'pong!' when it receives a message starting with 'ping'. ```csharp discord.MessageCreated += async (s, e) => { if (e.Message.Content.ToLower().StartsWith("ping")) await e.Message.RespondAsync("pong!"); }; ``` -------------------------------- ### ConfigureAsync Method Source: https://docs.dcs.aitsys.dev/api/DisCatSharp.Hosting/DisCatSharp.Hosting.BaseHostedService.ConfigureAsync.html This method is responsible for the initial setup and configuration of the Discord client. It is an abstract method, meaning it must be implemented by derived classes. ```APIDOC ## ConfigureAsync() ### Description Configure / Initialize the DiscordClient or DiscordShardedClient. ### Method Signature ```csharp protected abstract Task ConfigureAsync() ``` ### Returns - **Task**: Represents the asynchronous operation of configuring the client. ``` -------------------------------- ### QueueWarningThreshold Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.RestAdvancedConfiguration.QueueWarningThreshold.html Gets or sets the duration after which a warning log is emitted for a queued request that has not yet started. Set to TimeSpan.Zero to disable the warning. Must be non-negative. Defaults to 2 minutes. ```APIDOC ## QueueWarningThreshold Property ### Description Gets or sets the duration after which a warning log is emitted for a queued request that has not yet started. ### Property Value TimeSpan ### Remarks Set to Zero to disable the warning. Must be non-negative. Defaults to 2 minutes. ``` -------------------------------- ### Complete Command Module Example Source: https://docs.dcs.aitsys.dev/articles/modules/commandsnext/intro This shows a fully formed command module with a registered command. Ensure necessary using directives are included. ```csharp using System.Threading.Tasks; using DisCatSharp.CommandsNext; using DisCatSharp.CommandsNext.Attributes; public class MyFirstModule : BaseCommandModule { [Command("greet")] public async Task GreetCommand(CommandContext ctx) { await ctx.RespondAsync("Greetings! UwU"); } } ``` -------------------------------- ### QueueWarningThreshold Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.RestAdvancedConfiguration.QueueWarningThreshold.html Gets or sets the duration after which a warning log is emitted for a queued request that has not yet started. Set to TimeSpan.Zero to disable the warning. Must be non-negative. Defaults to 2 minutes. ```csharp public TimeSpan QueueWarningThreshold { get; set; } ``` -------------------------------- ### ConfigureAsync Method Source: https://docs.dcs.aitsys.dev/api/DisCatSharp.Hosting/DisCatSharp.Hosting.DiscordHostedService.ConfigureAsync.html This method is responsible for the initial setup and configuration of the Discord client. It is an override of a base method and is intended for internal use within the hosting service. ```APIDOC ## ConfigureAsync() ### Description Configure / Initialize the DiscordClient or DiscordShardedClient. ### Method Signature ```csharp protected override Task ConfigureAsync() ``` ### Returns Task - An asynchronous task representing the configuration operation. ``` -------------------------------- ### Record Audio to MP3 using ffmpeg Source: https://docs.dcs.aitsys.dev/articles/modules/audio/voice/receive This example demonstrates how to pipe decoded PCM audio data directly into an ffmpeg process to record it as an MP3 file. It includes logic to handle missing frames by filling them with silence. ```csharp using System.Diagnostics; using DisCatSharp.Voice; using DisCatSharp.Voice.EventArgs; private static Process? _ffmpeg; private static Stream? _ffmpegIn; public static void StartMp3Recording(string outputPath) { _ffmpeg = Process.Start(new ProcessStartInfo { FileName = "ffmpeg", Arguments = $"-y -hide_banner -loglevel warning -f s16le -ar 48000 -ac 2 -i pipe:0 -codec:a libmp3lame -q:a 2 \"{outputPath}\"", RedirectStandardInput = true, UseShellExecute = false, CreateNoWindow = true }) ?? throw new InvalidOperationException("Failed to start ffmpeg."); _ffmpegIn = _ffmpeg.StandardInput.BaseStream; } private static async Task OnVoiceReceivedForRecording(VoiceConnection _, VoiceReceiveEventArgs e) { if (_ffmpegIn is null || e.PcmData.Length == 0) return; // Preserve timeline continuity by filling packet-loss gaps with silence. if (e.MissingFrames > 0) { var bytesPerMs = e.AudioFormat.SampleRate * e.AudioFormat.ChannelCount * sizeof(short) / 1000; var silenceBytes = bytesPerMs * e.AudioDuration * e.MissingFrames; if (silenceBytes > 0) await _ffmpegIn.WriteAsync(new byte[silenceBytes]); } await _ffmpegIn.WriteAsync(e.PcmData); } public static async Task StopMp3RecordingAsync() { if (_ffmpeg is null || _ffmpegIn is null) return; await _ffmpegIn.FlushAsync(); _ffmpegIn.Dispose(); _ffmpegIn = null; _ffmpeg.WaitForExit(); _ffmpeg.Dispose(); _ffmpeg = null; } ``` ```csharp connection.VoiceReceived += OnVoiceReceivedForRecording; StartMp3Recording("logs/recordings/session.mp3"); ``` -------------------------------- ### Register Bot with Dependency Injection Source: https://docs.dcs.aitsys.dev/articles/getting_started/web_app Use AddDiscordHostedService for a streamlined DI setup. This is the recommended approach for integrating your bot. ```csharp public void ConfigureServices(IServiceCollection services) { services.AddDiscordHostedService(); } ``` -------------------------------- ### ChannelId Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.Core.DisCatSharpCommandContext.ChannelId.html Gets the ID of the channel this command gets executed in. ```APIDOC ## Property ChannelId ### Description Gets the id of the channel this command gets executed in. ### Signature ```csharp public ulong ChannelId { get; } ``` ### Property Value - **ulong**: The ID of the channel. ``` -------------------------------- ### Get Guild Welcome Screen Async Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordGuild.GetWelcomeScreenAsync.html Retrieves the welcome screen configuration for the current guild. Use this method to fetch details about the guild's welcome screen, such as enabled channels and descriptions. ```csharp public Task GetWelcomeScreenAsync(CancellationToken cancellationToken = default) ``` -------------------------------- ### GuildId Property Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.Core.DisCatSharpCommandContext.GuildId.html Gets the id of the guild this command gets executed in. ```APIDOC ## GuildId Property ### Description Gets the id of the guild this command gets executed in. ### Property Value `ulong?` ``` -------------------------------- ### Initialize Debian Environment Source: https://docs.dcs.aitsys.dev/articles/misc/hosting Update and upgrade packages within the Debian virtual machine to ensure all system components are up-to-date. ```bash apt update -y && apt upgrade -y ``` -------------------------------- ### Initialize DiscordGuildWelcomeScreenChannel Source: https://docs.dcs.aitsys.dev/api/DisCatSharp/DisCatSharp.Entities.DiscordGuildWelcomeScreenChannel.-ctor.html Use this constructor to create a new DiscordGuildWelcomeScreenChannel instance. It requires the channel ID and a description, with an optional emoji parameter. ```csharp public DiscordGuildWelcomeScreenChannel(ulong channelId, string description, DiscordEmoji emoji = null) ``` -------------------------------- ### Install Custom Audio Filter Source: https://docs.dcs.aitsys.dev/articles/modules/audio/voice/transmit Installs a custom audio filter to modify PCM data before encoding. Filters are applied in the order they are installed. You can also set a global volume modifier. ```csharp using DisCatSharp.Voice; using DisCatSharp.Voice.Entities; using DisCatSharp.Voice.Interfaces; public sealed class SoftClipFilter : IVoiceFilter { public void Transform(Span pcmData, AudioFormat pcmFormat, int duration) { for (var i = 0; i < pcmData.Length; i++) { var sample = pcmData[i]; // Light soft-clip to reduce peaks before encode. if (sample > 28000) sample = (short)(28000 + (sample - 28000) / 4); if (sample < -28000) sample = (short)(-28000 + (sample + 28000) / 4); pcmData[i] = sample; } } } var transmit = connection.GetTransmitSink(); var filter = new SoftClipFilter(); transmit.InstallFilter(filter); // appended at end of filter chain transmit.VolumeModifier = 0.9; // optional global gain // ... write PCM as usual ... transmit.UninstallFilter(filter); ```