public EQDKPService(ulong guildId) : base(guildId) { //dont fetch for default guild id if (guildId == ulong.MaxValue) { return; } var json = File.ReadAllText(EQDKP_PATH); var eqdkp = JsonConvert.DeserializeObject <JObject>(json); if (eqdkp.TryGetValue(GuildId.ToString(), out var guildSettings)) { var apiKey = guildSettings.Value <string>("ApiKey"); var baseUrl = guildSettings.Value <string>("BaseUrl"); HttpClient = new HttpClient { BaseAddress = new Uri(baseUrl) }; HttpClient.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", apiKey); CharacterCache = new Dictionary <string, int>(StringComparer.OrdinalIgnoreCase); var unused = PrefetchCharacterIds(); } else { Log.Error("EQDKP Service created without required guild settings."); } }
protected virtual void NetFuncSelectNpcDialogGuildStorageMenu(int menuIndex) { if (currentNpcDialog == null || currentNpcDialog.type != NpcDialogType.GuildStorage) { currentNpcDialog = null; RequestShowNpcDialog(0); return; } switch (menuIndex) { case NpcDialog.STORAGE_CONFIRM_MENU_INDEX: OpenStorage(StorageType.Guild, GuildId.ToString()); currentNpcDialog = null; break; case NpcDialog.STORAGE_CANCEL_MENU_INDEX: currentNpcDialog = currentNpcDialog.storageCancelDialog; break; } if (currentNpcDialog == null) { RequestShowNpcDialog(0); } else { RequestShowNpcDialog(currentNpcDialog.DataId); } }
public async Task <Guild?> GetGuildAsync() { if (GuildId == null) { return(null); } return(Guild ??= await Client.Cache.Guilds.GetAsync(GuildId.ToString() !)); }
public async Task CacheAsync() { var channelTask = GuildId == null ? Client.Cache.Channels.SetNullableAsync(Channel) : Client.Cache.GuildChannels.SetNullableAsync(Channel as CoreGuildChannel, GuildId.ToString()); var authorTask = Client.Cache.Users.SetNullableAsync(Author); var memberTask = Client.Cache.GuildMembers.SetNullableAsync(Member, GuildId.ToString()); var messageTask = Client.Cache.Messages.SetAsync(this, ChannelId.ToString()); await Task.WhenAll(channelTask, authorTask, memberTask, messageTask); }
/// <summary> /// Gets the hash code for this <see cref="CommandCooldownBucket"/>. /// </summary> /// <returns>The hash code for this <see cref="CommandCooldownBucket"/>.</returns> public override int GetHashCode() { int hash = 13; hash = (hash * 7) + UserId.GetHashCode(); hash = (hash * 7) + ChannelId.GetHashCode(); hash = (hash * 7) + GuildId.GetHashCode(); return(hash); }
public override int GetHashCode() { unchecked { var hashCode = Key != null?Key.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (int)KeyScope; hashCode = (hashCode * 397) ^ ForumUserId.GetHashCode(); hashCode = (hashCode * 397) ^ DiscordUserId.GetHashCode(); hashCode = (hashCode * 397) ^ GuildId.GetHashCode(); hashCode = (hashCode * 397) ^ CreatedAt.GetHashCode(); return(hashCode); } }
public bool Equals(Message other) { return(Id.Equals(other.Id) && ChannelId.Equals(other.ChannelId) && GuildId.Equals(other.GuildId) && Author.Equals(other.Author) && Member.Equals(other.Member) && Content == other.Content && Timestamp.Equals(other.Timestamp) && Nullable.Equals(EditedTimestamp, other.EditedTimestamp) && TTS == other.TTS && MentionEveryone == other.MentionEveryone && Equals(Mentions, other.Mentions) && Equals(MentionRoles, other.MentionRoles) && Equals(MentionChannels, other.MentionChannels) && Equals(Attachments, other.Attachments) && Equals(Embeds, other.Embeds) && Equals(Reactions, other.Reactions) && Pinned == other.Pinned && Nullable.Equals(WebhookId, other.WebhookId) && Type == other.Type && Nullable.Equals(Activity, other.Activity) && Nullable.Equals(Application, other.Application) && Nullable.Equals(MessageReference, other.MessageReference) && Flags == other.Flags); }
// Methods public void Save() { RavenGuild old = RavenDb.GetGuild(GuildId); if (old != null) { RavenDb.UpdateGuild(old, this); } using (var session = RavenStore.Store.OpenSession()) { session.Store(this, GuildId.ToString()); session.SaveChanges(); } }
public async Task <Channel?> GetChannelAsync() { return(Channel ??= GuildId == null ? await Client.Cache.Channels.GetAsync(ChannelId.ToString()) : await Client.Cache.GuildChannels.GetAsync(ChannelId.ToString(), GuildId.ToString())); }
public async Task <GuildMember?> GetMemberAsync() { return(Member ??= await Client.Cache.GuildMembers.GetAsync(AuthorId.ToString(), GuildId.ToString())); }
public bool Equals(ChannelMention other) { return(Id.Equals(other.Id) && GuildId.Equals(other.GuildId) && Type == other.Type && Name == other.Name); }
public async Task <Guild?> GetGuildAsync(IClient client) { return(Guild ??= await client.Cache.Guilds.GetAsync(GuildId.ToString())); }
public async Task <IActionResult> CreateExisting(ulong roleId, ulong channelId, string courseName) { DiscordUserInfo currentUser = null; try { currentUser = await GetAuthenticatedUserInfoAsync(); } catch (HttpException httpEx) when(httpEx.HttpCode == HttpStatusCode.Unauthorized) { logger.LogError(httpEx, "Unhandled Discord HTTP Exception"); return(Unauthorized("Something broke, your login may be unauthorized.")); } catch (HttpException httpEx) when(httpEx.HttpCode == HttpStatusCode.NotFound) { logger.LogError(httpEx, "Unhandled Discord HTTP Exception"); return(NotFound("Something wasn't found.")); } catch (HttpException httpEx) { logger.LogError(httpEx, "Unhandled Discord HTTP Exception"); throw; } if (currentUser == null) { logger.LogError("Current User is null, this indicates some issue with logging in."); return(Unauthorized("Unable to log in.")); } if (!currentUser.InGuild) { return(Unauthorized("You are not a member of this server.")); } if (!currentUser.IsAdmin) { return(Unauthorized("You must be an admin to view this page.")); } var exists = await CheckExistsAndValidAsync(roleId, channelId); if (!exists) { return(BadRequest("Either the role or channel Id did not exist in this guild, or the role had permissions that could not be granted.")); } courseName = NormalizeCourseChannelName(courseName); var courseEntity = new CourseEntity() { GuildId = GuildId.ToString(), CourseId = courseName, ChannelId = channelId.ToString(), RoleId = roleId.ToString(), }; var storage = GetStorageUtil(); var table = await storage.GetCourseTableAsync(); var operation = TableOperation.InsertOrMerge(courseEntity); await table.ExecuteAsync(operation); // show the list return(await Index()); }
public override int GetHashCode() => GuildId.GetHashCode();
public override string ToString() { return($"Guild: {GuildId.ToString()}, id: {Id.ToString()}, name: \"{Name}\""); }
public async Task <CoreGuild?> GetGuildAsync() { return(await Client.Cache.Guilds.GetAsync(GuildId.ToString())); }
public async Task <GuildChannel?> GetChannelAsync() { return(await Client.Cache.GuildChannels.GetAsync(GuildId.ToString())); }
public override string ToString() { return(GuildId.ToString()); }
public async Task<CoreGuild?> GetGuildAsync() { if (GuildId == null) return null; return Guild ??= await Client.Cache.Guilds.GetAsync(GuildId.ToString()!); }