Wycademy/src/Wycademy/Commands/Services/BlacklistService.cs
/// <summary>
/// Populate the blacklists with the contents of the files.
/// </summary>
Populate the blacklists with the contents of the files.
Populate the blacklists with the contents of the files .
public async Task LoadAsync()
        {
            using (FileStream userBlacklist = File.Open(@"./userblacklist.txt", FileMode.OpenOrCreate))
            using (FileStream guildBlacklist = File.Open(@"./guildblacklist.txt", FileMode.OpenOrCreate))
            using (FileStream guildOwnerBlacklist = File.Open(@"./guildownerblacklist.txt", FileMode.OpenOrCreate))
            {
                byte[] userBytes = new byte[userBlacklist.Length];
                byte[] guildBytes = new byte[guildBlacklist.Length];
                byte[] guildOwnerBytes = new byte[guildOwnerBlacklist.Length];
                await userBlacklist.ReadAsync(userBytes, 0, (int)userBlacklist.Length);
                await guildBlacklist.ReadAsync(guildBytes, 0, (int)guildBlacklist.Length);
                await guildOwnerBlacklist.ReadAsync(guildOwnerBytes, 0, (int)guildOwnerBlacklist.Length);
                UnicodeEncoding unicode = new UnicodeEncoding();
                _userBlacklist = unicode.GetString(userBytes, 0, userBytes.Length).Split(' ').ParseIDs().ToList();
                _guildBlacklist = unicode.GetString(guildBytes, 0, guildBytes.Length).Split(' ').ParseIDs().ToList();
                _guildOwnerBlacklist = unicode.GetString(guildOwnerBytes, 0, guildOwnerBytes.Length).Split(' ').ParseIDs().ToList();
            }
        }
public async Task LoadAsync ( ) { using ( FileStream userBlacklist = File . Open ( @"./userblacklist.txt" , FileMode . OpenOrCreate ) ) using ( FileStream guildBlacklist = File . Open ( @"./guildblacklist.txt" , FileMode . OpenOrCreate ) ) using ( FileStream guildOwnerBlacklist = File . Open ( @"./guildownerblacklist.txt" , FileMode . OpenOrCreate ) ) { byte [ ] userBytes = new byte [ userBlacklist . Length ] ; byte [ ] guildBytes = new byte [ guildBlacklist . Length ] ; byte [ ] guildOwnerBytes = new byte [ guildOwnerBlacklist . Length ] ; await userBlacklist . ReadAsync ( userBytes , 0 , ( int ) userBlacklist . Length ) ; await guildBlacklist . ReadAsync ( guildBytes , 0 , ( int ) guildBlacklist . Length ) ; await guildOwnerBlacklist . ReadAsync ( guildOwnerBytes , 0 , ( int ) guildOwnerBlacklist . Length ) ; UnicodeEncoding unicode = new UnicodeEncoding ( ) ; _userBlacklist = unicode . GetString ( userBytes , 0 , userBytes . Length ) . Split ( ' ' ) . ParseIDs ( ) . ToList ( ) ; _guildBlacklist = unicode . GetString ( guildBytes , 0 , guildBytes . Length ) . Split ( ' ' ) . ParseIDs ( ) . ToList ( ) ; _guildOwnerBlacklist = unicode . GetString ( guildOwnerBytes , 0 , guildOwnerBytes . Length ) . Split ( ' ' ) . ParseIDs ( ) . ToList ( ) ; } }
Populate the blacklists with the contents of the files.
Populate the blacklists with the contents of the files .
// Create a byte array for each file. // Read into each byte array. // Convert the byte arrays into List<ulong>s and assign them to the blacklists.