VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form frmDatabase 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Edit Database"
   ClientHeight    =   5160
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4200
   BeginProperty Font 
      Name            =   "Verdana"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "frmDatabase.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5160
   ScaleWidth      =   4200
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton cmdSave 
      Caption         =   "Save"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3120
      TabIndex        =   4
      Top             =   4680
      Width           =   975
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "Cancel"
      Height          =   375
      Left            =   1920
      TabIndex        =   5
      Top             =   4680
      Width           =   1095
   End
   Begin VB.CommandButton cmdAdd 
      Caption         =   "Add"
      Height          =   255
      Left            =   2760
      TabIndex        =   3
      Top             =   4200
      Width           =   1335
   End
   Begin VB.CommandButton cmdEdit 
      Caption         =   "Edit"
      Height          =   255
      Left            =   1440
      TabIndex        =   2
      Top             =   4200
      Width           =   1335
   End
   Begin VB.CommandButton cmdRemove 
      Caption         =   "Remove"
      Height          =   255
      Left            =   120
      TabIndex        =   1
      Top             =   4200
      Width           =   1335
   End
   Begin MSComctlLib.ListView lvUsers 
      Height          =   4095
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   3975
      _ExtentX        =   7011
      _ExtentY        =   7223
      View            =   3
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      FullRowSelect   =   -1  'True
      _Version        =   393217
      ForeColor       =   16777215
      BackColor       =   0
      BorderStyle     =   1
      Appearance      =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Courier New"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      NumItems        =   2
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Text            =   "Username"
         Object.Width           =   3881
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   1
         Text            =   "Attributes"
         Object.Width           =   2469
      EndProperty
   End
   Begin VB.Line Line1 
      X1              =   0
      X2              =   4200
      Y1              =   4560
      Y2              =   4560
   End
End
Attribute VB_Name = "frmDatabase"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public BotIndex As Integer
Public DB As String

Public Sub ShowDB()
    DB = frmBot.Bot(BotIndex).DbFile
    
    If fso.FileExists(DB) = False Then Call fso.CreateTextFile(DB)
    
    Dim strLine As String
    Open DB For Input As #1
    Do Until EOF(1)
    Line Input #1, strLine
        If InStrB(strLine, "\") > 0 Then
            With lvUsers.ListItems.Add(, , Trim$(Left$(strLine, InStr(strLine, "\") - 1)))
                .ListSubItems.Add , , Trim$(Mid$(strLine, InStr(strLine, "\") + 1))
            End With
        End If
    Loop
    Close #1
End Sub

Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub cmdEdit_Click()
    If lvUsers.ListItems.Count > 0 Then
        Dim strAttributes As String
        strAttributes = InputBox("Available Attributes:" & vbNewLine & _
            "    B - Basic Access" & vbNewLine & _
            "    C - Clan Management" & vbNewLine & _
            "    D - Database Management" & vbNewLine & _
            "    J - Join Commands" & vbNewLine & _
            "    M - Moderation" & vbNewLine & _
            "    O - Owner of the Bot" & vbNewLine & _
            "    S - Safe" & vbNewLine & _
            "    X - Banned" & vbNewLine & vbNewLine & _
            "New Attributes:", "Change Attributes?", lvUsers.SelectedItem.ListSubItems(1).text)
        If LenB(ParseAttributeString(strAttributes)) = 0 Then
            If LenB(strAttributes) > 0 Then MsgBox "Invalid attributes specified!", vbExclamation, "Invalid Attributes"
            Exit Sub
        End If
        strAttributes = ParseAttributeString(strAttributes)
        lvUsers.SelectedItem.ListSubItems(1).text = strAttributes
    End If
End Sub

Private Sub cmdRemove_Click()
    If lvUsers.ListItems.Count > 0 Then
        If MsgBox("Are you sure you want to remove " & """" & lvUsers.SelectedItem.text & """" & "?", vbQuestion + vbYesNo, "Remove User?") = vbYes Then
            lvUsers.ListItems.Remove lvUsers.SelectedItem.Index
        End If
    End If
End Sub

Private Sub cmdAdd_Click()
    Dim strUser As String, strAttributes As String
    strUser = InputBox("Username:", "Add User")
    If LenB(strUser) = 0 Then Exit Sub
    strAttributes = InputBox("Available Attributes:" & vbNewLine & _
        "    B - Basic Access" & vbNewLine & _
        "    C - Clan Management" & vbNewLine & _
        "    D - Database Management" & vbNewLine & _
        "    J - Join Commands" & vbNewLine & _
        "    M - Moderation" & vbNewLine & _
        "    O - Owner of the Bot" & vbNewLine & _
        "    S - Safe" & vbNewLine & _
        "    X - Banned" & vbNewLine & vbNewLine & _
        "Attributes:", "What Attributes?")
    If LenB(ParseAttributeString(strAttributes)) = 0 Then
        If LenB(strAttributes) > 0 Then MsgBox "Invalid attributes specified!", vbExclamation, "Invalid Attributes"
        Exit Sub
    End If
    strAttributes = ParseAttributeString(strAttributes)
    With lvUsers.ListItems.Add(, , strUser)
        .ListSubItems.Add , , strAttributes
    End With
End Sub

Private Sub cmdSave_Click()
    If fso.FileExists(DB) = False Then Call fso.CreateTextFile(DB)
    
    Open DB For Output As #1
    Dim I As Integer
    For I = 1 To lvUsers.ListItems.Count
        Print #1, lvUsers.ListItems(I).text & "\" & lvUsers.ListItems(I).ListSubItems(1).text
    Next I
    Close #1
    
    frmBot.Bot(BotIndex).ReloadDatabase
    
    Unload Me
End Sub
