public static string GetCommandPrefix(ICommandContext context, IMessageChannel channel) { string commandPrefix = context.Bot.Settings.CommandPrefix ?? "!"; if (context.Bot.Settings.CustomPrefixes != null) { if (channel.GetChannelType() == ChannelType.Text) { var guildChannel = channel as IGuildChannel; return(guildChannel == null || !context.Bot.Settings.CustomPrefixes.ContainsKey(guildChannel.Guild.Id) ? commandPrefix : context.Bot.Settings.CustomPrefixes[guildChannel.Guild.Id]); } return(context.Bot.Settings.CustomPrefixes.ContainsKey(channel.Id) ? context.Bot.Settings.CustomPrefixes[channel.Id] : commandPrefix); } return(commandPrefix); }