Exemple #1
0
        public async Task Register(CommandContext ctx, string steamId = "")
        {
            if (ctx.Guild.Id != 572662006692315136)
            {
                await ctx.RespondAsync("Command is not usable within this guild");

                return;
            }
            if (steamId == string.Empty)
            {
                await ctx.RespondAsync("You need to enter the id. Example: >register 76561198065593279 (Find your Steam ID here: https://steamidfinder.com/)");

                return;
            }

            bool failedToConvert = false;

            try
            {
                System.Convert.ToInt64(steamId);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Failed to convert because {e.Message}.");
                failedToConvert = true;
            }
            if (steamId.Contains("STEAM") || steamId.Contains("[U") || failedToConvert)
            {
                await ctx.RespondAsync("Steam ID needs to be in the SteamID64 format! Example: >register 76561198065593279 (Find your Steam ID here: https://steamidfinder.com/)");

                return;
            }
            string existingId = await DatabaseModule.GetPlayerSteamIDFromDiscordID(ctx.Member.Id.ToString());

            if (existingId != string.Empty)
            {
                await DatabaseModule.DeletePlayerSteamID(ctx.Member.Id.ToString());
            }
            await DatabaseModule.AddPlayerSteamID(ctx.Member.Id.ToString(), steamId);

            await ctx.RespondAsync("Steam ID added");
        }