· 6 years ago · Feb 24, 2020, 12:34 AM
1using System;
2using System.IO;
3using System.Linq;
4using System.Net.Http;
5using System.Text.RegularExpressions;
6using System.Threading.Tasks;
7using Discord;
8using Discord.Commands;
9using Discord.WebSocket;
10using Microsoft.Data.Sqlite;
11using SteamWebAPI2;
12using SteamWebAPI2.Interfaces;
13using SteamWebAPI2.Models;
14using SteamWebAPI2.Utilities;
15
16namespace DiscordBot.Modules
17{
18 [Name("Cheaters")]
19 [Group("cheater")]
20 [Summary("Commands related to cheaters; ban-watch, lists, etc.")]
21 public class CheaterModule : ModuleBase<SocketCommandContext>
22 {
23 [Command("add")]
24 [Summary("Add a cheater to the list")]
25 [RequireOwner]
26 public async Task AddCheater(string profile)
27 {
28 string dbpath = Path.Combine(Directory.GetCurrentDirectory(), "cheaters.sq3");
29 if (!(File.Exists(dbpath)))
30 throw new Exception("Database doesn't exist. Notify the bot owner.");
31 using (SqliteConnection db = new SqliteConnection($"Filename={dbpath}"))
32 {
33 db.Open();
34 SqliteCommand checkForEmptyTable = new SqliteCommand("SELECT name FROM sqlite_master WHERE type='cheaters'", db);
35 SqliteDataReader query = checkForEmptyTable.ExecuteReader();
36 if (!(query.HasRows))
37 throw new Exception("Database has no entries. Notify the bot owner.");
38
39
40 /* doing this wrong...
41 var steamWebApiBaseUrl = "https://api.steampowered.com/";
42 var steamWebApiKey = "<your web api key>";
43 HttpClient httpClient = new HttpClient();
44 SteamWebHttpClient steamWebHttpClient = new SteamWebHttpClient(httpClient);
45 return new SteamWebRequest(steamWebApiBaseUrl, steamWebApiKey, steamWebHttpClient);
46
47 var steamid = new SteamId(profile, ???)
48 */
49
50 db.Close();
51 }
52 }
53 }
54}