forked from zaanposni/discord-masz
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't setup lavalink on ready as this is done automatically
- Loading branch information
1 parent
0d81036
commit 61723aa
Showing
7 changed files
with
63 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Bot.Attributes; | ||
using Discord.Interactions; | ||
using Lavalink4NET.Rest.Entities.Tracks; | ||
using Microsoft.AspNetCore.Components.Routing; | ||
using Music.Abstractions; | ||
using Music.Enums; | ||
using Music.Extensions; | ||
using System.Numerics; | ||
|
||
namespace Music.Commands; | ||
|
||
public class PlayStreamCommand : MusicCommand<PlayStreamCommand> | ||
{ | ||
[SlashCommand("play-stream", "Play a stream")] | ||
[BotChannel] | ||
public async Task PlayStream( | ||
[Summary("stream-url", "Stream URL")] string streamUrl, | ||
[Summary("source", "Music source")] MusicSource source = MusicSource.Default) | ||
{ | ||
if (!Uri.IsWellFormedUriString(streamUrl, UriKind.Absolute)) | ||
{ | ||
await RespondInteraction("I need a valid stream URL to function"); | ||
return; | ||
} | ||
|
||
var track = await Audio.Tracks.LoadTrackAsync(streamUrl, source.GetSearchMode()); | ||
|
||
if (track == null) | ||
{ | ||
await RespondInteraction($"Unable to get the stream from {streamUrl}"); | ||
return; | ||
} | ||
|
||
await Player.PlayAsync(track); | ||
|
||
await RespondInteraction($"Now streaming from {streamUrl}"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
public enum MusicSource | ||
{ | ||
None, | ||
Default, | ||
YouTube, | ||
YouTubeMusic, | ||
SoundCloud, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters