public void SetLanguage(IMessageChannel channel, IUserMessage message, string lang, bool channelOnly = false) { var culture = GetCatalog(new CultureInfo(lang)).CultureInfo; switch (channel) { case IDMChannel dm: Preference.GetUserPreference(dm.Recipient.Id).SetLanguage(lang, message); break; case IGroupChannel group: Preference.GetGroupPreference(group.Id).SetLanguage(lang, message); break; case IGuildChannel guild: Preference.GetGuildPreference(guild.GuildId).SetLanguage(lang, message, channelOnly ? channel.Id : 0); break; default: throw new ArgumentException(); } }
public Catalog GetCatalog(IMessageChannel channel) { try { switch (channel) { case IDMChannel dm: return(GetCatalog(Preference.GetUserPreference(dm.Recipient.Id).CultureInfo)); case IGroupChannel group: return(GetCatalog(Preference.GetGroupPreference(group.Id).CultureInfo)); case IGuildChannel guild: return(GetCatalog(Preference.GetGuildPreference(guild.GuildId).GetCaltureInfo(channel))); default: throw new ArgumentException(); } } catch (KeyNotFoundException) { return(GetCatalog()); } }