Ensure no more stack overflow

This commit is contained in:
Daniel_I_Am 2020-10-16 22:25:31 +02:00
parent b87d2a2c01
commit a92e258ed6
No known key found for this signature in database
GPG Key ID: 80C428FCC9743E84

View File

@ -24,7 +24,7 @@ namespace ChaosBot.Services.ProgrammingLanguageInterpreter
public LimitedSocketUser User { get; } public LimitedSocketUser User { get; }
public LimitedSocketCommandContext(SocketCommandContext context) public LimitedSocketCommandContext(SocketCommandContext context)
{ {LoggingFacade.Trace("Reached constructor LimitedSocketCommandContext");
Channel = new LimitedISocketMessageChannel(context.Channel); Channel = new LimitedISocketMessageChannel(context.Channel);
Client = new LimitedDiscordSocketClient(context.Client); Client = new LimitedDiscordSocketClient(context.Client);
Guild = new LimitedSocketGuild(context.Guild); Guild = new LimitedSocketGuild(context.Guild);
@ -40,7 +40,7 @@ namespace ChaosBot.Services.ProgrammingLanguageInterpreter
public DateTimeOffset CreatedAt { get; } public DateTimeOffset CreatedAt { get; }
public LimitedISocketMessageChannel(ISocketMessageChannel channel) public LimitedISocketMessageChannel(ISocketMessageChannel channel)
{ {LoggingFacade.Trace("Reached constructor LimitedISocketMessageChannel");
Name = channel.Name; Name = channel.Name;
Id = channel.Id; Id = channel.Id;
CreatedAt = channel.CreatedAt; CreatedAt = channel.CreatedAt;
@ -55,7 +55,7 @@ namespace ChaosBot.Services.ProgrammingLanguageInterpreter
public UserStatus Status { get; } public UserStatus Status { get; }
public LimitedDiscordSocketClient(DiscordSocketClient client) public LimitedDiscordSocketClient(DiscordSocketClient client)
{ {LoggingFacade.Trace("Reached constructor LimitedDiscordSocketClient");
Activity = client.Activity; Activity = client.Activity;
Latency = client.Latency; Latency = client.Latency;
ShardId = client.ShardId; ShardId = client.ShardId;
@ -99,7 +99,7 @@ namespace ChaosBot.Services.ProgrammingLanguageInterpreter
public string VoiceRegionId { get; } public string VoiceRegionId { get; }
public LimitedSocketGuild(SocketGuild guild) public LimitedSocketGuild(SocketGuild guild)
{ {LoggingFacade.Trace("Reached constructor LimitedSocketGuild");
Id = guild.Id; Id = guild.Id;
AFKChannel = guild.AFKChannel == null ? null : new LimitedSocketVoiceChannel(guild.AFKChannel); AFKChannel = guild.AFKChannel == null ? null : new LimitedSocketVoiceChannel(guild.AFKChannel);
AFKTimeout = guild.AFKTimeout; AFKTimeout = guild.AFKTimeout;
@ -150,7 +150,7 @@ namespace ChaosBot.Services.ProgrammingLanguageInterpreter
public IReadOnlyCollection<LimitedSocketRole> MentionedRoles { get; } public IReadOnlyCollection<LimitedSocketRole> MentionedRoles { get; }
public IReadOnlyCollection<LimitedSocketUser> MentionedUsers { get; } public IReadOnlyCollection<LimitedSocketUser> MentionedUsers { get; }
public LimitedSocketUserMessage(SocketUserMessage message) public LimitedSocketUserMessage(SocketUserMessage message)
{ {LoggingFacade.Trace("Reached constructor LimitedSocketUserMessage");
Author = new LimitedSocketUser(message.Author); Author = new LimitedSocketUser(message.Author);
Source = message.Source; Source = message.Source;
Content = message.Content; Content = message.Content;
@ -184,7 +184,7 @@ namespace ChaosBot.Services.ProgrammingLanguageInterpreter
public string GetAvatarUrl => originalUser.GetAvatarUrl(); public string GetAvatarUrl => originalUser.GetAvatarUrl();
public LimitedSocketUser(SocketUser user) public LimitedSocketUser(SocketUser user)
{ {LoggingFacade.Trace("Reached constructor LimitedSocketUser");
originalUser = user; originalUser = user;
Id = user.Id; Id = user.Id;
@ -210,13 +210,12 @@ namespace ChaosBot.Services.ProgrammingLanguageInterpreter
public ulong Id { get; } public ulong Id { get; }
public IReadOnlyCollection<LimitedSocketGuildUser> Users { get; } public IReadOnlyCollection<LimitedSocketGuildUser> Users { get; }
public LimitedSocketGuildChannel(SocketGuildChannel channel) public LimitedSocketGuildChannel(SocketGuildChannel channel)
{ {LoggingFacade.Trace("Reached constructor LimitedSocketGuildChannel");
Name = channel.Name; Name = channel.Name;
Position = channel.Position; Position = channel.Position;
PermissionOverwrites = channel.PermissionOverwrites; PermissionOverwrites = channel.PermissionOverwrites;
CreatedAt = channel.CreatedAt; CreatedAt = channel.CreatedAt;
Id = channel.Id; Id = channel.Id;
Users = channel.Users.Select(u => new LimitedSocketGuildUser(u)).ToList();
} }
} }
@ -226,7 +225,7 @@ namespace ChaosBot.Services.ProgrammingLanguageInterpreter
public IReadOnlyCollection<LimitedSocketGuildChannel> Channels { get; } public IReadOnlyCollection<LimitedSocketGuildChannel> Channels { get; }
public LimitedSocketCategoryChannel(SocketCategoryChannel category) : base(category) public LimitedSocketCategoryChannel(SocketCategoryChannel category) : base(category)
{ {LoggingFacade.Trace("Reached constructor LimitedSocketCategoryChannel");
Channels = category.Channels.Select(c => new LimitedSocketGuildChannel(c)).ToList(); Channels = category.Channels.Select(c => new LimitedSocketGuildChannel(c)).ToList();
} }
} }
@ -239,7 +238,7 @@ namespace ChaosBot.Services.ProgrammingLanguageInterpreter
public int? UserLimit { get; } public int? UserLimit { get; }
public LimitedSocketVoiceChannel(SocketVoiceChannel channel) : base(channel) public LimitedSocketVoiceChannel(SocketVoiceChannel channel) : base(channel)
{ {LoggingFacade.Trace("Reached constructor LimitedSocketVoiceChannel");
Bitrate = channel.Bitrate; Bitrate = channel.Bitrate;
Category = new LimitedICategoryChannel(channel.Category); Category = new LimitedICategoryChannel(channel.Category);
CategoryId = channel.CategoryId; CategoryId = channel.CategoryId;
@ -257,7 +256,7 @@ namespace ChaosBot.Services.ProgrammingLanguageInterpreter
public string Topic { get; } public string Topic { get; }
public LimitedSocketTextChannel(SocketTextChannel channel) : base(channel) public LimitedSocketTextChannel(SocketTextChannel channel) : base(channel)
{ {LoggingFacade.Trace("Reached constructor LimitedSocketTextChannel");
Category = new LimitedICategoryChannel(channel.Category); Category = new LimitedICategoryChannel(channel.Category);
CategoryId = channel.CategoryId; CategoryId = channel.CategoryId;
IsNsfw = channel.IsNsfw; IsNsfw = channel.IsNsfw;
@ -283,7 +282,7 @@ namespace ChaosBot.Services.ProgrammingLanguageInterpreter
public SocketVoiceState? VoiceState { get; } public SocketVoiceState? VoiceState { get; }
public LimitedSocketGuildUser(SocketGuildUser user) : base(user) public LimitedSocketGuildUser(SocketGuildUser user) : base(user)
{ {LoggingFacade.Trace("Reached constructor LimitedSocketGuildUser");
GuildPermissions = user.GuildPermissions; GuildPermissions = user.GuildPermissions;
Hierarchy = user.Hierarchy; Hierarchy = user.Hierarchy;
IsDeafened = user.IsDeafened; IsDeafened = user.IsDeafened;
@ -313,7 +312,7 @@ namespace ChaosBot.Services.ProgrammingLanguageInterpreter
public GuildPermissions Permissions { get; } public GuildPermissions Permissions { get; }
public int Position { get; } public int Position { get; }
public LimitedSocketRole(SocketRole role) public LimitedSocketRole(SocketRole role)
{ {LoggingFacade.Trace("Reached constructor LimitedSocketRole");
Id = role.Id; Id = role.Id;
Color = role.Color; Color = role.Color;
CreatedAt = role.CreatedAt; CreatedAt = role.CreatedAt;
@ -340,7 +339,7 @@ namespace ChaosBot.Services.ProgrammingLanguageInterpreter
public IReadOnlyList<ulong> RoleIds { get; } public IReadOnlyList<ulong> RoleIds { get; }
public LimitedGuildEmote(GuildEmote emote) public LimitedGuildEmote(GuildEmote emote)
{ {LoggingFacade.Trace("Reached constructor LimitedGuildEmote");
Name = emote.Name; Name = emote.Name;
Id = emote.Id; Id = emote.Id;
Animated = emote.Animated; Animated = emote.Animated;
@ -362,7 +361,7 @@ namespace ChaosBot.Services.ProgrammingLanguageInterpreter
public DateTimeOffset CreatedAt { get; } public DateTimeOffset CreatedAt { get; }
public ulong Id { get; } public ulong Id { get; }
public LimitedICategoryChannel(ICategoryChannel category) public LimitedICategoryChannel(ICategoryChannel category)
{ {LoggingFacade.Trace("Reached constructor LimitedICategoryChannel");
Position = category.Position; Position = category.Position;
GuildId = category.GuildId; GuildId = category.GuildId;
PermissionOverwrites = category.PermissionOverwrites; PermissionOverwrites = category.PermissionOverwrites;