delete playlist added @DragonOverlord xD closes #322
This commit is contained in:
parent
9bcce1f2d8
commit
21dc657779
@ -33,6 +33,14 @@ namespace NadekoBot.Classes
|
||||
conn.CreateTable<PlaylistSongInfo>();
|
||||
conn.CreateTable<MusicPlaylist>();
|
||||
conn.Execute(Queries.TransactionTriggerQuery);
|
||||
try
|
||||
{
|
||||
conn.Execute(Queries.DeletePlaylistTriggerQuery);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,4 +216,11 @@ INSERT OR REPLACE INTO CurrencyState (Id, UserId, Value, DateAdded)
|
||||
NEW.DateAdded);
|
||||
END
|
||||
";
|
||||
public static string DeletePlaylistTriggerQuery = @"
|
||||
CREATE TRIGGER music_playlist
|
||||
AFTER DELETE ON MusicPlaylist
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DELETE FROM PlaylistSongInfo WHERE PlaylistId = OLD.Id;
|
||||
END";
|
||||
}
|
||||
|
@ -610,6 +610,23 @@ namespace NadekoBot.Modules.Music
|
||||
e.Channel.SendMessage($"```js\n--- List of saved playlists ---\n\n" + string.Join("\n", result.Select(r => $"'{r.Name}-{r.Id}' by {r.Creator} ({r.SongCnt} songs)")) + $"\n\n --- Page {num} ---```");
|
||||
});
|
||||
|
||||
cgb.CreateCommand("deleteplaylist")
|
||||
.Alias("delpls")
|
||||
.Description("Deletes a saved playlist. Only if you made it or if you are the bot owner. | `!m delpls animu-5`")
|
||||
.Parameter("pl", ParameterType.Required)
|
||||
.Do(async e =>
|
||||
{
|
||||
var pl = e.GetArg("pl").Trim().Split('-')[1];
|
||||
if (string.IsNullOrWhiteSpace(pl))
|
||||
return;
|
||||
var plnum = int.Parse(pl);
|
||||
if (NadekoBot.IsOwner(e.User.Id))
|
||||
DbHandler.Instance.Delete<MusicPlaylist>(plnum);
|
||||
else
|
||||
DbHandler.Instance.DeleteWhere<MusicPlaylist>(mp => mp.Id == plnum && (long)e.User.Id == mp.CreatorId);
|
||||
await e.Channel.SendMessage("`Ok.` :ok:");
|
||||
});
|
||||
|
||||
cgb.CreateCommand("goto")
|
||||
.Description("Goes to a specific time in seconds in a song.")
|
||||
.Parameter("time")
|
||||
|
Loading…
Reference in New Issue
Block a user