Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            string apiKey = "<BOT-API-SECRET>";

            if (File.Exists("api.key"))
            {
                apiKey = File.ReadAllText("api.key");
            }

            DiscordBot.Start(apiKey).ConfigureAwait(false).GetAwaiter().GetResult();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the Prefixes and restarts the Bot
        /// </summary>
        /// <param name="ctx">Command context</param>
        /// <param name="prefixes">all useable prefixes</param>
        /// <returns></returns>
        internal static bool SetPrefixes(CommandContext ctx, string[] prefixes)
        {
            ctx.Message.DeleteAsync().GetAwaiter().GetResult();
            _discord.DisconnectAsync().GetAwaiter().GetResult();
            _discord.Dispose();
            Task.Delay(1000).GetAwaiter();

            _options.Prefixes = prefixes.ToList();
            Options.SaveToFile(_options, "settings.json");

            string apiKey = "<BOT-API-SECRET>";

            if (File.Exists("api.key"))
            {
                apiKey = File.ReadAllText("api.key");
            }
            DiscordBot.Start(apiKey, false).ConfigureAwait(false);

            Task.Delay(1000).GetAwaiter();
            return(true);
        }