public WorkService() { _daysToBeLockedOut = SettingsHandler.LoadValueInt("daysToBeLockedOut", JsonFile.PayWork); _daysToRemoveMessage = SettingsHandler.LoadValueInt("daysToRemoveMessage", JsonFile.PayWork); _lookingForWorkChannel = SettingsHandler.LoadValueUlong("looking-for-work", JsonFile.PayWork); _hiringChannel = SettingsHandler.LoadValueUlong("hiring", JsonFile.PayWork); _collaborationChannel = SettingsHandler.LoadValueUlong("collaboration", JsonFile.PayWork); }
public async Task OnMessageAdded(SocketMessage messageParam) { IChannel channel = messageParam.Channel; Work work = null; bool flag = false; if (channel.Id == _lookingForWorkChannel) { if (messageParam.Author.IsBot) { return; } flag = true; work = new Work(messageParam.Author as IGuildUser, messageParam.Timestamp.DateTime, messageParam, messageParam.Channel, SettingsHandler.LoadValueUlong("looking-for-work:mute", JsonFile.PayWork)); await UserRemoveAccess(work); await MessageRemove(work); await DuplicateUserMsg(work.Channel, work.User, messageParam.Timestamp, messageParam.Content, work.User.Username, work.User.GetAvatarUrl()); } else if (!flag && channel.Id == _hiringChannel) { if (messageParam.Author.IsBot) { return; } flag = true; work = new Work(messageParam.Author as IGuildUser, messageParam.Timestamp.DateTime, messageParam, messageParam.Channel, SettingsHandler.LoadValueUlong("hiring:mute", JsonFile.PayWork)); await UserRemoveAccess(work); await MessageRemove(work); await DuplicateUserMsg(work.Channel, work.User, messageParam.Timestamp, messageParam.Content, work.User.Username, work.User.GetAvatarUrl()); } else if (!flag && channel.Id == _collaborationChannel) { if (messageParam.Author.IsBot) { return; } flag = true; work = new Work(messageParam.Author as IGuildUser, messageParam.Timestamp.DateTime, messageParam, messageParam.Channel, SettingsHandler.LoadValueUlong("collaboration:mute", JsonFile.PayWork)); await UserRemoveAccess(work); await MessageRemove(work); await DuplicateUserMsg(work.Channel, work.User, messageParam.Timestamp, messageParam.Content, work.User.Username, work.User.GetAvatarUrl()); } if (flag) { allWork.Add(work); } }
private async Task UserJoined(SocketGuildUser user) { ulong general = SettingsHandler.LoadValueUlong("generalChannel/id", JsonFile.Settings); var socketTextChannel = _client.GetChannel(general) as SocketTextChannel; _databaseService.AddNewUser(user); //Check for existing mute if (_userService._mutedUsers.HasUser(user.Id)) { await user.AddRoleAsync(Settings.GetMutedRole(user.Guild)); await _loggingService.LogAction( $"Currently muted user rejoined - {user.Mention} - `{user.Username}#{user.DiscriminatorValue}` - ID : `{user.Id}`"); await socketTextChannel.SendMessageAsync($"{user.Mention} tried to rejoin the server to avoid their mute. Mute time increased by 72 hours."); _userService._mutedUsers.AddCooldown(user.Id, hours: 72); return; } await _loggingService.LogAction( $"User Joined - {user.Mention} - `{user.Username}#{user.DiscriminatorValue}` - ID : `{user.Id}`"); Embed em = _userService.WelcomeMessage(user.GetAvatarUrl(), user.Username, user.DiscriminatorValue); if (socketTextChannel != null) { await socketTextChannel.SendMessageAsync(string.Empty, false, em); } string globalRules = Settings.GetRule(0).content; IDMChannel dm = await user.GetOrCreateDMChannelAsync(); await dm.SendMessageAsync( "Hello and welcome to Unity Developer Hub !\nHope you enjoy your stay.\nHere are some rules to respect to keep the community friendly, please read them carefully.\n" + "Please also read the additional informations in the **#welcome** channel." + "You can get all the available commands on the server by typing !help in the **#bot-commands** channel."); await dm.SendMessageAsync(globalRules); //TODO: add users when bot was offline }
public async Task <string> ValidatePackageWithCode(IUser user, uint packageId, string code) { string c; if (!_verificationCodes.TryGetValue(packageId, out c)) { return("An error occured while trying to validate your package. Please verify your packageId is valid"); } if (c != code) { return("The verification code is not valid. Please verify it and try again."); } var u = user as SocketGuildUser; IRole publisher = u.Guild.GetRole(SettingsHandler.LoadValueUlong("publisherRoleID", JsonFile.Settings)); await u.AddRoleAsync(publisher); _databaseService.AddPublisherPackage(user.Username, user.DiscriminatorValue.ToString(), user.Id.ToString(), packageId); return("Your package has been verified and added to the daily advertisement list."); }
public static ulong GetMusicCommandsChannel() { return(SettingsHandler.LoadValueUlong("musicCommandsChannel/id", JsonFile.Settings)); }
public static ulong GetCasinoChannel() { return(SettingsHandler.LoadValueUlong("casinoChannel/id", JsonFile.Settings)); }
public static ulong GetAnimeChannel() { return(SettingsHandler.LoadValueUlong("animeChannel/id", JsonFile.Settings)); }
public static ulong GetUnityNewsChannel() { return(SettingsHandler.LoadValueUlong("unityNewsChannel/id", JsonFile.Settings)); }
public static ulong GetBotAnnouncementChannel() { return(SettingsHandler.LoadValueUlong("botAnnouncementChannel/id", JsonFile.Settings)); }
public static IRole GetMutedRole(IGuild guild) { return(guild.Roles.Single(x => x.Id == SettingsHandler.LoadValueUlong("mutedRoleID", JsonFile.Settings))); }