| @@ -10,7 +10,7 @@ namespace NadekoBot.Modules.Administration.Commands | |||||||
|     { |     { | ||||||
|         public AutoAssignRole(DiscordModule module) : base(module) |         public AutoAssignRole(DiscordModule module) : base(module) | ||||||
|         { |         { | ||||||
|             NadekoBot.Client.UserJoined += (s, e) => |             NadekoBot.OnReady += () => NadekoBot.Client.UserJoined += (s, e) => | ||||||
|             { |             { | ||||||
|                 try |                 try | ||||||
|                 { |                 { | ||||||
|   | |||||||
| @@ -12,6 +12,8 @@ namespace NadekoBot.Modules.Administration.Commands | |||||||
|     class CrossServerTextChannel : DiscordCommand |     class CrossServerTextChannel : DiscordCommand | ||||||
|     { |     { | ||||||
|         public CrossServerTextChannel(DiscordModule module) : base(module) |         public CrossServerTextChannel(DiscordModule module) : base(module) | ||||||
|  |         { | ||||||
|  |             NadekoBot.OnReady += () => | ||||||
|             { |             { | ||||||
|                 NadekoBot.Client.MessageReceived += async (s, e) => |                 NadekoBot.Client.MessageReceived += async (s, e) => | ||||||
|                 { |                 { | ||||||
| @@ -54,6 +56,7 @@ namespace NadekoBot.Modules.Administration.Commands | |||||||
|                     } |                     } | ||||||
|                     catch { } |                     catch { } | ||||||
|                 }; |                 }; | ||||||
|  |             }; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private string GetText(Server server, Channel channel, User user, Message message) => |         private string GetText(Server server, Channel channel, User user, Message message) => | ||||||
|   | |||||||
| @@ -18,6 +18,8 @@ namespace NadekoBot.Modules.Administration.Commands | |||||||
|         private ConcurrentBag<KeyValuePair<Channel, string>> voicePresenceUpdates = new ConcurrentBag<KeyValuePair<Channel, string>>(); |         private ConcurrentBag<KeyValuePair<Channel, string>> voicePresenceUpdates = new ConcurrentBag<KeyValuePair<Channel, string>>(); | ||||||
|  |  | ||||||
|         public LogCommand(DiscordModule module) : base(module) |         public LogCommand(DiscordModule module) : base(module) | ||||||
|  |         { | ||||||
|  |             NadekoBot.OnReady += () => | ||||||
|             { |             { | ||||||
|                 NadekoBot.Client.MessageReceived += MsgRecivd; |                 NadekoBot.Client.MessageReceived += MsgRecivd; | ||||||
|                 NadekoBot.Client.MessageDeleted += MsgDltd; |                 NadekoBot.Client.MessageDeleted += MsgDltd; | ||||||
| @@ -50,6 +52,7 @@ namespace NadekoBot.Modules.Administration.Commands | |||||||
|                     } |                     } | ||||||
|                     catch { } |                     catch { } | ||||||
|                 }; |                 }; | ||||||
|  |             }; | ||||||
|  |  | ||||||
|             // start the userpresence queue |             // start the userpresence queue | ||||||
|  |  | ||||||
|   | |||||||
| @@ -9,7 +9,6 @@ using System.Linq; | |||||||
| using System.Text; | using System.Text; | ||||||
| using System.Threading; | using System.Threading; | ||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
| using System.Timers; |  | ||||||
| using Timer = System.Timers.Timer; | using Timer = System.Timers.Timer; | ||||||
|  |  | ||||||
| namespace NadekoBot.Modules.Administration.Commands | namespace NadekoBot.Modules.Administration.Commands | ||||||
| @@ -38,7 +37,7 @@ namespace NadekoBot.Modules.Administration.Commands | |||||||
|                 {"%trivia%", () => Games.Commands.TriviaCommands.RunningTrivias.Count.ToString()} |                 {"%trivia%", () => Games.Commands.TriviaCommands.RunningTrivias.Count.ToString()} | ||||||
|             }; |             }; | ||||||
|  |  | ||||||
|         private readonly SemaphoreSlim playingPlaceholderLock = new SemaphoreSlim(1,1); |         private readonly SemaphoreSlim playingPlaceholderLock = new SemaphoreSlim(1, 1); | ||||||
|  |  | ||||||
|         public PlayingRotate(DiscordModule module) : base(module) |         public PlayingRotate(DiscordModule module) : base(module) | ||||||
|         { |         { | ||||||
| @@ -70,8 +69,7 @@ namespace NadekoBot.Modules.Administration.Commands | |||||||
|                 } |                 } | ||||||
|                 catch { } |                 catch { } | ||||||
|             }; |             }; | ||||||
|  |             NadekoBot.OnReady += () => timer.Enabled = NadekoBot.Config.IsRotatingStatus; | ||||||
|             timer.Enabled = NadekoBot.Config.IsRotatingStatus; |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public Func<CommandEventArgs, Task> DoFunc() => async e => |         public Func<CommandEventArgs, Task> DoFunc() => async e => | ||||||
| @@ -86,7 +84,8 @@ namespace NadekoBot.Modules.Administration.Commands | |||||||
|                 NadekoBot.Config.IsRotatingStatus = timer.Enabled; |                 NadekoBot.Config.IsRotatingStatus = timer.Enabled; | ||||||
|                 await ConfigHandler.SaveConfig().ConfigureAwait(false); |                 await ConfigHandler.SaveConfig().ConfigureAwait(false); | ||||||
|             } |             } | ||||||
|             finally { |             finally | ||||||
|  |             { | ||||||
|                 playingPlaceholderLock.Release(); |                 playingPlaceholderLock.Release(); | ||||||
|             } |             } | ||||||
|             await e.Channel.SendMessage($"❗`Rotating playing status has been {(timer.Enabled ? "enabled" : "disabled")}.`").ConfigureAwait(false); |             await e.Channel.SendMessage($"❗`Rotating playing status has been {(timer.Enabled ? "enabled" : "disabled")}.`").ConfigureAwait(false); | ||||||
| @@ -103,7 +102,7 @@ namespace NadekoBot.Modules.Administration.Commands | |||||||
|             cgb.CreateCommand(Module.Prefix + "addplaying") |             cgb.CreateCommand(Module.Prefix + "addplaying") | ||||||
|                 .Alias(Module.Prefix + "adpl") |                 .Alias(Module.Prefix + "adpl") | ||||||
|                 .Description("Adds a specified string to the list of playing strings to rotate. " + |                 .Description("Adds a specified string to the list of playing strings to rotate. " + | ||||||
|                              "Supported placeholders: " + string.Join(", ", PlayingPlaceholders.Keys)+ $" **Bot Owner Only!**| `{Prefix}adpl`") |                              "Supported placeholders: " + string.Join(", ", PlayingPlaceholders.Keys) + $" **Bot Owner Only!**| `{Prefix}adpl`") | ||||||
|                 .Parameter("text", ParameterType.Unparsed) |                 .Parameter("text", ParameterType.Unparsed) | ||||||
|                 .AddCheck(SimpleCheckers.OwnerOnly()) |                 .AddCheck(SimpleCheckers.OwnerOnly()) | ||||||
|                 .Do(async e => |                 .Do(async e => | ||||||
| @@ -152,7 +151,8 @@ namespace NadekoBot.Modules.Administration.Commands | |||||||
|                     int num; |                     int num; | ||||||
|                     string str; |                     string str; | ||||||
|                     await playingPlaceholderLock.WaitAsync().ConfigureAwait(false); |                     await playingPlaceholderLock.WaitAsync().ConfigureAwait(false); | ||||||
|                     try { |                     try | ||||||
|  |                     { | ||||||
|                         if (!int.TryParse(arg.Trim(), out num) || num <= 0 || num > NadekoBot.Config.RotatingStatuses.Count) |                         if (!int.TryParse(arg.Trim(), out num) || num <= 0 || num > NadekoBot.Config.RotatingStatuses.Count) | ||||||
|                             return; |                             return; | ||||||
|                         str = NadekoBot.Config.RotatingStatuses[num - 1]; |                         str = NadekoBot.Config.RotatingStatuses[num - 1]; | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ namespace NadekoBot.Modules.Administration.Commands | |||||||
|  |  | ||||||
|         public RatelimitCommand(DiscordModule module) : base(module) |         public RatelimitCommand(DiscordModule module) : base(module) | ||||||
|         { |         { | ||||||
|             NadekoBot.Client.MessageReceived += async (s, e) => |             NadekoBot.OnReady += () => NadekoBot.Client.MessageReceived += async (s, e) => | ||||||
|             { |             { | ||||||
|                 if (e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id) |                 if (e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id) | ||||||
|                     return; |                     return; | ||||||
|   | |||||||
| @@ -31,8 +31,12 @@ namespace NadekoBot.Modules.Administration.Commands | |||||||
|         { |         { | ||||||
|             AnnouncementsDictionary = new ConcurrentDictionary<ulong, AnnounceControls>(); |             AnnouncementsDictionary = new ConcurrentDictionary<ulong, AnnounceControls>(); | ||||||
|  |  | ||||||
|  |             //gotta subscribe after ready, to prevent trying to send these before all guilds are initialized | ||||||
|  |             NadekoBot.OnReady += () => | ||||||
|  |             { | ||||||
|                 NadekoBot.Client.UserJoined += UserJoined; |                 NadekoBot.Client.UserJoined += UserJoined; | ||||||
|                 NadekoBot.Client.UserLeft += UserLeft; |                 NadekoBot.Client.UserLeft += UserLeft; | ||||||
|  |             }; | ||||||
|  |  | ||||||
|             var data = Classes.DbHandler.Instance.GetAllRows<DataModels.Announcement>(); |             var data = Classes.DbHandler.Instance.GetAllRows<DataModels.Announcement>(); | ||||||
|  |  | ||||||
| @@ -245,7 +249,7 @@ namespace NadekoBot.Modules.Administration.Commands | |||||||
|                 }); |                 }); | ||||||
|  |  | ||||||
|             cgb.CreateCommand(Module.Prefix + "greetmsg") |             cgb.CreateCommand(Module.Prefix + "greetmsg") | ||||||
|                 .Description($"Sets a new join announcement message. Type %user% if you want to mention the new member. Using it with no message will show the current greet message. **Needs Manage Server Permissions.**| `{Prefix}greetmsg Welcome to the server, %user%.`") |                 .Description($"Sets a new join announcement message. Type %user% if you want to mention the new member. Using it with no message will show the current greet message. **Needs Manage Server Permissions.**| `{Prefix}greetmsg Welcome, %user%.`") | ||||||
|                 .Parameter("msg", ParameterType.Unparsed) |                 .Parameter("msg", ParameterType.Unparsed) | ||||||
|                 .Do(async e => |                 .Do(async e => | ||||||
|                 { |                 { | ||||||
| @@ -278,7 +282,7 @@ namespace NadekoBot.Modules.Administration.Commands | |||||||
|                 }); |                 }); | ||||||
|  |  | ||||||
|             cgb.CreateCommand(Module.Prefix + "byemsg") |             cgb.CreateCommand(Module.Prefix + "byemsg") | ||||||
|                 .Description($"Sets a new leave announcement message. Type %user% if you want to mention the new member. Using it with no message will show the current bye message. **Needs Manage Server Permissions.**| `{Prefix}byemsg %user% has left the server.`") |                 .Description($"Sets a new leave announcement message. Type %user% if you want to mention the new member. Using it with no message will show the current bye message. **Needs Manage Server Permissions.**| `{Prefix}byemsg %user% has left.`") | ||||||
|                 .Parameter("msg", ParameterType.Unparsed) |                 .Parameter("msg", ParameterType.Unparsed) | ||||||
|                 .Do(async e => |                 .Do(async e => | ||||||
|                 { |                 { | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ namespace NadekoBot.Modules.Administration.Commands | |||||||
|         public VoicePlusTextCommand(DiscordModule module) : base(module) |         public VoicePlusTextCommand(DiscordModule module) : base(module) | ||||||
|         { |         { | ||||||
|             // changing servers may cause bugs |             // changing servers may cause bugs | ||||||
|             NadekoBot.Client.UserUpdated += async (sender, e) => |             NadekoBot.OnReady += () => NadekoBot.Client.UserUpdated += async (sender, e) => | ||||||
|             { |             { | ||||||
|                 try |                 try | ||||||
|                 { |                 { | ||||||
|   | |||||||
| @@ -92,7 +92,7 @@ namespace NadekoBot.Classes.Help.Commands | |||||||
| #if DEBUG | #if DEBUG | ||||||
|             File.WriteAllText("../../../docs/Commands List.md", helpstr.ToString()); |             File.WriteAllText("../../../docs/Commands List.md", helpstr.ToString()); | ||||||
| #else | #else | ||||||
|             File.WriteAllText("commandlist.md", helpstr); |             File.WriteAllText("commandlist.md", helpstr.ToString()); | ||||||
| #endif | #endif | ||||||
|         }; |         }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -324,7 +324,7 @@ namespace NadekoBot.Modules.Music | |||||||
|  |  | ||||||
|                 cgb.CreateCommand(Prefix + "soundcloudpl") |                 cgb.CreateCommand(Prefix + "soundcloudpl") | ||||||
|                     .Alias(Prefix + "scpl") |                     .Alias(Prefix + "scpl") | ||||||
|                     .Description($"Queue a soundcloud playlist using a link. | `{Prefix}scpl https://soundcloud.com/saratology/sets/symphony`") |                     .Description($"Queue a soundcloud playlist using a link. | `{Prefix}scpl soundcloudseturl`") | ||||||
|                     .Parameter("pl", ParameterType.Unparsed) |                     .Parameter("pl", ParameterType.Unparsed) | ||||||
|                     .Do(async e => |                     .Do(async e => | ||||||
|                     { |                     { | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ namespace NadekoBot.Modules.Permissions.Commands | |||||||
|  |  | ||||||
|         public FilterInvitesCommand(DiscordModule module) : base(module) |         public FilterInvitesCommand(DiscordModule module) : base(module) | ||||||
|         { |         { | ||||||
|             NadekoBot.Client.MessageReceived += async (sender, args) => |             NadekoBot.OnReady += () => NadekoBot.Client.MessageReceived += async (sender, args) => | ||||||
|             { |             { | ||||||
|                 if (args.Channel.IsPrivate || args.User.Id == NadekoBot.Client.CurrentUser.Id) return; |                 if (args.Channel.IsPrivate || args.User.Id == NadekoBot.Client.CurrentUser.Id) return; | ||||||
|                 try |                 try | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ namespace NadekoBot.Modules.Permissions.Commands | |||||||
|     { |     { | ||||||
|         public FilterWords(DiscordModule module) : base(module) |         public FilterWords(DiscordModule module) : base(module) | ||||||
|         { |         { | ||||||
|             NadekoBot.Client.MessageReceived += async (sender, args) => |             NadekoBot.OnReady += () => NadekoBot.Client.MessageReceived += async (sender, args) => | ||||||
|             { |             { | ||||||
|                 if (args.Channel.IsPrivate || args.User.Id == NadekoBot.Client.CurrentUser.Id) return; |                 if (args.Channel.IsPrivate || args.User.Id == NadekoBot.Client.CurrentUser.Id) return; | ||||||
|                 try |                 try | ||||||
|   | |||||||
| @@ -70,7 +70,8 @@ namespace NadekoBot.Modules.Searches.Commands | |||||||
|                 catch { } |                 catch { } | ||||||
|                 await ConfigHandler.SaveConfig().ConfigureAwait(false); |                 await ConfigHandler.SaveConfig().ConfigureAwait(false); | ||||||
|             }; |             }; | ||||||
|             checkTimer.Start(); |             //start checking only after ready, because we need all servers to be initialized | ||||||
|  |             NadekoBot.OnReady += checkTimer.Start; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private async Task<Tuple<bool, string>> GetStreamStatus(StreamNotificationConfig stream, bool checkCache = true) |         private async Task<Tuple<bool, string>> GetStreamStatus(StreamNotificationConfig stream, bool checkCache = true) | ||||||
|   | |||||||
| @@ -30,7 +30,7 @@ namespace NadekoBot.Modules.Utility.Commands | |||||||
|         { |         { | ||||||
|             var remList = DbHandler.Instance.GetAllRows<Reminder>(); |             var remList = DbHandler.Instance.GetAllRows<Reminder>(); | ||||||
|  |  | ||||||
|             reminders = remList.Select(StartNewReminder).ToList(); |             NadekoBot.OnReady += () => reminders = remList.Select(StartNewReminder).ToList(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private Timer StartNewReminder(Reminder r) |         private Timer StartNewReminder(Reminder r) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user