public StatsService(ShardedDiscordClient client, CommandHandler cmdHandler) { this.client = client; Reset(); this.client.MessageReceived += _ => Task.FromResult(MessageCounter++); cmdHandler.CommandExecuted += (_, e) => CommandsRan++; this.client.Disconnected += _ => Reset(); this.carbonitexTimer = new Timer(async (state) => { if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.CarbonKey)) return; try { using (var http = new HttpClient()) { using (var content = new FormUrlEncodedContent( new Dictionary<string, string> { { "servercount", this.client.GetGuilds().Count.ToString() }, { "key", NadekoBot.Credentials.CarbonKey }})) { content.Headers.Clear(); content.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); var res = await http.PostAsync("https://www.carbonitex.net/discord/data/botdata.php", content).ConfigureAwait(false); } }; } catch { } }, null, TimeSpan.FromHours(1), TimeSpan.FromHours(1)); }
public RatelimitCommand() { this._client = FaultyBot.Client; this._log = LogManager.GetCurrentClassLogger(); _client.MessageReceived += (umsg) => { var t = Task.Run(async() => { var usrMsg = umsg as IUserMessage; var channel = usrMsg.Channel as ITextChannel; if (channel == null || usrMsg.IsAuthor()) { return; } Ratelimiter limiter; if (!RatelimitingChannels.TryGetValue(channel.Id, out limiter)) { return; } if (limiter.CheckUserRatelimit(usrMsg.Author.Id)) { try { await usrMsg.DeleteAsync(); } catch (Exception ex) { _log.Warn(ex); } } }); return(Task.CompletedTask); }; }
public Music(ILocalization loc, CommandService cmds, ShardedDiscordClient client, IGoogleApiService google) : base(loc, cmds, client) { //it can fail if its currenctly opened or doesn't exist. Either way i don't care try { Directory.Delete(MusicDataPath, true); } catch { } Directory.CreateDirectory(MusicDataPath); _google = google; }
public Music(ILocalization loc, CommandService cmds, ShardedDiscordClient client, IGoogleApiService google) : base(loc, cmds, client) { //it can fail if its currenctly opened or doesn't exist. Either way i don't care try { Directory.Delete(MusicDataPath, true); } catch { } Directory.CreateDirectory(MusicDataPath); _google = google; }
public StatsService(ShardedDiscordClient client, CommandHandler cmdHandler) { this.client = client; Reset(); this.client.MessageReceived += _ => Task.FromResult(messageCounter++); cmdHandler.CommandExecuted += (_, e) => commandsRan++; this.client.Disconnected += _ => Reset(); }
public Gambling(ILocalization loc, CommandService cmds, ShardedDiscordClient client) : base(loc, cmds, client) { using (var uow = DbHandler.UnitOfWork()) { var conf = uow.BotConfig.GetOrCreate(); CurrencyName = conf.CurrencyName; CurrencySign = conf.CurrencySign; CurrencyPluralName = conf.CurrencyPluralName; } }
public Gambling(ILocalization loc, CommandService cmds, ShardedDiscordClient client) : base(loc, cmds, client) { using (var uow = DbHandler.UnitOfWork()) { var conf = uow.BotConfig.GetOrCreate(); CurrencyName = conf.CurrencyName; CurrencySign = conf.CurrencySign; CurrencyPluralName = conf.CurrencyPluralName; } }
public RatelimitCommand() { this._client = NadekoBot.Client; this._log = LogManager.GetCurrentClassLogger(); _client.MessageReceived += (umsg) => { var t = Task.Run(async() => { var usrMsg = umsg as IUserMessage; var usrGuild = umsg as IGuildUser; var channel = usrMsg.Channel as ITextChannel; var usr = channel.GetUser(umsg.Author.Id) as IUser; ulong[] white = new ulong[] { 208441726464032769, // administrators 240045137810554880, // moderators 240049119035523073, // devs 240049515770413057, // moderators I18n 240049523370622976 // helpers }; var roles = usrGuild.Roles; if (channel == null || usrMsg.IsAuthor() || usrMsg.Author.Id == channel.Guild.OwnerId) { return; } for (int i = 0; i <= roles.Count; i++) { for (int x = 0; x <= white.Length; x++) { var usrGuild_Roles = channel.Guild.GetRole(white[x]); var usrGuild_Roles_Members = usrGuild_Roles.Members(); foreach (IUser user_roles in usrGuild_Roles_Members) { if (usr == user_roles) { return; } } } } Ratelimiter limiter; if (!RatelimitingChannels.TryGetValue(channel.Id, out limiter)) { return; } if (limiter.CheckUserRatelimit(usrMsg.Author.Id)) { try { await usrMsg.DeleteAsync(); } catch (Exception ex) { _log.Warn(ex); } } }); return(Task.CompletedTask); }; }
public DiscordModule(ILocalization loc, CommandService cmds, ShardedDiscordClient client) { string prefix; if (NadekoBot.ModulePrefixes.TryGetValue(this.GetType().Name, out prefix)) _prefix = prefix; else _prefix = "?missing_prefix?"; _l = loc; _commands = cmds; _client = client; _log = LogManager.GetCurrentClassLogger(); }
public LogCommands(ShardedDiscordClient client) { //_client.MessageReceived += _client_MessageReceived; _client.MessageUpdated += _client_MessageUpdated; _client.MessageDeleted += _client_MessageDeleted; _client.UserBanned += _client_UserBanned; _client.UserUnbanned += _client_UserUnbanned; _client.UserJoined += _client_UserJoined; _client.UserLeft += _client_UserLeft; _client.UserPresenceUpdated += _client_UserPresenceUpdated; _client.UserVoiceStateUpdated += _client_UserVoiceStateUpdated; _client.UserUpdated += _client_UserUpdated; _client.ChannelCreated += _client_ChannelCreated; _client.ChannelDestroyed += _client_ChannelDestroyed; _client.ChannelUpdated += _client_ChannelUpdated; }
public LogCommands(ShardedDiscordClient client) { //_client.MessageReceived += _client_MessageReceived; _client.MessageUpdated += _client_MessageUpdated; _client.MessageDeleted += _client_MessageDeleted; _client.UserBanned += _client_UserBanned; _client.UserUnbanned += _client_UserUnbanned; _client.UserJoined += _client_UserJoined; _client.UserLeft += _client_UserLeft; _client.UserPresenceUpdated += _client_UserPresenceUpdated; _client.UserVoiceStateUpdated += _client_UserVoiceStateUpdated; _client.UserUpdated += _client_UserUpdated; _client.ChannelCreated += _client_ChannelCreated; _client.ChannelDestroyed += _client_ChannelDestroyed; _client.ChannelUpdated += _client_ChannelUpdated; }
public DiscordModule(ILocalization loc, CommandService cmds, ShardedDiscordClient client) { string prefix; if (FaultyBot.ModulePrefixes.TryGetValue(this.GetType().Name, out prefix)) { _prefix = prefix; } else { _prefix = "?missing_prefix?"; } _l = loc; _commands = cmds; _client = client; _log = LogManager.GetCurrentClassLogger(); }
public StatsService(ShardedDiscordClient client, CommandHandler cmdHandler) { this.client = client; Reset(); this.client.MessageReceived += _ => Task.FromResult(MessageCounter++); cmdHandler.CommandExecuted += (_, e) => CommandsRan++; this.client.Disconnected += _ => Reset(); this.carbonitexTimer = new Timer(async(state) => { if (string.IsNullOrWhiteSpace(FaultyBot.Credentials.CarbonKey)) { return; } try { using (var http = new HttpClient()) { using (var content = new FormUrlEncodedContent( new Dictionary <string, string> { { "servercount", this.client.GetGuilds().Count.ToString() }, { "key", FaultyBot.Credentials.CarbonKey } })) { content.Headers.Clear(); content.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); var res = await http.PostAsync("https://www.carbonitex.net/discord/data/botdata.php", content).ConfigureAwait(false); } }; } catch { } }, null, TimeSpan.FromHours(1), TimeSpan.FromHours(1)); }
public RatelimitCommand() { this._client = NadekoBot.Client; this._log = LogManager.GetCurrentClassLogger(); _client.MessageReceived += (umsg) => { var t = Task.Run(async () => { var usrMsg = umsg as IUserMessage; var channel = usrMsg.Channel as ITextChannel; if (channel == null || usrMsg.IsAuthor()) return; Ratelimiter limiter; if (!RatelimitingChannels.TryGetValue(channel.Id, out limiter)) return; if (limiter.CheckUserRatelimit(usrMsg.Author.Id)) try { await usrMsg.DeleteAsync(); } catch (Exception ex) { _log.Warn(ex); } }); return Task.CompletedTask; }; }
public AntiRaidCommands(ShardedDiscordClient client) { _log = LogManager.GetCurrentClassLogger(); client.MessageReceived += (imsg) => { var msg = imsg as IUserMessage; if (msg == null || msg.Author.IsBot) return Task.CompletedTask; var channel = msg.Channel as ITextChannel; if (channel == null) return Task.CompletedTask; var t = Task.Run(async () => { try { AntiSpamSetting spamSettings; if (!antiSpamGuilds.TryGetValue(channel.Guild.Id, out spamSettings)) return; var stats = spamSettings.UserStats.AddOrUpdate(msg.Author.Id, new UserSpamStats(msg.Content), (id, old) => { old.ApplyNextMessage(msg.Content); return old; }); if (stats.Count >= spamSettings.MessageThreshold) { if (spamSettings.UserStats.TryRemove(msg.Author.Id, out stats)) { await PunishUsers(spamSettings.Action, await GetMuteRole(channel.Guild), ProtectionType.Spamming, (IGuildUser)msg.Author) .ConfigureAwait(false); } } } catch { } }); return Task.CompletedTask; }; client.UserJoined += (usr) => { if (usr.IsBot) return Task.CompletedTask; AntiRaidSetting settings; if (!antiRaidGuilds.TryGetValue(usr.Guild.Id, out settings)) return Task.CompletedTask; var t = Task.Run(async () => { if (!settings.RaidUsers.Add(usr)) return; ++settings.UsersCount; if (settings.UsersCount >= settings.UserThreshold) { var users = settings.RaidUsers.ToArray(); settings.RaidUsers.Clear(); await PunishUsers(settings.Action, await GetMuteRole(usr.Guild), ProtectionType.Raiding, users).ConfigureAwait(false); } await Task.Delay(1000 * settings.Seconds).ConfigureAwait(false); settings.RaidUsers.TryRemove(usr); --settings.UsersCount; }); return Task.CompletedTask; }; }
public SelfCommands(ShardedDiscordClient client) { this._client = client; }
public Searches(ILocalization loc, CommandService cmds, ShardedDiscordClient client, IGoogleApiService youtube) : base(loc, cmds, client) { _google = youtube; }
public CustomReactions(ILocalization loc, CommandService cmds, ShardedDiscordClient client) : base(loc, cmds, client) { }
public CustomReactions(ILocalization loc, CommandService cmds, ShardedDiscordClient client) : base(loc, cmds, client) { }
public Administration(ILocalization loc, CommandService cmds, ShardedDiscordClient client) : base(loc, cmds, client) { NadekoBot.CommandHandler.CommandExecuted += DelMsgOnCmd_Handler; }
public Searches(ILocalization loc, CommandService cmds, ShardedDiscordClient client, IGoogleApiService youtube) : base(loc, cmds, client) { _google = youtube; }
public Administration(ILocalization loc, CommandService cmds, ShardedDiscordClient client) : base(loc, cmds, client) { NadekoBot.CommandHandler.CommandExecuted += DelMsgOnCmd_Handler; }
public AntiRaidCommands(ShardedDiscordClient client) { _log = LogManager.GetCurrentClassLogger(); client.MessageReceived += (imsg) => { var msg = imsg as IUserMessage; if (msg == null || msg.Author.IsBot) return Task.CompletedTask; var channel = msg.Channel as ITextChannel; if (channel == null) return Task.CompletedTask; var t = Task.Run(async () => { try { AntiSpamSetting spamSettings; if (!antiSpamGuilds.TryGetValue(channel.Guild.Id, out spamSettings)) return; var stats = spamSettings.UserStats.AddOrUpdate(msg.Author.Id, new UserSpamStats(msg.Content), (id, old) => { old.ApplyNextMessage(msg.Content); return old; }); if (stats.Count >= spamSettings.MessageThreshold) { if (spamSettings.UserStats.TryRemove(msg.Author.Id, out stats)) { await PunishUsers(spamSettings.Action, await GetMuteRole(channel.Guild), ProtectionType.Spamming, (IGuildUser)msg.Author) .ConfigureAwait(false); } } } catch { } }); return Task.CompletedTask; }; client.UserJoined += (usr) => { if (usr.IsBot) return Task.CompletedTask; AntiRaidSetting settings; if (!antiRaidGuilds.TryGetValue(usr.Guild.Id, out settings)) return Task.CompletedTask; var t = Task.Run(async () => { if (!settings.RaidUsers.Add(usr)) return; ++settings.UsersCount; if (settings.UsersCount >= settings.UserThreshold) { var users = settings.RaidUsers.ToArray(); settings.RaidUsers.Clear(); await PunishUsers(settings.Action, await GetMuteRole(usr.Guild), ProtectionType.Raiding, users).ConfigureAwait(false); } await Task.Delay(1000 * settings.Seconds).ConfigureAwait(false); settings.RaidUsers.TryRemove(usr); --settings.UsersCount; }); return Task.CompletedTask; }; }
public SelfCommands() { this._client = NadekoBot.Client; }
public CommandHandler(ShardedDiscordClient client, CommandService commandService) { _client = client; _commandService = commandService; _log = LogManager.GetCurrentClassLogger(); }
public NSFW(ILocalization loc, CommandService cmds, ShardedDiscordClient client) : base(loc, cmds, client) { }
public NSFW(ILocalization loc, CommandService cmds, ShardedDiscordClient client) : base(loc, cmds, client) { }
public SelfCommands(ShardedDiscordClient client) { this._client = client; }