Announcements are now on parse and persist restarts
Also added reason for .die
This commit is contained in:
		
							
								
								
									
										231
									
								
								NadekoBot/Commands/ServerGreetCommand.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										231
									
								
								NadekoBot/Commands/ServerGreetCommand.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,231 @@
 | 
				
			|||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using Discord.Commands;
 | 
				
			||||||
 | 
					using System.Collections.Concurrent;
 | 
				
			||||||
 | 
					using NadekoBot.Extensions;
 | 
				
			||||||
 | 
					using Discord;
 | 
				
			||||||
 | 
					using Parse;
 | 
				
			||||||
 | 
					using System.ComponentModel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Voltana's legacy
 | 
				
			||||||
 | 
					public class AsyncLazy<T> : Lazy<Task<T>> 
 | 
				
			||||||
 | 
					{ 
 | 
				
			||||||
 | 
					    public AsyncLazy(Func<T> valueFactory) : 
 | 
				
			||||||
 | 
					        base(() => Task.Factory.StartNew(valueFactory)) { }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public AsyncLazy(Func<Task<T>> taskFactory) : 
 | 
				
			||||||
 | 
					        base(() => Task.Factory.StartNew(() => taskFactory()).Unwrap()) { } 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public TaskAwaiter<T> GetAwaiter() { return Value.GetAwaiter(); } 
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace NadekoBot.Commands {
 | 
				
			||||||
 | 
					    class ServerGreetCommand : DiscordCommand {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static ConcurrentDictionary<ulong, AnnounceControls> AnnouncementsDictionary;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public ServerGreetCommand() : base() {
 | 
				
			||||||
 | 
					            AnnouncementsDictionary = new ConcurrentDictionary<ulong, AnnounceControls>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            NadekoBot.client.UserJoined += UserJoined;
 | 
				
			||||||
 | 
					            NadekoBot.client.UserLeft += UserLeft;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var data = new ParseQuery<ParseObject>("Announcements")
 | 
				
			||||||
 | 
					                               .FindAsync()
 | 
				
			||||||
 | 
					                               .Result;
 | 
				
			||||||
 | 
					            if(data.Any())
 | 
				
			||||||
 | 
					            foreach (var po in data)
 | 
				
			||||||
 | 
					                AnnouncementsDictionary.TryAdd(po.Get<ulong>("serverId"), new AnnounceControls(po.Get<ulong>("serverId")).Initialize(po));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private async void UserLeft(object sender, UserEventArgs e) {
 | 
				
			||||||
 | 
					            if (!AnnouncementsDictionary.ContainsKey(e.Server.Id) ||
 | 
				
			||||||
 | 
					                !AnnouncementsDictionary[e.Server.Id].Bye) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var controls = AnnouncementsDictionary[e.Server.Id];
 | 
				
			||||||
 | 
					            var channel = NadekoBot.client.GetChannel(controls.ByeChannel);
 | 
				
			||||||
 | 
					            if (channel == null) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            await channel.Send(controls.ByeText.Replace("%user%", e.User.Mention));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private async void UserJoined(object sender, Discord.UserEventArgs e) {
 | 
				
			||||||
 | 
					            if (!AnnouncementsDictionary.ContainsKey(e.Server.Id) || 
 | 
				
			||||||
 | 
					                !AnnouncementsDictionary[e.Server.Id].Greet) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var controls = AnnouncementsDictionary[e.Server.Id];
 | 
				
			||||||
 | 
					            var channel = NadekoBot.client.GetChannel(controls.GreetChannel);
 | 
				
			||||||
 | 
					            if (channel == null) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            await channel.Send(controls.GreetText.Replace("%user%", e.User.Mention));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public class AnnounceControls {
 | 
				
			||||||
 | 
					            private ParseObject ParseObj = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            private bool greet;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            public bool Greet {
 | 
				
			||||||
 | 
					                get { return greet; }
 | 
				
			||||||
 | 
					                set { greet = value; Save(); }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            private ulong greetChannel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            public ulong GreetChannel {
 | 
				
			||||||
 | 
					                get { return greetChannel; }
 | 
				
			||||||
 | 
					                set { greetChannel = value; }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            private string greetText = "Welcome to the server %user%";
 | 
				
			||||||
 | 
					            public string GreetText {
 | 
				
			||||||
 | 
					                get { return greetText; }
 | 
				
			||||||
 | 
					                set { greetText = value; Save(); }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            private bool bye;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            public bool Bye {
 | 
				
			||||||
 | 
					                get { return bye; }
 | 
				
			||||||
 | 
					                set { bye = value; Save(); }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            private ulong byeChannel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            public ulong ByeChannel {
 | 
				
			||||||
 | 
					                get { return byeChannel; }
 | 
				
			||||||
 | 
					                set { byeChannel = value; }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            private string byeText = "%user% has left the server";
 | 
				
			||||||
 | 
					            public string ByeText {
 | 
				
			||||||
 | 
					                get { return byeText; }
 | 
				
			||||||
 | 
					                set { byeText = value; Save(); }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            public ulong ServerId { get; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            public AnnounceControls(ulong serverId) {
 | 
				
			||||||
 | 
					                this.ServerId = serverId;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            internal bool ToggleBye(ulong id) {
 | 
				
			||||||
 | 
					                if (Bye) {
 | 
				
			||||||
 | 
					                    return Bye = false;
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    ByeChannel = id;
 | 
				
			||||||
 | 
					                    return Bye = true;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            internal bool ToggleGreet(ulong id) {
 | 
				
			||||||
 | 
					                if (Greet) {
 | 
				
			||||||
 | 
					                    return Greet = false;
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    GreetChannel = id;
 | 
				
			||||||
 | 
					                    return Greet = true;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            private void Save() {
 | 
				
			||||||
 | 
					                ParseObject p = null;
 | 
				
			||||||
 | 
					                if (this.ParseObj != null)
 | 
				
			||||||
 | 
					                    p = ParseObj;
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                    p = ParseObj = new ParseObject("Announcements");
 | 
				
			||||||
 | 
					                p["greet"] = greet;
 | 
				
			||||||
 | 
					                p["greetText"] = greetText;
 | 
				
			||||||
 | 
					                p["greetChannel"] = greetChannel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                p["bye"] = bye;
 | 
				
			||||||
 | 
					                p["byeText"] = byeText;
 | 
				
			||||||
 | 
					                p["byeChannel"] = byeChannel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                p["serverId"] = ServerId;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                p.SaveAsync();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            internal AnnounceControls Initialize(ParseObject po) {
 | 
				
			||||||
 | 
					                greet = po.Get<bool>("greet");
 | 
				
			||||||
 | 
					                greetText = po.Get<string>("greetText");
 | 
				
			||||||
 | 
					                greetChannel = po.Get<ulong>("greetChannel");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                bye = po.Get<bool>("bye");
 | 
				
			||||||
 | 
					                byeText = po.Get<string>("byeText");
 | 
				
			||||||
 | 
					                byeChannel = po.Get<ulong>("byeChannel");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                this.ParseObj = po;
 | 
				
			||||||
 | 
					                return this;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public override Func<CommandEventArgs, Task> DoFunc() {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public override void Init(CommandGroupBuilder cgb) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            cgb.CreateCommand(".greet")
 | 
				
			||||||
 | 
					                .Description("Enables or Disables anouncements on the current channel when someone joins the server.")
 | 
				
			||||||
 | 
					                .Do(async e => {
 | 
				
			||||||
 | 
					                    if (!e.User.ServerPermissions.ManageServer) return;
 | 
				
			||||||
 | 
					                    if (!AnnouncementsDictionary.ContainsKey(e.Server.Id))
 | 
				
			||||||
 | 
					                        AnnouncementsDictionary.TryAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    var controls = AnnouncementsDictionary[e.Server.Id];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (controls.ToggleGreet(e.Channel.Id))
 | 
				
			||||||
 | 
					                        await e.Send("Greet announcements enabled on this channel.");
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                        await e.Send("Greet announcements disabled.");
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            cgb.CreateCommand(".greetmsg")
 | 
				
			||||||
 | 
					                .Description("Sets a new announce message. Type %user% if you want to mention the new member.\n**Usage**: .greetmsg Welcome to the server, %user%.")
 | 
				
			||||||
 | 
					                .Parameter("msg", ParameterType.Unparsed)
 | 
				
			||||||
 | 
					                .Do(async e => {
 | 
				
			||||||
 | 
					                    if (!e.User.ServerPermissions.ManageServer) return;
 | 
				
			||||||
 | 
					                    if (e.GetArg("msg") == null) return;
 | 
				
			||||||
 | 
					                    if (!AnnouncementsDictionary.ContainsKey(e.Server.Id))
 | 
				
			||||||
 | 
					                        AnnouncementsDictionary.TryAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    AnnouncementsDictionary[e.Server.Id].GreetText = e.GetArg("msg");
 | 
				
			||||||
 | 
					                    await e.Send("New greet message set.");
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            cgb.CreateCommand(".bye")
 | 
				
			||||||
 | 
					                .Description("Enables or Disables anouncements on the current channel when someone leaves the server.")
 | 
				
			||||||
 | 
					                .Do(async e => {
 | 
				
			||||||
 | 
					                    if (!e.User.ServerPermissions.ManageServer) return;
 | 
				
			||||||
 | 
					                    if (!AnnouncementsDictionary.ContainsKey(e.Server.Id))
 | 
				
			||||||
 | 
					                        AnnouncementsDictionary.TryAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    var controls = AnnouncementsDictionary[e.Server.Id];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (controls.ToggleBye(e.Channel.Id))
 | 
				
			||||||
 | 
					                        await e.Send("Bye announcements enabled on this channel.");
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                        await e.Send("Bye announcements disabled.");
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            cgb.CreateCommand(".byemsg")
 | 
				
			||||||
 | 
					                .Description("Sets a new announce leave message. Type %user% if you want to mention the new member.\n**Usage**: .byemsg %user% has left the server.")
 | 
				
			||||||
 | 
					                .Parameter("msg", ParameterType.Unparsed)
 | 
				
			||||||
 | 
					                .Do(async e => {
 | 
				
			||||||
 | 
					                    if (!e.User.ServerPermissions.ManageServer) return;
 | 
				
			||||||
 | 
					                    if (e.GetArg("msg") == null) return;
 | 
				
			||||||
 | 
					                    if (!AnnouncementsDictionary.ContainsKey(e.Server.Id))
 | 
				
			||||||
 | 
					                        AnnouncementsDictionary.TryAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    AnnouncementsDictionary[e.Server.Id].ByeText = e.GetArg("msg");
 | 
				
			||||||
 | 
					                    await e.Send("New bye message set.");
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -8,6 +8,7 @@ using Discord.Commands;
 | 
				
			|||||||
using NadekoBot.Extensions;
 | 
					using NadekoBot.Extensions;
 | 
				
			||||||
using System.Threading;
 | 
					using System.Threading;
 | 
				
			||||||
using System.Diagnostics;
 | 
					using System.Diagnostics;
 | 
				
			||||||
 | 
					using Parse;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace NadekoBot {
 | 
					namespace NadekoBot {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,7 @@ using System.Linq;
 | 
				
			|||||||
using System.Timers;
 | 
					using System.Timers;
 | 
				
			||||||
using NadekoBot.Extensions;
 | 
					using NadekoBot.Extensions;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using NadekoBot.Commands;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace NadekoBot.Modules
 | 
					namespace NadekoBot.Modules
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -14,6 +15,7 @@ namespace NadekoBot.Modules
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        public Administration() : base() {
 | 
					        public Administration() : base() {
 | 
				
			||||||
            commands.Add(new HelpCommand());
 | 
					            commands.Add(new HelpCommand());
 | 
				
			||||||
 | 
					            commands.Add(new ServerGreetCommand());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public override void Install(ModuleManager manager)
 | 
					        public override void Install(ModuleManager manager)
 | 
				
			||||||
@@ -62,7 +64,6 @@ namespace NadekoBot.Modules
 | 
				
			|||||||
                            await e.Send("You failed to supply a valid username");
 | 
					                            await e.Send("You failed to supply a valid username");
 | 
				
			||||||
                            return;
 | 
					                            return;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
                        var role = e.Server.FindRoles(e.GetArg("role_name")).FirstOrDefault();
 | 
					                        var role = e.Server.FindRoles(e.GetArg("role_name")).FirstOrDefault();
 | 
				
			||||||
                        if (role == null) {
 | 
					                        if (role == null) {
 | 
				
			||||||
                            await e.Send("You failed to supply a valid role");
 | 
					                            await e.Send("You failed to supply a valid role");
 | 
				
			||||||
@@ -269,14 +270,23 @@ namespace NadekoBot.Modules
 | 
				
			|||||||
                    });
 | 
					                    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                cgb.CreateCommand(".die")
 | 
					                cgb.CreateCommand(".die")
 | 
				
			||||||
                    .Description("Works only for the owner. Shuts the bot down.")
 | 
					                    .Alias(".graceful")
 | 
				
			||||||
 | 
					                    .Parameter("reason",ParameterType.Unparsed)
 | 
				
			||||||
 | 
					                    .Description("Works only for the owner. Shuts the bot down and notifies users about the restart.")
 | 
				
			||||||
                    .Do(async e => {
 | 
					                    .Do(async e => {
 | 
				
			||||||
                        if (e.User.Id == NadekoBot.OwnerID) {
 | 
					                        if (e.User.Id == NadekoBot.OwnerID) {
 | 
				
			||||||
                            Timer t = new Timer();
 | 
					                            Timer t = new Timer();
 | 
				
			||||||
                            t.Interval = 2000;
 | 
					                            t.Interval = 2000;
 | 
				
			||||||
                            t.Elapsed += (s, ev) => { Environment.Exit(0); };
 | 
					                            t.Elapsed += (s, ev) => { Environment.Exit(0); };
 | 
				
			||||||
                            t.Start();
 | 
					                            t.Start();
 | 
				
			||||||
                            await e.Send("Shutting down.");
 | 
					                            string reason = e.GetArg("reason");
 | 
				
			||||||
 | 
					                            if (reason == null)
 | 
				
			||||||
 | 
					                                reason = "Unspecified.";
 | 
				
			||||||
 | 
					                            foreach (var kvp in Music.musicPlayers) {
 | 
				
			||||||
 | 
					                                if(kvp.Value?.CurrentSong?.Channel!=null)
 | 
				
			||||||
 | 
					                                    await kvp.Value.CurrentSong.Channel.Send($"Owner initiated a shutdown, sorry for the interruption.\nReason: `{reason}`");
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            await e.Send("`Shutting down.`");
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    });
 | 
					                    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -314,66 +324,6 @@ namespace NadekoBot.Modules
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
					
 | 
										
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                cgb.CreateCommand(".greet")
 | 
					 | 
				
			||||||
                    .Description("Enables or Disables anouncements on the current channel when someone joins the server.")
 | 
					 | 
				
			||||||
                    .Do(async e => {
 | 
					 | 
				
			||||||
                        if (e.User.Id != NadekoBot.OwnerID) return;
 | 
					 | 
				
			||||||
                        announcingGreet = !announcingGreet;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (announcingGreet) {
 | 
					 | 
				
			||||||
                            announceChannel = e.Channel;
 | 
					 | 
				
			||||||
                            joinServer = e.Server;
 | 
					 | 
				
			||||||
                            NadekoBot.client.UserJoined += Client_UserJoined;
 | 
					 | 
				
			||||||
                            await e.Send("Greet announcements enabled on this channel.");
 | 
					 | 
				
			||||||
                        } else {
 | 
					 | 
				
			||||||
                            announceChannel = null;
 | 
					 | 
				
			||||||
                            joinServer = null;
 | 
					 | 
				
			||||||
                            NadekoBot.client.UserJoined -= Client_UserJoined;
 | 
					 | 
				
			||||||
                            await e.Send("Announcements disabled.");
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    });
 | 
					 | 
				
			||||||
                //todo add greet/bye for everyone
 | 
					 | 
				
			||||||
                cgb.CreateCommand(".greetmsg")
 | 
					 | 
				
			||||||
                    .Description("Sets a new announce message. Type %user% if you want to mention the new member.\n**Usage**: .greetmsg Welcome to the server, %user%.")
 | 
					 | 
				
			||||||
                    .Parameter("msg", ParameterType.Unparsed)
 | 
					 | 
				
			||||||
                    .Do(async e => {
 | 
					 | 
				
			||||||
                        if (e.User.Id != NadekoBot.OwnerID) return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (e.GetArg("msg") == null) return;
 | 
					 | 
				
			||||||
                        announceMsg = e.GetArg("msg");
 | 
					 | 
				
			||||||
                        await e.Send("New greet message set.");
 | 
					 | 
				
			||||||
                    });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                cgb.CreateCommand(".bye")
 | 
					 | 
				
			||||||
                    .Description("Enables or Disables anouncements on the current channel when someone leaves the server.")
 | 
					 | 
				
			||||||
                    .Do(async e => {
 | 
					 | 
				
			||||||
                        if (e.User.Id != NadekoBot.OwnerID) return;
 | 
					 | 
				
			||||||
                        announcingLeave = !announcingLeave;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (announcingLeave) {
 | 
					 | 
				
			||||||
                            announceLeaveChannel = e.Channel;
 | 
					 | 
				
			||||||
                            leaveServer = e.Server;
 | 
					 | 
				
			||||||
                            NadekoBot.client.UserLeft += Client_UserLeft;
 | 
					 | 
				
			||||||
                            await e.Send("Leave announcements enabled on this channel.");
 | 
					 | 
				
			||||||
                        } else {
 | 
					 | 
				
			||||||
                            announceLeaveChannel = null;
 | 
					 | 
				
			||||||
                            leaveServer = null;
 | 
					 | 
				
			||||||
                            NadekoBot.client.UserLeft -= Client_UserLeft;
 | 
					 | 
				
			||||||
                            await e.Send("Leave announcements disabled.");
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                cgb.CreateCommand(".byemsg")
 | 
					 | 
				
			||||||
                    .Description("Sets a new announce leave message. Type %user% if you want to mention the new member.\n**Usage**: .byemsg %user% has left the server.")
 | 
					 | 
				
			||||||
                    .Parameter("msg", ParameterType.Unparsed)
 | 
					 | 
				
			||||||
                    .Do(async e => {
 | 
					 | 
				
			||||||
                        if (e.User.Id != NadekoBot.OwnerID) return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (e.GetArg("msg") == null) return;
 | 
					 | 
				
			||||||
                        announceLeaveMsg = e.GetArg("msg");
 | 
					 | 
				
			||||||
                        await e.Send("New bye message set.");
 | 
					 | 
				
			||||||
                    });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                cgb.CreateCommand(".checkmyperms")
 | 
					                cgb.CreateCommand(".checkmyperms")
 | 
				
			||||||
                    .Description("Checks your userspecific permissions on this channel.")
 | 
					                    .Description("Checks your userspecific permissions on this channel.")
 | 
				
			||||||
                    .Do(async e => {
 | 
					                    .Do(async e => {
 | 
				
			||||||
@@ -424,7 +374,6 @@ namespace NadekoBot.Modules
 | 
				
			|||||||
                            await e.Send("Sending failed.");
 | 
					                            await e.Send("Sending failed.");
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    });
 | 
					                    });
 | 
				
			||||||
 | 
					 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -122,11 +122,12 @@ namespace NadekoBot.Modules {
 | 
				
			|||||||
                    .Alias("yq")
 | 
					                    .Alias("yq")
 | 
				
			||||||
                    .Description("Queue a song using keywords or link. **You must be in a voice channel**.\n**Usage**: `!m q Dream Of Venice`")
 | 
					                    .Description("Queue a song using keywords or link. **You must be in a voice channel**.\n**Usage**: `!m q Dream Of Venice`")
 | 
				
			||||||
                    .Parameter("Query", ParameterType.Unparsed)
 | 
					                    .Parameter("Query", ParameterType.Unparsed)
 | 
				
			||||||
                    .Do(e => {
 | 
					                    .Do(async e => {
 | 
				
			||||||
                        if (musicPlayers.ContainsKey(e.Server) == false)
 | 
					                        if (musicPlayers.ContainsKey(e.Server) == false)
 | 
				
			||||||
                            musicPlayers.TryAdd(e.Server, new MusicControls());
 | 
					                            musicPlayers.TryAdd(e.Server, new MusicControls());
 | 
				
			||||||
                        var player = musicPlayers[e.Server];
 | 
					                        var player = musicPlayers[e.Server];
 | 
				
			||||||
                        player.SongQueue.Add(new StreamRequest(NadekoBot.client, e, e.GetArg("Query")));
 | 
					                        player.SongQueue.Add(new StreamRequest(NadekoBot.client, e, e.GetArg("Query")));
 | 
				
			||||||
 | 
					                        await e.Send(":warning: Music is unstable atm, working on a fix. :warning:");
 | 
				
			||||||
                    });
 | 
					                    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                cgb.CreateCommand("lq")
 | 
					                cgb.CreateCommand("lq")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,7 +24,7 @@ namespace NadekoBot
 | 
				
			|||||||
        public static string password;
 | 
					        public static string password;
 | 
				
			||||||
        public static string TrelloAppKey;
 | 
					        public static string TrelloAppKey;
 | 
				
			||||||
        public static bool ForwardMessages = false;
 | 
					        public static bool ForwardMessages = false;
 | 
				
			||||||
        public static string BotVersion = "0.7-beta2";
 | 
					        public static string BotVersion = "0.7-beta3";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        static void Main()
 | 
					        static void Main()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -141,6 +141,7 @@
 | 
				
			|||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
    <Compile Include="Classes\SParser.cs" />
 | 
					    <Compile Include="Classes\SParser.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Commands\ServerGreetCommand.cs" />
 | 
				
			||||||
    <Compile Include="Commands\SpeedTyping.cs" />
 | 
					    <Compile Include="Commands\SpeedTyping.cs" />
 | 
				
			||||||
    <Compile Include="Classes\_JSONModels.cs" />
 | 
					    <Compile Include="Classes\_JSONModels.cs" />
 | 
				
			||||||
    <Compile Include="Classes\Cards.cs" />
 | 
					    <Compile Include="Classes\Cards.cs" />
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user