restored some lost work
This commit is contained in:
		@@ -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);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user