Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0024325f4f | ||
![]() |
5a9d978b5e | ||
![]() |
1fc3fae278 | ||
![]() |
ac0f6e18ed | ||
![]() |
47bffbff7f | ||
![]() |
fcd376bdcb | ||
![]() |
a71f65de55 | ||
![]() |
3fd19eb149 | ||
![]() |
bc7e493e71 | ||
![]() |
85dbbd8bfc | ||
![]() |
e5d3f6935d |
@ -46,9 +46,9 @@ namespace TomatenMusic_Api
|
|||||||
if (e.Response.IsPlaylist)
|
if (e.Response.IsPlaylist)
|
||||||
{
|
{
|
||||||
if (e.Now)
|
if (e.Now)
|
||||||
await player.PlayPlaylistNowAsync(e.Response.Playlist);
|
await player.PlayNowAsync(e.Response.Playlist);
|
||||||
else
|
else
|
||||||
await player.PlayPlaylistAsync(e.Response.Playlist);
|
await player.PlayItemAsync(e.Response.Playlist);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
if (e.Now)
|
if (e.Now)
|
||||||
|
@ -5,10 +5,6 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<RootNamespace>TomatenMusic_Api</RootNamespace>
|
<RootNamespace>TomatenMusic_Api</RootNamespace>
|
||||||
<RestoreAdditionalProjectSources>
|
|
||||||
https://api.nuget.org/v3/index.json;
|
|
||||||
https://nuget.emzi0767.com/api/v3/index.json
|
|
||||||
</RestoreAdditionalProjectSources>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -84,7 +84,7 @@ namespace TomatenMusic.Commands
|
|||||||
if (response.IsPlaylist)
|
if (response.IsPlaylist)
|
||||||
{
|
{
|
||||||
ILavalinkPlaylist playlist = response.Playlist;
|
ILavalinkPlaylist playlist = response.Playlist;
|
||||||
await player.PlayPlaylistNowAsync(playlist);
|
await player.PlayNowAsync(playlist);
|
||||||
|
|
||||||
_ = ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent("Now Playing:").AddEmbed(
|
_ = ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent("Now Playing:").AddEmbed(
|
||||||
Common.AsEmbed(playlist)
|
Common.AsEmbed(playlist)
|
||||||
@ -237,7 +237,7 @@ namespace TomatenMusic.Commands
|
|||||||
if (response.IsPlaylist)
|
if (response.IsPlaylist)
|
||||||
{
|
{
|
||||||
ILavalinkPlaylist playlist = response.Playlist;
|
ILavalinkPlaylist playlist = response.Playlist;
|
||||||
await player.PlayPlaylistAsync(playlist);
|
await player.PlayItemAsync(playlist);
|
||||||
|
|
||||||
await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent("Now Playing:").AddEmbed(
|
await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent("Now Playing:").AddEmbed(
|
||||||
Common.AsEmbed(playlist)
|
Common.AsEmbed(playlist)
|
||||||
|
@ -20,7 +20,7 @@ namespace TomatenMusic.Music.Entitites
|
|||||||
public IEnumerable<string> YoutubeTags { get; set; }
|
public IEnumerable<string> YoutubeTags { get; set; }
|
||||||
public ulong YoutubeViews { get; set; }
|
public ulong YoutubeViews { get; set; }
|
||||||
public ulong YoutubeLikes { get; set; }
|
public ulong YoutubeLikes { get; set; }
|
||||||
public Uri YoutubeThumbnail { get; set; }
|
public Uri? YoutubeThumbnail { get; set; } = null;
|
||||||
public DateTime YoutubeUploadDate { get; set; }
|
public DateTime YoutubeUploadDate { get; set; }
|
||||||
//
|
//
|
||||||
// Summary:
|
// Summary:
|
||||||
|
@ -44,7 +44,9 @@ namespace TomatenMusic.Music.Entitites
|
|||||||
if (!player.PlayerQueue.Queue.Any())
|
if (!player.PlayerQueue.Queue.Any())
|
||||||
player.PlayerQueue.CurrentPlaylist = this;
|
player.PlayerQueue.CurrentPlaylist = this;
|
||||||
|
|
||||||
player.PlayerQueue.Queue = new Queue<TomatenMusicTrack>(player.PlayerQueue.Queue.Prepend(new TomatenMusicTrack(player.PlayerQueue.LastTrack.WithPosition(player.TrackPosition))));
|
if (!withoutQueuePrepend && player.State == PlayerState.Playing)
|
||||||
|
player.PlayerQueue.Queue = new Queue<TomatenMusicTrack>(player.PlayerQueue.Queue.Prepend(new TomatenMusicTrack(player.PlayerQueue.LastTrack.WithPosition(player.TrackPosition))));
|
||||||
|
|
||||||
|
|
||||||
Queue<TomatenMusicTrack> reversedTracks = new Queue<TomatenMusicTrack>(Tracks);
|
Queue<TomatenMusicTrack> reversedTracks = new Queue<TomatenMusicTrack>(Tracks);
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ namespace TomatenMusicCore.Music.Entities
|
|||||||
|
|
||||||
public async Task PlayNow(GuildPlayer player, TimeSpan? startTime = null, TimeSpan? endTime = null, bool withoutQueuePrepend = false)
|
public async Task PlayNow(GuildPlayer player, TimeSpan? startTime = null, TimeSpan? endTime = null, bool withoutQueuePrepend = false)
|
||||||
{
|
{
|
||||||
if (!withoutQueuePrepend)
|
if (!withoutQueuePrepend && player.State == PlayerState.Playing)
|
||||||
player.PlayerQueue.Queue = new Queue<TomatenMusicTrack>(player.PlayerQueue.Queue.Prepend(new TomatenMusicTrack(player.PlayerQueue.LastTrack.WithPosition(player.TrackPosition))));
|
player.PlayerQueue.Queue = new Queue<TomatenMusicTrack>(player.PlayerQueue.Queue.Prepend(new TomatenMusicTrack(player.PlayerQueue.LastTrack.WithPosition(player.TrackPosition))));
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,7 +57,9 @@ namespace TomatenMusic.Music.Entitites
|
|||||||
if (!player.PlayerQueue.Queue.Any())
|
if (!player.PlayerQueue.Queue.Any())
|
||||||
player.PlayerQueue.CurrentPlaylist = this;
|
player.PlayerQueue.CurrentPlaylist = this;
|
||||||
|
|
||||||
player.PlayerQueue.Queue = new Queue<TomatenMusicTrack>(player.PlayerQueue.Queue.Prepend(new TomatenMusicTrack(player.PlayerQueue.LastTrack.WithPosition(player.TrackPosition))));
|
if (!withoutQueuePrepend && player.State == PlayerState.Playing)
|
||||||
|
player.PlayerQueue.Queue = new Queue<TomatenMusicTrack>(player.PlayerQueue.Queue.Prepend(new TomatenMusicTrack(player.PlayerQueue.LastTrack.WithPosition(player.TrackPosition))));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Queue<TomatenMusicTrack> reversedTracks = new Queue<TomatenMusicTrack>(Tracks);
|
Queue<TomatenMusicTrack> reversedTracks = new Queue<TomatenMusicTrack>(Tracks);
|
||||||
|
@ -64,26 +64,6 @@ namespace TomatenMusic.Music
|
|||||||
QueuePrompt.UpdateFor(GuildId);
|
QueuePrompt.UpdateFor(GuildId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PlayPlaylistAsync(ILavalinkPlaylist playlist)
|
|
||||||
{
|
|
||||||
EnsureNotDestroyed();
|
|
||||||
EnsureConnected();
|
|
||||||
|
|
||||||
_logger.LogInformation("Started playing Playlist {0} on Guild {1}", playlist.Title, (await GetGuildAsync()).Name);
|
|
||||||
|
|
||||||
|
|
||||||
QueuePrompt.UpdateFor(GuildId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task PlayPlaylistNowAsync(ILavalinkPlaylist playlist)
|
|
||||||
{
|
|
||||||
EnsureConnected();
|
|
||||||
EnsureNotDestroyed();
|
|
||||||
|
|
||||||
|
|
||||||
QueuePrompt.UpdateFor(GuildId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task RewindAsync()
|
public async Task RewindAsync()
|
||||||
{
|
{
|
||||||
EnsureNotDestroyed();
|
EnsureNotDestroyed();
|
||||||
@ -109,24 +89,19 @@ namespace TomatenMusic.Music
|
|||||||
MusicActionResponse response;
|
MusicActionResponse response;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
response = PlayerQueue.(true);
|
response = PlayerQueue.NextTrack(true, Autoplay);
|
||||||
}catch (Exception ex)
|
}catch (Exception ex)
|
||||||
{
|
{
|
||||||
if (Autoplay)
|
if (Autoplay)
|
||||||
{
|
{
|
||||||
YoutubeService youtube = TomatenMusicBot.ServiceProvider.GetRequiredService<YoutubeService>();
|
_ = OnAutoPlay(CurrentTrack);
|
||||||
LavalinkTrack newTrack = await youtube.GetRelatedTrackAsync(CurrentTrack.TrackIdentifier, PlayerQueue.PlayedTracks.Take(5).ToList().ConvertAll(x => x.TrackIdentifier));
|
|
||||||
|
|
||||||
_logger.LogInformation($"Skipped Track {CurrentTrack.Title} for Autoplayed Track {newTrack.Title}");
|
|
||||||
await PlayAsync(newTrack);
|
|
||||||
QueuePrompt.UpdateFor(GuildId);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation($"Skipped Track {CurrentTrack.Title} for Track {response.Track.Title}");
|
_logger.LogInformation($"Skipped Track {CurrentTrack.Title} for Track {response.Track.Title}");
|
||||||
await base.PlayAsync(response.Track);
|
await PlayNowAsync(response.Track, withoutQueuePrepend: true);
|
||||||
QueuePrompt.UpdateFor(GuildId);
|
QueuePrompt.UpdateFor(GuildId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,10 +159,16 @@ namespace TomatenMusic.Music
|
|||||||
|
|
||||||
if (channel.Type == ChannelType.Stage)
|
if (channel.Type == ChannelType.Stage)
|
||||||
{
|
{
|
||||||
DiscordStageInstance stageInstance = await channel.GetStageInstanceAsync();
|
DiscordStageInstance stageInstance;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
stageInstance = await channel.GetStageInstanceAsync();
|
||||||
|
|
||||||
if (stageInstance == null)
|
}catch (Exception ex)
|
||||||
|
{
|
||||||
stageInstance = await channel.CreateStageInstanceAsync("Music");
|
stageInstance = await channel.CreateStageInstanceAsync("Music");
|
||||||
|
}
|
||||||
|
|
||||||
await stageInstance.Channel.UpdateCurrentUserVoiceStateAsync(false);
|
await stageInstance.Channel.UpdateCurrentUserVoiceStateAsync(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +204,6 @@ namespace TomatenMusic.Music
|
|||||||
public async override Task OnTrackEndAsync(TrackEndEventArgs eventArgs)
|
public async override Task OnTrackEndAsync(TrackEndEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
DisconnectOnStop = false;
|
DisconnectOnStop = false;
|
||||||
YoutubeService youtube = TomatenMusicBot.ServiceProvider.GetRequiredService<YoutubeService>();
|
|
||||||
var oldTrack = CurrentTrack;
|
var oldTrack = CurrentTrack;
|
||||||
|
|
||||||
if (eventArgs.Reason != TrackEndReason.Finished)
|
if (eventArgs.Reason != TrackEndReason.Finished)
|
||||||
@ -246,12 +226,8 @@ namespace TomatenMusic.Music
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TomatenMusicTrack newTrack = await youtube.GetRelatedTrackAsync(oldTrack.TrackIdentifier, PlayerQueue.PlayedTracks.Take(5).ToList().ConvertAll(x => x.TrackIdentifier));
|
|
||||||
_logger.LogInformation($"Autoplaying for track {oldTrack.TrackIdentifier} with Track {newTrack.TrackIdentifier}");
|
|
||||||
await base.OnTrackEndAsync(eventArgs);
|
await base.OnTrackEndAsync(eventArgs);
|
||||||
PlayerQueue.LastTrack = newTrack;
|
_ = OnAutoPlay(oldTrack);
|
||||||
await newTrack.Play(this);
|
|
||||||
QueuePrompt.UpdateFor(GuildId);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -259,6 +235,21 @@ namespace TomatenMusic.Music
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task OnAutoPlay(LavalinkTrack oldTrack)
|
||||||
|
{
|
||||||
|
YoutubeService youtube = TomatenMusicBot.ServiceProvider.GetRequiredService<YoutubeService>();
|
||||||
|
|
||||||
|
TomatenMusicTrack newTrack;
|
||||||
|
if (oldTrack.Provider != StreamProvider.YouTube)
|
||||||
|
newTrack = await youtube.GetRelatedTrackAsync(PlayerQueue.PlayedTracks.First(x => x.Provider == StreamProvider.YouTube).TrackIdentifier, PlayerQueue.PlayedTracks.Take(5).ToList().ConvertAll(x => x.TrackIdentifier));
|
||||||
|
else
|
||||||
|
newTrack = await youtube.GetRelatedTrackAsync(oldTrack.TrackIdentifier, PlayerQueue.PlayedTracks.Take(5).ToList().ConvertAll(x => x.TrackIdentifier));
|
||||||
|
_logger.LogInformation($"Autoplaying for track {oldTrack.TrackIdentifier} with Track {newTrack.TrackIdentifier}");
|
||||||
|
PlayerQueue.LastTrack = newTrack;
|
||||||
|
await newTrack.PlayNow(this, withoutQueuePrepend: true);
|
||||||
|
QueuePrompt.UpdateFor(GuildId);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<DiscordChannel> GetChannelAsync()
|
public async Task<DiscordChannel> GetChannelAsync()
|
||||||
{
|
{
|
||||||
EnsureConnected();
|
EnsureConnected();
|
||||||
|
@ -26,7 +26,7 @@ namespace TomatenMusic.Music
|
|||||||
|
|
||||||
public TomatenMusicTrack LastTrack { get; set; }
|
public TomatenMusicTrack LastTrack { get; set; }
|
||||||
|
|
||||||
public List<TomatenMusicTrack> QueueLoopList { get; private set; }
|
public List<TomatenMusicTrack> QueueLoopList { get; private set; } = new List<TomatenMusicTrack>();
|
||||||
|
|
||||||
public void QueueTrack(TomatenMusicTrack track)
|
public void QueueTrack(TomatenMusicTrack track)
|
||||||
{
|
{
|
||||||
@ -92,10 +92,11 @@ namespace TomatenMusic.Music
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MusicActionResponse NextTrack(bool ignoreLoop = false)
|
public MusicActionResponse NextTrack(bool ignoreLoop = false, bool autoplay = false)
|
||||||
{
|
{
|
||||||
if (LastTrack != null)
|
if (LastTrack != null)
|
||||||
PlayedTracks = new Queue<TomatenMusicTrack>(PlayedTracks.Prepend(new TomatenMusicTrack(LastTrack.WithPosition(TimeSpan.Zero))));
|
if (LoopType != LoopType.TRACK || (ignoreLoop && (Queue.Any() || autoplay)))
|
||||||
|
PlayedTracks = new Queue<TomatenMusicTrack>(PlayedTracks.Prepend(new TomatenMusicTrack(LastTrack.WithPosition(TimeSpan.Zero))));
|
||||||
|
|
||||||
switch (LoopType)
|
switch (LoopType)
|
||||||
{
|
{
|
||||||
@ -157,8 +158,7 @@ namespace TomatenMusic.Music
|
|||||||
|
|
||||||
if (type == LoopType.QUEUE)
|
if (type == LoopType.QUEUE)
|
||||||
{
|
{
|
||||||
QueueLoopList = new List<TomatenMusicTrack>(Queue);
|
QueueLoopList = new List<TomatenMusicTrack>(Queue.Prepend(LastTrack));
|
||||||
QueueLoopList.Add(LastTrack);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,11 +93,15 @@ namespace TomatenMusic.Prompt.Implementation
|
|||||||
_ = args.Interaction.EditOriginalResponseAsync(new DiscordWebhookBuilder().WithContent("Please connect to the bots Channel to use this Interaction"));
|
_ = args.Interaction.EditOriginalResponseAsync(new DiscordWebhookBuilder().WithContent("Please connect to the bots Channel to use this Interaction"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await Player.RewindAsync();
|
await Player.RewindAsync();
|
||||||
}catch (Exception ex)
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,8 +135,18 @@ namespace TomatenMusic.Prompt.Implementation
|
|||||||
_ = args.Interaction.EditOriginalResponseAsync(new DiscordWebhookBuilder().WithContent("Please connect to the bots Channel to use this Interaction"));
|
_ = args.Interaction.EditOriginalResponseAsync(new DiscordWebhookBuilder().WithContent("Please connect to the bots Channel to use this Interaction"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await Player.SkipAsync();
|
||||||
|
|
||||||
await Player.SkipAsync();
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_ = args.Interaction.CreateResponseAsync(
|
||||||
|
DSharpPlus.InteractionResponseType.ChannelMessageWithSource,
|
||||||
|
new DiscordInteractionResponseBuilder()
|
||||||
|
.WithContent($"An Error occurred during this Interaction {ex.Message}"));
|
||||||
|
}
|
||||||
|
|
||||||
System.Timers.Timer timer = new System.Timers.Timer(800);
|
System.Timers.Timer timer = new System.Timers.Timer(800);
|
||||||
timer.Elapsed += (s, args) =>
|
timer.Elapsed += (s, args) =>
|
||||||
|
@ -87,9 +87,9 @@ namespace TomatenMusic
|
|||||||
.AddSingleton(
|
.AddSingleton(
|
||||||
new LavalinkNodeOptions
|
new LavalinkNodeOptions
|
||||||
{
|
{
|
||||||
RestUri = "http://116.202.92.16:2333",
|
RestUri = "http://127.0.0.1:2333",
|
||||||
Password = config.LavaLinkPassword,
|
Password = config.LavaLinkPassword,
|
||||||
WebSocketUri = "ws://116.202.92.16:2333",
|
WebSocketUri = "ws://127.0.0.1:2333",
|
||||||
AllowResuming = true
|
AllowResuming = true
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -4,17 +4,13 @@
|
|||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<RestoreAdditionalProjectSources>
|
|
||||||
https://api.nuget.org/v3/index.json;
|
|
||||||
https://nuget.emzi0767.com/api/v3/index.json
|
|
||||||
</RestoreAdditionalProjectSources>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DSharpPlus" Version="4.2.0-nightly-01101" />
|
<PackageReference Include="DSharpPlus" Version="4.2.0-nightly-01107" />
|
||||||
<PackageReference Include="DSharpPlus.Interactivity" Version="4.2.0-nightly-01101" />
|
<PackageReference Include="DSharpPlus.Interactivity" Version="4.2.0-nightly-01107" />
|
||||||
<PackageReference Include="DSharpPlus.SlashCommands" Version="4.2.0-nightly-01101" />
|
<PackageReference Include="DSharpPlus.SlashCommands" Version="4.2.0-nightly-01107" />
|
||||||
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.56.0.2630" />
|
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.57.0.2637" />
|
||||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.42" />
|
<PackageReference Include="HtmlAgilityPack" Version="1.11.42" />
|
||||||
<PackageReference Include="Lavalink4NET" Version="2.1.1" />
|
<PackageReference Include="Lavalink4NET" Version="2.1.1" />
|
||||||
<PackageReference Include="Lavalink4NET.DSharpPlus" Version="2.1.1" />
|
<PackageReference Include="Lavalink4NET.DSharpPlus" Version="2.1.1" />
|
||||||
|
@ -32,10 +32,12 @@ namespace TomatenMusic.Util
|
|||||||
DiscordEmbedBuilder builder = new DiscordEmbedBuilder()
|
DiscordEmbedBuilder builder = new DiscordEmbedBuilder()
|
||||||
.WithTitle(track.Title)
|
.WithTitle(track.Title)
|
||||||
.WithUrl(track.Source)
|
.WithUrl(track.Source)
|
||||||
.WithImageUrl(context.YoutubeThumbnail)
|
|
||||||
.WithDescription(context.YoutubeDescription)
|
.WithDescription(context.YoutubeDescription)
|
||||||
.AddField("Length", Common.GetTimestamp(track.Duration), true);
|
.AddField("Length", Common.GetTimestamp(track.Duration), true);
|
||||||
|
|
||||||
|
if (context.YoutubeThumbnail != null)
|
||||||
|
builder.WithImageUrl(context.YoutubeThumbnail);
|
||||||
|
|
||||||
if (context.IsFile)
|
if (context.IsFile)
|
||||||
{
|
{
|
||||||
builder.WithAuthor(track.Author);
|
builder.WithAuthor(track.Author);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user