Embeds, Cleanup and Improvements to Roll, Userinfo the init process

This commit is contained in:
Runebaas 2017-04-17 23:58:43 +02:00
parent 6d5c6f2ea8
commit 735a4a81d4
5 changed files with 65 additions and 33 deletions

View file

@ -18,10 +18,6 @@ namespace Geekbot.net.Lib
// {
// get
// {
// if (_instance.IsValueCreated)
// {
// return _instance.Value;
// }
// lock (ThreadLock)
// {
// if (Client == null)

View file

@ -0,0 +1,21 @@
using System;
using System.Threading.Tasks;
using Discord.Commands;
using Discord;
namespace Geekbot.net.Modules
{
public class Info : ModuleBase
{
[Command("info"), Summary("Show some info about the bot.")]
public async Task getInfo()
{
var eb = new EmbedBuilder();
eb.WithAuthor(new EmbedAuthorBuilder()
.WithIconUrl(Context.User.GetAvatarUrl())
.WithName(Context.User.Username));
eb.AddField("Test", "Some testing stuff here...");
await ReplyAsync("", false, eb.Build());
}
}
}

View file

@ -7,11 +7,24 @@ namespace Geekbot.net.Modules
public class Roll : ModuleBase
{
[Command("roll"), Summary("Roll a number between 1 and 100.")]
public async Task RollCommand()
public async Task RollCommand([Remainder, Summary("stuff...")] string stuff = "nothing")
{
var rnd = new Random();
var number = rnd.Next(1, 100);
await ReplyAsync(Context.Message.Author.Mention + ", you rolled " + number);
var guess = 1000;
int.TryParse(stuff, out guess);
if (guess <= 100 && guess > 0)
{
await ReplyAsync($"{Context.Message.Author.Mention} you rolled {number}, your guess was {guess}");
if (guess == number)
{
await ReplyAsync($"Congratulations {Context.User.Username}, your guess was correct!");
}
}
else
{
await ReplyAsync(Context.Message.Author.Mention + ", you rolled " + number);
}
}
[Command("dice"), Summary("Roll a dice")]

View file

@ -21,34 +21,25 @@ namespace Geekbot.net.Modules
var messages = (int)redis.StringGet(key + "-messages");
var level = GetLevelAtExperience(messages);
var reply = "";
if (Context.Message.Author.Id == userInfo.Id)
{
reply = reply + $"here are your stats {userInfo.Mention}\r\n";
}
else
{
reply = reply + $"here are {userInfo.Mention}'s stats\r\n";
}
reply = reply + $"```\r\n";
reply = reply + $"Discordian Since: {userInfo.CreatedAt.Day}/{userInfo.CreatedAt.Month}/{userInfo.CreatedAt.Year} ({age} days)\r\n";
reply = reply + $"Level: {level}\r\n";
reply = reply + $"Messages Sent: {messages}\r\n";
var eb = new EmbedBuilder();
eb.WithAuthor(new EmbedAuthorBuilder()
.WithIconUrl(userInfo.GetAvatarUrl())
.WithName(userInfo.Username));
var jokeKarma = redis.StringGet(key + "-karma");
if (!jokeKarma.IsNullOrEmpty)
eb.AddField("Discordian Since", $"{userInfo.CreatedAt.Day}/{userInfo.CreatedAt.Month}/{userInfo.CreatedAt.Year} ({age} days)");
eb.AddField("Level", level);
eb.AddField("Messages Sent", messages);
var karma = redis.StringGet(key + "-karma");
if (!karma.IsNullOrEmpty)
{
reply = reply + $"Karma: {jokeKarma}\r\n";
eb.AddField("Karma", karma);
}
reply = reply + $"```";
await ReplyAsync(reply);
await ReplyAsync("", false, eb.Build());
}
public async Task GetLevel([Summary("The (optional) user to get info for")] string xp)
public async Task GetLevel(string xp)
{
var level = GetLevelAtExperience(int.Parse(xp));
await ReplyAsync(level.ToString());

View file

@ -12,7 +12,7 @@ namespace Geekbot.net
{
class Program
{
public CommandService commands;
private CommandService commands;
private DiscordSocketClient client;
private DependencyMap map;
private IDatabase redis;
@ -28,7 +28,6 @@ namespace Geekbot.net
Console.WriteLine("Starting...");
//Task.WaitAll(BootTasks.CheckSettingsFile());
Task.WaitAll(new Program().MainAsync());
}
@ -36,8 +35,20 @@ namespace Geekbot.net
{
client = new DiscordSocketClient();
commands = new CommandService();
redis = new RedisClient().Client;
const string token = "MTgxMDkyOTgxMDUzNDU2Mzg0.C8_UTw.PvXLAVOTccbrWKLMeyvN9WqRPlU";
var token = redis.StringGet("discordToken");
if (token.IsNullOrEmpty)
{
Console.Write("Your bot Token: ");
var newToken = Console.ReadLine();
redis.StringSet("discordToken", newToken);
token = newToken;
Console.Write("Bot Owner User ID: ");
var ownerId = Console.ReadLine();
redis.StringSet("botOwner", ownerId);
}
map = new DependencyMap();
map.Add<ICatClient>(new CatClient());
@ -90,7 +101,7 @@ namespace Geekbot.net
{
var message = messsageParam;
if (message == null) return;
if (message.Author.Username.Contains("Geekbot")) return;
if (message.Author.Username.Equals(client.CurrentUser.Username)) return;
var channel = (SocketGuildChannel)message.Channel;