2015-12-05 10:27:00 +00:00
|
|
|
|
using Discord;
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Parse;
|
2015-12-09 20:47:02 +00:00
|
|
|
|
using Discord.Commands;
|
2015-12-05 10:27:00 +00:00
|
|
|
|
using NadekoBot.Modules;
|
2015-12-09 20:47:02 +00:00
|
|
|
|
using Discord.Modules;
|
2015-12-30 04:44:36 +00:00
|
|
|
|
using Discord.Legacy;
|
2015-12-31 19:40:09 +00:00
|
|
|
|
using Discord.Audio;
|
2015-12-05 10:27:00 +00:00
|
|
|
|
|
|
|
|
|
namespace NadekoBot
|
|
|
|
|
{
|
|
|
|
|
class NadekoBot
|
|
|
|
|
{
|
|
|
|
|
public static DiscordClient client;
|
2016-01-11 19:35:49 +00:00
|
|
|
|
public static StatsCollector stats_collector;
|
2015-12-05 10:27:00 +00:00
|
|
|
|
public static string botMention;
|
2016-01-11 19:35:49 +00:00
|
|
|
|
public static string GoogleAPIKey = null;
|
2015-12-15 08:28:26 +00:00
|
|
|
|
public static ulong OwnerID;
|
2015-12-30 04:44:36 +00:00
|
|
|
|
public static string password;
|
2015-12-05 10:27:00 +00:00
|
|
|
|
|
2015-12-09 20:47:02 +00:00
|
|
|
|
static void Main()
|
2015-12-05 10:27:00 +00:00
|
|
|
|
{
|
|
|
|
|
//load credentials from credentials.json
|
|
|
|
|
Credentials c;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
c = JsonConvert.DeserializeObject<Credentials>(File.ReadAllText("credentials.json"));
|
|
|
|
|
botMention = c.BotMention;
|
2016-01-11 19:35:49 +00:00
|
|
|
|
if (c.GoogleAPIKey == null || c.GoogleAPIKey == "") {
|
|
|
|
|
Console.WriteLine("No google api key found. You will not be able to use music and links won't be shortened.");
|
|
|
|
|
}
|
2015-12-05 10:27:00 +00:00
|
|
|
|
OwnerID = c.OwnerID;
|
2015-12-30 04:44:36 +00:00
|
|
|
|
password = c.Password;
|
2015-12-05 10:27:00 +00:00
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Failed to load stuff from credentials.json, RTFM");
|
|
|
|
|
Console.ReadKey();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//create new discord client
|
2016-01-11 19:35:49 +00:00
|
|
|
|
client = new DiscordClient();
|
2015-12-05 10:27:00 +00:00
|
|
|
|
|
|
|
|
|
//create a command service
|
|
|
|
|
var commandService = new CommandService(new CommandServiceConfig
|
|
|
|
|
{
|
|
|
|
|
CommandChar = null,
|
|
|
|
|
HelpMode = HelpMode.Disable
|
|
|
|
|
});
|
|
|
|
|
|
2016-01-11 19:35:49 +00:00
|
|
|
|
//init parse
|
|
|
|
|
if (c.ParseKey != null && c.ParseID != null && c.ParseID != "" && c.ParseKey != "") {
|
|
|
|
|
ParseClient.Initialize(c.ParseID, c.ParseKey);
|
|
|
|
|
|
|
|
|
|
//monitor commands for logging
|
|
|
|
|
stats_collector = new StatsCollector(commandService);
|
|
|
|
|
} else {
|
|
|
|
|
Console.WriteLine("Parse key and/or ID not found. Bot will not log.");
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-05 10:27:00 +00:00
|
|
|
|
|
|
|
|
|
//add command service
|
2015-12-30 04:44:36 +00:00
|
|
|
|
var commands = client.Services.Add<CommandService>(commandService);
|
2015-12-05 10:27:00 +00:00
|
|
|
|
|
|
|
|
|
//create module service
|
2015-12-30 04:44:36 +00:00
|
|
|
|
var modules = client.Services.Add<ModuleService>(new ModuleService());
|
2015-12-05 10:27:00 +00:00
|
|
|
|
|
2015-12-31 19:40:09 +00:00
|
|
|
|
//add audio service
|
|
|
|
|
var audio = client.Services.Add<AudioService>(new AudioService(new AudioServiceConfig() {
|
2016-01-05 04:52:11 +00:00
|
|
|
|
Channels = 2,
|
|
|
|
|
EnableEncryption = false
|
2015-12-31 19:40:09 +00:00
|
|
|
|
}));
|
|
|
|
|
|
2015-12-05 10:27:00 +00:00
|
|
|
|
//install modules
|
2015-12-06 11:57:29 +00:00
|
|
|
|
modules.Install(new Administration(), "Administration", FilterType.Unrestricted);
|
2015-12-06 13:22:30 +00:00
|
|
|
|
modules.Install(new Conversations(), "Conversations", FilterType.Unrestricted);
|
2015-12-05 10:27:00 +00:00
|
|
|
|
modules.Install(new Gambling(), "Gambling", FilterType.Unrestricted);
|
|
|
|
|
modules.Install(new Games(), "Games", FilterType.Unrestricted);
|
2015-12-31 19:40:09 +00:00
|
|
|
|
modules.Install(new Music(), "Music", FilterType.Unrestricted);
|
2015-12-05 10:27:00 +00:00
|
|
|
|
modules.Install(new Searches(), "Searches", FilterType.Unrestricted);
|
|
|
|
|
|
|
|
|
|
//run the bot
|
|
|
|
|
client.Run(async () =>
|
|
|
|
|
{
|
2015-12-09 20:47:02 +00:00
|
|
|
|
await client.Connect(c.Username, c.Password);
|
|
|
|
|
Console.WriteLine("Connected!");
|
2015-12-05 10:27:00 +00:00
|
|
|
|
});
|
|
|
|
|
Console.WriteLine("Exiting...");
|
|
|
|
|
Console.ReadKey();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|