'lavalink not working when making discord bot with DSharpPlus. not throwing any errors
command class, no errors when running
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using DSharpPlus.Lavalink;
namespace MusicBot
{
public class MediaCommands : BaseCommandModule
{
[Command("join"), Description("joins user voice channel")]
public async Task JoinVC(CommandContext ctx, DiscordChannel chn)
{
var lava = ctx.Client.GetLavalink();
if (!lava.ConnectedNodes.Any())
{
await ctx.RespondAsync("The Lavalink connection is not established");
return;
}
var node = lava.ConnectedNodes.Values.First();
if (chn.Type != ChannelType.Voice)
{
await ctx.RespondAsync("Not a valid voice channel");
return;
}
await node.ConnectAsync(chn);
await ctx.RespondAsync($"Joined {chn}");
}
program class no error when running
using System;
using DSharpPlus;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using DSharpPlus.CommandsNext;
using DSharpPlus.Lavalink;
using DSharpPlus.Net;
using LortBasic;
using LortMusic;
namespace Lort
{
class Program
{
static void Main(string[] args)
{
MainAsync().GetAwaiter().GetResult();
}
static async Task MainAsync()
{
var LortBot = new DiscordClient(new DiscordConfiguration()
{
Token = "mytoken",
TokenType = TokenType.Bot,
Intents = DiscordIntents.All,
MinimumLogLevel = LogLevel.Debug
});
//lavalink
var endpoint = new ConnectionEndpoint
{
Hostname = "127.0.0.1",
Port = 25565
};
var lavalinkconfig = new LavalinkConfiguration
{
Password = "youshallnotpass",
RestEndpoint = endpoint,
SocketEndpoint = endpoint,
};
var lavalink = LortBot.UseLavalink();
await LortBot.ConnectAsync();
await lavalink.ConnectAsync(lavalinkconfig);
await Task.Delay(-1);
I'm following this guide to make a discord bot with c# using DSharpPlus https://dsharpplus.github.io/articles/audio/lavalink/setup.html and everything works up until trying to get the bot to join a voice channel. it has admin rights and no errors in lavalink console, bot console, vs, none anywhere. nothing happens though... at all
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
