-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRoles.cs
39 lines (31 loc) · 770 Bytes
/
Roles.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using DSharpPlus.Entities;
using DSharpPlus.SlashCommands;
using Newtonsoft.Json;
namespace RoleManager;
public class Roles
{
public static List<ulong> savedRoles = new List<ulong>();
public static void LoadRoles()
{
if (!File.Exists("./roles.json"))
{
File.WriteAllText("./roles.json", "[]");
}
string jsonString = File.ReadAllText("./roles.json");
savedRoles = JsonConvert.DeserializeObject<List<ulong>>(jsonString) ?? new List<ulong>();
}
public static void SaveRoles()
{
File.WriteAllText("./roles.json", JsonConvert.SerializeObject(savedRoles));
}
public static void AddRole(ulong roleID)
{
savedRoles.Add(roleID);
SaveRoles();
}
public static void RemoveRole(ulong roleID)
{
savedRoles.Remove(roleID);
SaveRoles();
}
}