Skip to content

Instantly share code, notes, and snippets.

@foxbot
Created June 21, 2017 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foxbot/255527b9f76be49d286fd1e3f04a770c to your computer and use it in GitHub Desktop.
Save foxbot/255527b9f76be49d286fd1e3f04a770c to your computer and use it in GitHub Desktop.
Mutate the LogSeverity on a LogMessage object
using System.Reflection;
using Discord;
namespace DiscordBot
{
public class LogMutator
{
private readonly FieldInfo _sevField;
public LogMutator()
{
_sevField = typeof(LogMessage).GetField($"{nameof(LogMessage.Severity)}k__BackingField");
}
public LogMessage Mutate(LogMessage message, LogSeverity severity)
{
_sevField.SetValue(message, severity);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment