Initial commit
This commit is contained in:
commit
79e7cffb4e
49 changed files with 6399 additions and 0 deletions
40
Entities/UserMusic.cs
Normal file
40
Entities/UserMusic.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// Project Makoto Example Plugin
|
||||
// Copyright (C) 2023 Fortunevale
|
||||
// This code is licensed under MIT license (see 'LICENSE'-file for details)
|
||||
|
||||
using System.Linq;
|
||||
using DisCatSharp.Lavalink.Entities;
|
||||
using DisCatSharp.Lavalink.Enums;
|
||||
using Newtonsoft.Json;
|
||||
using ProjectMakoto.Database;
|
||||
using ProjectMakoto.Enums;
|
||||
using Xorog.UniversalExtensions;
|
||||
|
||||
namespace ProjectMakoto.Plugins.Music.Entities;
|
||||
|
||||
|
||||
[TableName("users")]
|
||||
public class UserMusic : PluginDatabaseTable
|
||||
{
|
||||
public UserMusic(BasePlugin plugin, ulong identifierValue) : base(plugin, identifierValue)
|
||||
{
|
||||
this.Id = identifierValue;
|
||||
}
|
||||
|
||||
[ColumnName("UserId"), ColumnType(ColumnTypes.BigInt), Primary]
|
||||
internal ulong Id { get; init; }
|
||||
|
||||
[ColumnName("Playlists"), ColumnType(ColumnTypes.LongText), Default("[]")]
|
||||
public UserPlaylist[] Playlists
|
||||
{
|
||||
get => (JsonConvert.DeserializeObject<UserPlaylist[]>(this.GetValue<string>(this.Id, "Playlists")) ?? [])
|
||||
.Select(x =>
|
||||
{
|
||||
x.Bot = this.Bot;
|
||||
x.Parent = this;
|
||||
|
||||
return x;
|
||||
}).ToArray();
|
||||
set => this.SetValue(this.Id, "Playlists", JsonConvert.SerializeObject(value));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue