Skip to content

Instantly share code, notes, and snippets.

@AntiTcb
AntiTcb / keybase.md
Created August 27, 2017 07:10
Keybase

Keybase proof

I hereby claim:

  • I am antitcb on github.
  • I am antitcb (https://keybase.io/antitcb) on keybase.
  • I have a public key ASBhkdf7teFnqbV3NITKjA45q6g3jaWagE13mLF548RGsgo

To claim this, I am signing this object:

@AntiTcb
AntiTcb / RequireRoleAttribute.cs
Last active July 3, 2018 01:05
Your require role precondition is bad, quick hold this
public class RequireRoleAttribute : RequireContextAttribute
{
private ulong[] _roleIds;
private string[] _roleNames;
/// <summary> Requires that the command caller has ANY of the supplied role ids. </summary>
public RequireRoleAttribute(params ulong[] roleIds) : base(ContextType.Guild)
=> _roleIds = roleIds;
/// <summary> Requires that the command caller has ANY of the supplied role names. </summary>
@AntiTcb
AntiTcb / I got bored.freebie.cs
Last active March 11, 2019 18:35
I got bored.freebie
public static class ChannelExtensions {
public static async Task<IGuildChannel> CloneChannelAsync(this IGuildChannel channel, string newChannelName)
{
if (channel.Guild is null)
throw new InvalidOperationException("The guild is detatched from this channel entity.");
IGuildChannel newChannel = null;
switch (channel)
{
case ITextChannel tChannel:
internal class TemplateMemberNameComparer : StringComparer
{
public override int Compare(string x, string y)
=> string.Compare(Rename(x), Rename(y), true);
public override bool Equals(string x, string y)
=> string.Equals(Rename(x), Rename(y), StringComparison.OrdinalIgnoreCase);
public override int GetHashCode(string obj)
=> Rename(obj).GetHashCode();