Initial Commit

This commit is contained in:
dboerlage 2017-04-12 21:49:04 +02:00
commit bb0db1701c
No known key found for this signature in database
GPG key ID: BDA07B7D3FCF147F
7 changed files with 187 additions and 0 deletions

View file

@ -0,0 +1,26 @@
using System;
using System.Threading.Tasks;
using Discord.Commands;
using RestSharp;
namespace Geekbot.net.Modules
{
public class Cat : ModuleBase
{
[Command("cat"), Summary("Return a random image of a cat.")]
public async Task Say()
{
var client = new RestClient("http://random.cat");
var request = new RestRequest("meow.php", Method.GET);
var response = client.Execute<CatObject>(request);
await ReplyAsync(response.Data.file);
}
}
public class CatObject
{
public string file {get;set;}
}
}

View file

@ -0,0 +1,15 @@
using System.Threading.Tasks;
using Discord.Commands;
namespace Geekbot.net.Modules
{
public class Ping : ModuleBase
{
[Command("ping"), Summary("Pong.")]
public async Task Say()
{
// ReplyAsync is a method on ModuleBase
await ReplyAsync("Pong");
}
}
}

View file

@ -0,0 +1,23 @@
using System;
using System.Threading.Tasks;
using Discord;
using Discord.Commands;
namespace Geekbot.net.Modules
{
public class UserInfo : ModuleBase
{
[Alias("stats", "whois")]
[Command("user"), Summary("Get information about this user")]
public async Task User([Summary("The (optional) user to get info for")] IUser user = null)
{
var userInfo = user ?? Context.Message.Author;
var age = Math.Floor((DateTime.Now - userInfo.CreatedAt).TotalDays);
await ReplyAsync($"{userInfo.Username}#{userInfo.Discriminator}\r\n" +
$"Account created at {userInfo.CreatedAt.Day}.{userInfo.CreatedAt.Month}.{userInfo.CreatedAt.Year}, that is {age} days ago\r\n" +
$"Currently {userInfo.Status}");
}
}
}