mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-05-03 04:29:54 +03:00
Use TryGetValue instead of ContainsKey and retrieving afterwards
This commit is contained in:
parent
59d9423b5f
commit
7afd00bf30
4 changed files with 9 additions and 9 deletions
|
@ -65,7 +65,7 @@ public static class Utils {
|
|||
|
||||
public static SocketRole? GetMuteRole(SocketGuild guild) {
|
||||
var id = ulong.Parse(Boyfriend.GetGuildConfig(guild.Id)["MuteRole"]);
|
||||
if (MuteRoleCache.ContainsKey(id)) return MuteRoleCache[id];
|
||||
if (MuteRoleCache.TryGetValue(id, out var cachedMuteRole)) return cachedMuteRole;
|
||||
SocketRole? role = null;
|
||||
foreach (var x in guild.Roles) {
|
||||
if (x.Id != id) continue;
|
||||
|
@ -97,7 +97,7 @@ public static class Utils {
|
|||
public static string GetMessage(string name) {
|
||||
var propertyName = name;
|
||||
name = $"{Messages.Culture}/{name}";
|
||||
if (ReflectionMessageCache.ContainsKey(name)) return ReflectionMessageCache[name];
|
||||
if (ReflectionMessageCache.TryGetValue(name, out var cachedMessage)) return cachedMessage;
|
||||
|
||||
var toReturn =
|
||||
typeof(Messages).GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Static)?.GetValue(null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue