restored some lost work

This commit is contained in:
Master Kwoth 2017-11-28 14:00:02 +07:00
parent 60e248c78a
commit 6e5fd672ea
2 changed files with 41 additions and 4 deletions

View File

@ -591,6 +591,7 @@ namespace NadekoBot.Modules.Music
var mp = await _service.GetOrCreatePlayer(Context);
var val = mp.AutoDelete = !mp.AutoDelete;
_service.SetSongAutoDelete(Context.Guild.Id, val);
if (val)
{
await ReplyConfirmLocalized("sad_enabled").ConfigureAwait(false);
@ -816,10 +817,11 @@ namespace NadekoBot.Modules.Music
var embed = new EmbedBuilder()
.WithTitle(s.Title.TrimTo(65))
.WithUrl(s.SongUrl)
.WithAuthor(eab => eab.WithName(GetText("song_moved")).WithIconUrl("https://cdn.discordapp.com/attachments/155726317222887425/258605269972549642/music1.png"))
.AddField(fb => fb.WithName(GetText("from_position")).WithValue($"#{n1 + 1}").WithIsInline(true))
.AddField(fb => fb.WithName(GetText("to_position")).WithValue($"#{n2 + 1}").WithIsInline(true))
.WithColor(NadekoBot.OkColor);
.WithAuthor(eab => eab.WithName(GetText("song_moved")).WithIconUrl("https://cdn.discordapp.com/attachments/155726317222887425/258605269972549642/music1.png"))
.AddField(fb => fb.WithName(GetText("from_position")).WithValue($"#{n1 + 1}").WithIsInline(true))
.AddField(fb => fb.WithName(GetText("to_position")).WithValue($"#{n2 + 1}").WithIsInline(true))
.WithColor(NadekoBot.OkColor);
await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
}
@ -907,8 +909,22 @@ namespace NadekoBot.Modules.Music
var mp = await _service.GetOrCreatePlayer(Context);
mp.OutputTextChannel = (ITextChannel)Context.Channel;
_service.SetMusicChannel(Context.Guild.Id, Context.Channel.Id);
await ReplyConfirmLocalized("set_music_channel").ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
[RequireUserPermission(GuildPermission.ManageMessages)]
public async Task UnsetMusicChannel()
{
var mp = await _service.GetOrCreatePlayer(Context);
mp.OutputTextChannel = null;
_service.SetMusicChannel(Context.Guild.Id, null);
await ReplyConfirmLocalized("unset_music_channel").ConfigureAwait(false);
}
}
}

View File

@ -16,6 +16,7 @@ using NadekoBot.Modules.Music.Common.Exceptions;
using NadekoBot.Modules.Music.Common.SongResolver;
using NadekoBot.Common.Collections;
using System;
using Microsoft.EntityFrameworkCore;
namespace NadekoBot.Modules.Music.Services
{
@ -276,5 +277,25 @@ namespace NadekoBot.Modules.Music.Services
{
_musicSettings.AddOrUpdate(id, musicSettings, delegate { return musicSettings; });
}
public void SetMusicChannel(ulong guildId, ulong? cid)
{
using (var uow = _db.UnitOfWork)
{
var ms = uow.GuildConfigs.For(guildId, set => set.Include(x => x.MusicSettings)).MusicSettings;
ms.MusicChannelId = cid;
uow.Complete();
}
}
public void SetSongAutoDelete(ulong guildId, bool val)
{
using (var uow = _db.UnitOfWork)
{
var ms = uow.GuildConfigs.For(guildId, set => set.Include(x => x.MusicSettings)).MusicSettings;
ms.SongAutoDelete = val;
uow.Complete();
}
}
}
}