From 414ea5e42170386d4df79db2debc493d0eb4d393 Mon Sep 17 00:00:00 2001 From: Alee Date: Mon, 6 May 2019 16:58:06 -0400 Subject: Added a new command and finally getting rid of the hardcoded stuff --- AleeBot/AleeBot.csproj | 8 ++++++++ AleeBot/AleeBot.ico | Bin 0 -> 134483 bytes AleeBot/Data.cs | 29 +++++++++++++++++++++++++++ AleeBot/Program.cs | 52 ++++++++++++++++++++++++++++++++----------------- 4 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 AleeBot/AleeBot.ico create mode 100644 AleeBot/Data.cs diff --git a/AleeBot/AleeBot.csproj b/AleeBot/AleeBot.csproj index 2cff4bd..3e59679 100644 --- a/AleeBot/AleeBot.csproj +++ b/AleeBot/AleeBot.csproj @@ -8,6 +8,10 @@ (C) Copyright 2019 en AleeCorp + AleeBot.ico + AleeBot.NET + AleeBot + https://github.com/AleeCorp/AleeBot.NET @@ -16,4 +20,8 @@ + + + + diff --git a/AleeBot/AleeBot.ico b/AleeBot/AleeBot.ico new file mode 100644 index 0000000..d79600b Binary files /dev/null and b/AleeBot/AleeBot.ico differ diff --git a/AleeBot/Data.cs b/AleeBot/Data.cs new file mode 100644 index 0000000..0f1ab10 --- /dev/null +++ b/AleeBot/Data.cs @@ -0,0 +1,29 @@ +/******************************************* + * + * AleeBot.NET: A Discord bot that's made in Discord.NET, .NET Core 3.0 and a revival. + * Copyright (C) 2019 AleeCorp + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + **********************************************/ +namespace AleeBot +{ + public class Data + { + //This will be storing public variables such as versions and stuff. + + public static string Version = "3.0 Beta 1"; + public static string prefix = "ab:"; + } +} diff --git a/AleeBot/Program.cs b/AleeBot/Program.cs index d4ae19b..c996cc7 100644 --- a/AleeBot/Program.cs +++ b/AleeBot/Program.cs @@ -30,12 +30,20 @@ namespace AleeBot { public static void Main(string[] args) { + Console.Title = "AleeBot " + Data.Version + " Console"; Console.WriteLine("Starting AleeBot.NET"); - Console.WriteLine("Version: 3.0 Beta 1\n"); + Console.WriteLine("Version: "+ Data.Version +"\n"); Console.WriteLine("Machine Name: " + Environment.MachineName); Console.WriteLine("OS Version: " + Environment.OSVersion); Console.WriteLine("\n"); - new Program().MainAsync().GetAwaiter().GetResult(); + if (File.Exists("token.txt")) + { + new Program().MainAsync().GetAwaiter().GetResult(); + } else + { + Console.WriteLine("[ERROR] token.txt isn't found."); + Environment.Exit(0); + } } private DiscordSocketClient _client; @@ -45,36 +53,44 @@ namespace AleeBot _client = new DiscordSocketClient(); + #if DEBUG _client.Log += Log; + #endif - await _client.LoginAsync(TokenType.Bot, File.ReadAllText("config.json")); + await _client.LoginAsync(TokenType.Bot, File.ReadAllText("token.txt")); await _client.StartAsync(); _client.MessageReceived += Message; - - // Block this task until the program is closed. + + _client.Ready += () => + { + Console.WriteLine("[SUCCESS] AleeBot "+ Data.Version + " is now ready!"); + return Task.CompletedTask; + }; + await Task.Delay(-1); } private async Task Message(SocketMessage message) { - if (message.Content == "ab:ping") + + if (message.Content == Data.prefix + "help") { - await message.Channel.SendMessageAsync("Pong! Running on .NET Core!"); + var embed = new EmbedBuilder(); + embed.WithTitle("AleeBot.NET "+ Data.Version +" Help"); + embed.WithDescription("Every command you input into AleeBot is `ab:`"); + embed.WithColor(Color.Green); + embed.AddField("Commands:", "ab:help\nab:ping"); + await message.Channel.SendMessageAsync(embed: embed.Build()); } - else if (message.Content == "ab:version") + else if (message.Content == Data.prefix + "ping") { - await message.Channel.SendMessageAsync("AleeBot 3.0 Beta 1"); + await message.Channel.SendMessageAsync("🏓 Pong! Running on .NET Core!"); } - else if (message.Content == "ab:embed") + else if (message.Content == Data.prefix + "poweroff") { - Color darkGrey = new Color(96, 125, 139); - var embed = new EmbedBuilder - { - Title = "Hello World", - Color = darkGrey, - Description = "This is a embed!", - }; - await message.Channel.SendMessageAsync(embed: embed.Build()); + //if (message.Author = 242775871059001344) + await message.Channel.SendMessageAsync("⚠ AleeBot will now exit!"); + Environment.Exit(0); } } -- cgit v1.2.3