This commit is contained in:
Tim Müller
2022-03-28 19:52:42 +02:00
commit d432575da6
75 changed files with 6390 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
using Lavalink4NET.Player;
using System.Text.Json.Serialization;
using TomatenMusic.Music.Entitites;
namespace TomatenMusic_Api.Models
{
public class BasicTrackInfo
{
public string Name { get; set; }
public TrackPlatform Platform { get; set; }
public string YoutubeId { get; set; }
public string SpotifyId { get; set; }
public Uri URL { get; set; }
public BasicTrackInfo(LavalinkTrack track)
{
if (track == null)
return;
FullTrackContext ctx = (FullTrackContext)track.Context;
if (ctx == null)
return;
Name = track.Title;
Platform = ctx.SpotifyIdentifier == null ? TrackPlatform.YOUTUBE : TrackPlatform.SPOTIFY;
YoutubeId = track.TrackIdentifier;
SpotifyId = ctx.SpotifyIdentifier;
URL = new Uri(track.Source);
}
}
public enum TrackPlatform
{
YOUTUBE,
SPOTIFY,
FILE
}
}

View File

@@ -0,0 +1,13 @@
using DSharpPlus.Entities;
using Emzi0767.Utilities;
using Newtonsoft.Json;
namespace TomatenMusic_Api.Models
{
public class ChannelConnectRequest
{
public ulong Channel_Id { get; set; }
public ulong Guild_Id { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
namespace TomatenMusic_Api.Models.EventArgs
{
public class ChannelDisconnectRequest
{
public ulong GuildId { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using DSharpPlus.Entities;
using Emzi0767.Utilities;
namespace TomatenMusic_Api.Models.EventArgs
{
public class ChannelConnectArgs : AsyncEventArgs
{
public ulong Guild_Id { get; set; }
public DiscordChannel Channel { get; set; }
public ChannelConnectArgs(ulong guild_Id, DiscordChannel channel)
{
Guild_Id = guild_Id;
Channel = channel;
}
}
}

View File

@@ -0,0 +1,13 @@
using Emzi0767.Utilities;
namespace TomatenMusic_Api.Models.EventArgs
{
public class ChannelDisconnectArgs : AsyncEventArgs
{
public ulong GuildId { get; set; }
public ChannelDisconnectArgs(ulong guildId) { GuildId = guildId; }
}
}

View File

@@ -0,0 +1,22 @@
using Emzi0767.Utilities;
using Lavalink4NET.Player;
using TomatenMusic.Music;
namespace TomatenMusic_Api.Models.EventArgs
{
public class TrackPlayArgs : AsyncEventArgs
{
public MusicActionResponse Response { get; set; }
public ulong GuildId { get; set; }
public TimeSpan StartTime { get; set; }
public bool Now { get; set; }
public TrackPlayArgs(MusicActionResponse response, ulong guildId, TimeSpan startTime, bool now)
{
Response = response;
GuildId = guildId;
StartTime = startTime;
Now = now;
}
}
}

View File

@@ -0,0 +1,62 @@
using DSharpPlus.Entities;
using Lavalink4NET;
using Lavalink4NET.Player;
using TomatenMusic;
using TomatenMusic.Music;
namespace TomatenMusic_Api.Models
{
public class PlayerConnectionInfo
{
public static async Task<PlayerConnectionInfo> Create(GuildPlayer player)
{
PlayerConnectionInfo response = new PlayerConnectionInfo();
response.PlaybackPosition = player.TrackPosition;
response.Channel_Id = (ulong)player.VoiceChannelId;
response.Guild_Id = player.GuildId;
response.Paused = player.State == PlayerState.Paused;
response.CurrentTrack = new BasicTrackInfo(player.CurrentTrack);
response.LoopType = player.PlayerQueue.LoopType;
response.Queue = player.PlayerQueue.Queue.ToList().ConvertAll(x => new BasicTrackInfo(x));
response.PlayedTracks = player.PlayerQueue.PlayedTracks.ToList().ConvertAll(x => new BasicTrackInfo(x));
response.State = player.State;
return response;
}
// Summary:
// Gets the current playback position.
public TimeSpan PlaybackPosition
{
get;
internal set;
}
public PlayerState State { get; set; }
//
// Summary:
// Gets the voice channel associated with this connection.
public ulong Channel_Id { get; set; }
//
// Summary:
// Gets the guild associated with this connection.
public ulong Guild_Id {get; set; }
public bool Paused { get; set; }
public BasicTrackInfo CurrentTrack { get; set; }
public LoopType LoopType { get; set; }
public List<BasicTrackInfo> Queue { get; set; }
public List<BasicTrackInfo> PlayedTracks { get; set; }
}
}

View File

@@ -0,0 +1,10 @@
namespace TomatenMusic_Api.Models
{
public class TrackPlayRequest
{
public ulong GuildId { get; set; }
public string TrackUri { get; set; }
public bool Now { get; set; }
public int StartTimeSeconds { get; set; }
}
}