Skip to content

Instantly share code, notes, and snippets.

@nathan130200
nathan130200 / CommandContext.kt
Created August 31, 2018 17:46 — forked from luaugg/CommandContext.kt
Basic Kotlin code example with very helpful comments.
package kunou.commands
import kunou.startup.Kunou
import net.dv8tion.jda.core.entities.Member
import net.dv8tion.jda.core.entities.Message
import org.slf4j.LoggerFactory
import java.lang.NumberFormatException
/* This is an example of primary constructors in Kotlin. Note the use of the "val" keyword, which declares
an immutable property/field/variable. Notice how it can be used in constructors to declare properties.
@nathan130200
nathan130200 / Bot.ps1
Last active September 25, 2018 16:46
Discord Bot Powershell Launch Script
<#
# Discord Bot Powershell Launch Script
#>
$BotWorkingDir = [environment]::CurrentDirectory
$BotName = "MyBot"
<#
# BotType = 1: .NET Core bot.
# BotType = 0: .NET Framework (.exe) bot.
@nathan130200
nathan130200 / YtAudio.cs
Created November 15, 2018 17:58 — forked from Emzi0767/YtAudio.cs
YouTube audio stream url extractor
// requires Jint
//
// this can be used for video streams as well, with few modifications
public async Task<string> GetYtAudioUrl(string id)
{
await Task.Yield();
var utf8 = new UTF8Encoding(false);
var wc = new WebClient();
@nathan130200
nathan130200 / Event based eval.cs
Last active December 19, 2018 17:32
C# Eval event based.
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using DSharpPlus.Interactivity;
using GameStage.Core.Entities.Eval;
using Humanizer;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Scripting;
using Microsoft.CodeAnalysis.Scripting;
using DSharpPlus.CommandsNext;
using DSharpPlus.Interactivity;
using DSharpPlus.Entities;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using DSharpPlus;
using Humanizer;
using GameStage.Entities.Config;
@nathan130200
nathan130200 / BN_Loot_Exp.cs
Created January 2, 2019 14:41
BN Loot & XP Services.
// LootService.cs
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.Entities;
using DSharpPlus.EventArgs;
using DSharpPlus.Exceptions;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@nathan130200
nathan130200 / cm.js
Last active January 12, 2019 19:44
Basic connection manager implementation for c2s node xmpp server connection handling.
const Jid = require('@xmpp/jid').JID;
const Session = require('node-xmpp-server').C2SStream;
module.exports = class ConnectionManager {
constructor() {
/**
* @type Map<String, Array<Session>>
*/
this._connections = new Map();
}
@nathan130200
nathan130200 / Program.cs
Created January 16, 2019 22:42
WarfaceBot in C# with UseProtect.
using agsXMPP;
using agsXMPP.protocol.tls;
using agsXMPP.Xml;
using agsXMPP.Xml.Dom;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Security;
@nathan130200
nathan130200 / gist:83c55446e9adc17ee2030d08a99eaa61
Created February 4, 2019 11:24 — forked from gregerhalltorp/gist:1853953
Custom type converter for converting between MongoDB.Bson.ObjectId and string
public class ObjectIdConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context,
Type sourceType)
{
if (sourceType == typeof(string))
return true;
return base.CanConvertFrom(context, sourceType);
}
@nathan130200
nathan130200 / main.cpp
Created March 26, 2019 17:07
Contagem de valor.
#include <iostream>
#include <cstdio>
#include <filesystem>
using namespace std;
enum MoneyType {
Moeda,
Nota
};