public GuildDataSerializableContainer(GuildData data) { ParentCategoryContainer = new SnowflakeContainer <DiscordChannel>(data.ParentCategory); CommandListenChannelContainer = new SnowflakeContainer <DiscordChannel>(data.CommandListenChannel); WaitingRoomVCContainer = new SnowflakeContainer <DiscordChannel>(data.WaitingRoomVC); MemberRoleContainer = new SnowflakeContainer <DiscordRole>(data.MemberRole); MutedRoleContainer = new SnowflakeContainer <DiscordRole>(data.MutedRole); BotManagerRoleContainer = new SnowflakeContainer <DiscordRole>(data.MutedRole); EveryonePermission = data.EveryonePermission; CreatedChannelsContainer = new Dictionary <ulong, List <SnowflakeContainer <DiscordChannel> > >(); RolewisePermissionContainer = new Dictionary <ulong, VoiceChannelCreationPermissions>(); MemberwisePermissionContainer = new Dictionary <ulong, VoiceChannelCreationPermissions>(); foreach (KeyValuePair <DiscordMember, List <DiscordChannel> > kvp in data.CreatedChannels) { KeyValuePair <ulong, List <SnowflakeContainer <DiscordChannel> > > newAdd = new KeyValuePair <ulong, List <SnowflakeContainer <DiscordChannel> > >(kvp.Key.Id, new List <SnowflakeContainer <DiscordChannel> >()); foreach (DiscordChannel channel in kvp.Value) { newAdd.Value.Add(new SnowflakeContainer <DiscordChannel>(channel)); } CreatedChannelsContainer.Add(newAdd.Key, newAdd.Value); } foreach (KeyValuePair <DiscordRole, VoiceChannelCreationPermissions> kvp in data.RolewisePermissions) { RolewisePermissionContainer.Add(kvp.Key.Id, kvp.Value); } foreach (KeyValuePair <DiscordMember, VoiceChannelCreationPermissions> kvp in data.MemberwisePermissions) { MemberwisePermissionContainer.Add(kvp.Key.Id, kvp.Value); } }
public void Write(GamePacketWriter writer) { GuildData.Write(writer); Self.Write(writer); SelfPrivate.Write(writer); writer.Write(Nameplate); }
/// <summary> /// 获取公共信息 /// </summary> /// <param name="pt"></param> protected void S2C_GuildInfo(Pt pt) { //Debug.Log("S2C_GuildInfo"); pt_guild_info_d380 info = pt as pt_guild_info_d380; if (info.lev == 0) { return; } if (info != null) { GuildData data = new GuildData(info); if (myGuildInfo == null) { GuildInfo guildInfo = new GuildInfo(data); myGuildInfo = guildInfo; } else { myGuildInfo.UpdateServerData(data); } if (OnGetPublicEvent != null) { OnGetPublicEvent(); } } }
public async Task VoteAsync() { GuildData g_data = GuildCenter.GetGuild(Context.Guild.Id); // if id == 0 then the guild's info doesnt exist if (g_data.Id != 0 && g_data.werdData.gameStarted) // check for condition stated above { if (g_data.werdData.votes >= g_data.werdData.players.Count / 3 * 2) { // if 2/3 of the players vote to end the game it can end without admin intervention g_data.werdData.gameStarted = false; await ReplyAsync($"The vote to end the game has passed."); await ReplyAsync("Game over.", true); // experimental return; } else { g_data.werdData.votes++; } } else { await ReplyAsync($"{Context.User.Mention} ... erm... You can't vote to end a match that doesn't exist...\n" + $"My faith in mankind has just lowered considerably :face_palm:"); } }
public void UpdateData(GuildData newConfig) { var collection = Database.GetCollection <GuildData>("guilds"); collection.EnsureIndex(s => s.Id, true); collection.Update(newConfig); }
public async UniTaskVoid IncreaseGuildExp(IPlayerCharacterData playerCharacter, int exp) { #if UNITY_STANDALONE && !CLIENT_BUILD ValidateGuildRequestResult validateResult = this.CanIncreaseGuildExp(playerCharacter, exp); if (!validateResult.IsSuccess) { return; } AsyncResponseData <GuildResp> resp = await DbServiceClient.IncreaseGuildExpAsync(new IncreaseGuildExpReq() { GuildId = validateResult.GuildId, Exp = exp, }); if (!resp.IsSuccess) { return; } GuildData guild = resp.Response.GuildData; SetGuild(validateResult.GuildId, guild); // Broadcast via chat server if (ClusterClient.IsNetworkActive) { ClusterClient.SendSetGuildLevelExpSkillPoint(MMOMessageTypes.UpdateGuild, guild.id, guild.level, guild.exp, guild.skillPoint); } GameInstance.ServerGameMessageHandlers.SendSetGuildLevelExpSkillPointToMembers(guild); #endif }
public MessageReceivedEventArgs(SocketMessage s, IServiceProvider provider) { Message = s.Cast <SocketUserMessage>() ?? throw new ArgumentException($"{nameof(s)} is not a SocketUserMessage; aborting event handler call."); provider.Get(out _db); Context = VolteContext.Create(s, provider); Data = _db.GetData(Context.Guild); }
protected override void BeforeExecute(CommandInfo command) { dataContext = new WaitingListDataContext(); waitingList = new CommandWaitingList(dataContext, Context.Client.Rest, Context.Guild.Id); guildData = dataContext.GetOrCreateGuildData(Context.Guild) !; base.BeforeExecute(command); }
public void Save(GuildData newConfig) { _guildData.LockedRef(coll => { _guildData.EnsureIndex(s => s.Id, true); _guildData.Update(newConfig); }); }
public async Task SetPrefix(CommandContext ctx, string prefix) { GuildData guildData = Database.GetOrCreateGuildData(ctx.Guild.Id); guildData.GuildPrefix = prefix; guildData.FlushData(); await ctx.RespondAsync($"Set prefix for this server: `{prefix}`."); }
//save given GuildData to "DeltaCORE\Guild\" in its JSON file public void SaveGuildData(GuildData data) { //Console.WriteLine(data.name + " " + data.roles); string jsonSavString = JsonSerializer.Serialize(data, options); //Console.WriteLine(jsonSavString); File.WriteAllText(guildFolder + data.Name + ".json", jsonSavString); }
public CommandWaitingList(WaitingListDataContext dataContext, DiscordSocketRestClient restClient, ulong guildId) { this.dataContext = dataContext; this.restClient = restClient; this.guildId = guildId; this.guildData = dataContext.GetGuild(guildId) !; }
public void UpdateData(GuildData newConfig) { _logger.Debug(LogSource.Volte, $"Updating data for guild {newConfig.Id}"); var collection = Database.GetCollection <GuildData>("guilds"); collection.EnsureIndex(s => s.Id, true); collection.Update(newConfig); }
public async Task RemoveBot(params string[] args) { if (!(args.Length == 2)) { await ReplyAsync("Please use the right number of arguments."); return; } if (ulong.TryParse(args[0], out ulong id)) { Submission toRemove; GuildData guildData = data.GetGuild(Context.Guild.Id); if (guildData != null) { if (args[1] == "archives") { toRemove = guildData.GetSubmissionFromArchives(id); if (toRemove != null) { guildData.archive.Remove(toRemove); StoreData(id); await ReplyAsync("Successfully removed submission from the archives list."); } else { await ReplyAsync("Could not find bot in archives list."); } } else if (args[1] == "pending") { toRemove = guildData.GetSubmissionFromQueue(id); if (toRemove != null) { guildData.queue.Remove(toRemove); StoreData(id); await ReplyAsync("Successfully removed submission from the pending list."); } else { await ReplyAsync("Could not find bot in pending list."); } } else { await ReplyAsync("Please specify either archives or pending lists."); } } else { await ReplyAsync("Error getting guild data."); } } else { await ReplyAsync("Please type a valid bot id."); } }
static async Task MemberJoined(DiscordClient client, GuildMemberAddEventArgs e) { GuildData guildData = Database.GetOrCreateGuildData(e.Guild.Id); foreach (ulong roleId in guildData.RolesToAssignOnJoin) { await e.Member.GrantRoleAsync(e.Guild.GetRole(roleId)); } }
public static GuildData Instance() { if (intance_ == null) { intance_ = new GuildData(); } return(intance_); }
private static async Task <DiscordChannel> GetLogChannel(DiscordClient client, ulong guildId) { var logChannelId = GuildData.GetLogChannel(guildId); if (logChannelId == 0) { return(null); } return(await client.GetChannelAsync(logChannelId)); }
public void SetGuild(int guildId, GuildData guildData) { if (Guilds.ContainsKey(guildId)) { Guilds[guildId] = guildData; } else { Guilds.TryAdd(guildId, guildData); } }
public async Task CommandPrefix() { GuildDataIO io = new GuildDataIO(Context.Guild.Id); GuildData guildData = io.Read(); await ReplyAsync(string.Empty, false, new EmbedBuilder() { Description = string.Format("Current prefix is `{0}`", guildData.CommandPrefix), Color = Color.Green }.Build()); }
/// <summary> /// 初次创建公会 /// </summary> /// <param name="gArea">公会所在区域</param> /// <param name="gName">公会名称</param> /// <returns>状态值 /// 0:正常创建 /// 1:该群公会已存在,更新信息 /// </returns> public int createGuild(string gArea, string gName, long gId) { try { int retCode = -1; using SqlSugarClient dbClient = SugarUtils.CreateSqlSugarClient(DBPath); var data = new GuildData() { GuildName = gName, ServerArea = gArea, Gid = gId }; if (dbClient.Queryable <GuildData>().Where(i => i.Gid == gId).Any()) { retCode = 1; dbClient.Updateable <GuildData>(data).Where(i => i.Gid == gId).ExecuteCommand(); } else { retCode = 0; dbClient.Insertable <GuildData>(data).ExecuteCommand(); } //TODO 改用ORM // SQLiteHelper dbHelper = new SQLiteHelper(DBPath); // dbHelper.OpenDB(); // if (Convert.ToBoolean(dbHelper.GetCount(GuildTableName, GPrimaryColName, GuildId))) //查找是否有记录 // { // //已存在,则更新信息 // dbHelper.UpdateData(GuildTableName, "name", gName, GPrimaryColName, GuildId); // dbHelper.UpdateData(GuildTableName, "server", gArea, GPrimaryColName, GuildId); // dbHelper.CloseDB(); // return 1; // } // else //未找到,初次创建 // { // string[] GuildInitData = //创建用户初始化数据数组 // { // GroupId.ToString(), //所在群号 // gName, //公会名 // gArea //所在区服 // }; // dbHelper.InsertRow(GuildTableName, GColName, GuildInitData); //向数据库写入新数据 // dbHelper.CloseDB(); // return 0; // } return(retCode); } catch (Exception) { throw; } }
public override GuildData ReadGuild(int id, GuildRoleData[] defaultGuildRoles) { GuildData result = null; MySQLRowsReader reader = ExecuteReader("SELECT * FROM guild WHERE id=@id LIMIT 1", new MySqlParameter("@id", id)); if (reader.Read()) { result = new GuildData(id, reader.GetString("guildName"), reader.GetString("leaderId"), defaultGuildRoles); result.level = reader.GetInt16("level"); result.exp = reader.GetInt32("exp"); result.skillPoint = reader.GetInt16("skillPoint"); result.guildMessage = reader.GetString("guildMessage"); result.gold = reader.GetInt32("gold"); reader = ExecuteReader("SELECT * FROM guildrole WHERE guildId=@id", new MySqlParameter("@id", id)); byte guildRole; GuildRoleData guildRoleData; while (reader.Read()) { guildRole = reader.GetByte("guildRole"); guildRoleData = new GuildRoleData(); guildRoleData.roleName = reader.GetString("name"); guildRoleData.canInvite = reader.GetBoolean("canInvite"); guildRoleData.canKick = reader.GetBoolean("canKick"); guildRoleData.shareExpPercentage = reader.GetByte("shareExpPercentage"); result.SetRole(guildRole, guildRoleData); } reader = ExecuteReader("SELECT id, dataId, characterName, level, guildRole FROM characters WHERE guildId=@id", new MySqlParameter("@id", id)); SocialCharacterData guildMemberData; while (reader.Read()) { // Get some required data, other data will be set at server side guildMemberData = new SocialCharacterData(); guildMemberData.id = reader.GetString("id"); guildMemberData.characterName = reader.GetString("characterName"); guildMemberData.dataId = reader.GetInt32("dataId"); guildMemberData.level = reader.GetInt16("level"); result.AddMember(guildMemberData, reader.GetByte("guildRole")); } reader = ExecuteReader("SELECT dataId, level FROM guildskill WHERE guildId=@id", new MySqlParameter("@id", id)); while (reader.Read()) { result.SetSkillLevel(reader.GetInt32("dataId"), reader.GetInt16("level")); } } return(result); }
public async Task DefaultChannelAsync(SocketChannel channel) { GuildData g_data = GuildCenter.GetGuild(Context.Guild.Id); if (g_data.Id == 0) { g_data = new GuildData(Context.Guild.Id, Context.Guild.Name); } g_data.defaultChannel = channel.Id; GuildCenter.Guilds.Add(g_data); GuildCenter.SaveGuilds(); await ReplyAsync(Context.User.Mention + ", guild settings updated."); }
private void MobileClientGuildMemberLoggedOutHandler(MobileClientGuildMemberLoggedOut msg) { Debug.Log(string.Concat(new string[] { "Guild member ", msg.Member.Name, " (", msg.Member.Guid, ") logged out." })); GuildData.RemoveGuildMember(msg.Member.Guid); this.allPanels.adventureMapPanel.m_guildChatSlider_Bottom.UpdateGuildMateRoster(); }
public void SetData(GuildData _data) { if (nameLab != null) { nameLab.text = _data.guildName; } if (chairManNameLab != null) { chairManNameLab.text = _data.presidentName; } if (numLab != null) { numLab.text = _data.memberAmount.ToString() + "/" + _data.totalMemAmount; } if (levelLab != null) { levelLab.text = _data.guildLevel.ToString(); } if (fightVal != null) { fightVal.text = _data.guildFightValue.ToString(); } if (noGuildObj != null) { noGuildObj.gameObject.SetActive(!GameCenter.mainPlayerMng.MainPlayerInfo.HavaGuild); } if (havaGuildObj != null) { havaGuildObj.gameObject.SetActive(GameCenter.mainPlayerMng.MainPlayerInfo.HavaGuild); } if (rankLab != null) { rankLab.text = _data.guildRank.ToString(); } if (noGuildObj != null && applyBtn != null) { applyBtn.isEnabled = !_data.haveJoined; UIEventListener.Get(applyBtn.gameObject).onClick = (x) => { GameCenter.guildMng.C2S_JoinGuild(_data.guildId); }; } if (checkBtn != null) { UIEventListener.Get(checkBtn.gameObject).onClick = (x) => { GameCenter.guildMng.C2S_JoinGuild(_data.guildId); }; } }
public async UniTaskVoid HandleRequestIncreaseGuildSkillLevel(RequestHandlerData requestHandler, RequestIncreaseGuildSkillLevelMessage request, RequestProceedResultDelegate <ResponseIncreaseGuildSkillLevelMessage> result) { #if UNITY_STANDALONE && !CLIENT_BUILD await UniTask.Yield(); IPlayerCharacterData playerCharacter; if (!GameInstance.ServerUserHandlers.TryGetPlayerCharacter(requestHandler.ConnectionId, out playerCharacter)) { result.InvokeError(new ResponseIncreaseGuildSkillLevelMessage() { message = UITextKeys.UI_ERROR_NOT_LOGGED_IN, }); return; } ValidateGuildRequestResult validateResult = GameInstance.ServerGuildHandlers.CanIncreaseGuildSkillLevel(playerCharacter, request.dataId); if (!validateResult.IsSuccess) { result.InvokeError(new ResponseIncreaseGuildSkillLevelMessage() { message = validateResult.GameMessage, }); return; } // Save to database AsyncResponseData <GuildResp> updateResp = await DbServiceClient.AddGuildSkillAsync(new AddGuildSkillReq() { GuildId = validateResult.GuildId, SkillId = request.dataId, }); if (!updateResp.IsSuccess) { result.InvokeError(new ResponseIncreaseGuildSkillLevelMessage() { message = UITextKeys.UI_ERROR_INTERNAL_SERVER_ERROR, }); return; } GuildData guild = updateResp.Response.GuildData; GameInstance.ServerGuildHandlers.SetGuild(validateResult.GuildId, guild); // Broadcast via chat server if (ClusterClient.IsNetworkActive) { ClusterClient.SendSetGuildSkillLevel(MMOMessageTypes.UpdateGuild, validateResult.GuildId, request.dataId, guild.GetSkillLevel(request.dataId)); ClusterClient.SendSetGuildLevelExpSkillPoint(MMOMessageTypes.UpdateGuild, validateResult.GuildId, guild.level, guild.exp, guild.skillPoint); } GameInstance.ServerGameMessageHandlers.SendSetGuildSkillLevelToMembers(guild, request.dataId); GameInstance.ServerGameMessageHandlers.SendSetGuildLevelExpSkillPointToMembers(guild); result.InvokeSuccess(new ResponseIncreaseGuildSkillLevelMessage()); #endif }
public GuildData GetData(ulong id) { return(_guildData.ValueLock(() => { var conf = _guildData.FindOne(g => g.Id == id); if (conf != null) { return conf; } var newConf = GuildData.CreateFrom(_client.GetGuild(id)); _guildData.Insert(newConf); return newConf; })); }
private string GetPrefix(ulong guildId) { if (GuildPrefixes.TryGetValue(guildId, out string prefix)) { return(prefix); } var p = GuildData.GetPrefix(guildId); if (!string.IsNullOrEmpty(p)) { GuildPrefixes.TryAdd(guildId, p); } return(p); }
public async Task StartAsync() { GuildData g_data = GuildCenter.GetGuild(Context.Guild.Id); if (g_data.Id == 0) // check to make sure the guild exists in memory { GuildCenter.Guilds.Add(new GuildData(Context.Guild.Id, Context.Guild.Name)); g_data = GuildCenter.GetGuild(Context.Guild.Id); // no need to check this time } g_data.werdData = new WerdData(guildId: Context.Guild.Id, werd: GenerateWerd()); g_data.werdData.gameStarted = true; await ReplyAsync("A five letter word has been selected! ``$rules`` to learn how to play. " + "Guess away.... :smile:"); }
async Task AddSubmission(Submission submission, ulong guildId) { GuildData guild = data.GetGuild(guildId); if (guild != null) { guild.queue.Add(submission); StoreData(guildId); await Context.Channel.SendMessageAsync("Submission sent!"); } else { await Context.Channel.SendMessageAsync("Could not submit."); } }
async Task AddSubmission(Submission submission, ulong guildId) { GuildData guild = data.GetGuild(guildId); if (guild != null) { guild.queue.Add(submission); StoreData(guildId); await Context.Channel.SendMessageAsync("Podsumowanie wysłane!"); } else { await Context.Channel.SendMessageAsync("Nie udało mi się podsumować..."); } }