-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added admin logging to log important commands that are issued to the …
…database
- Loading branch information
1 parent
d177bc5
commit a275742
Showing
13 changed files
with
177 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using DiscordBot.Database; | ||
using MySql.Data.MySqlClient; | ||
|
||
namespace DiscordBot.Logging | ||
{ | ||
public class AdminLog | ||
{ | ||
internal static bool Log(ulong executedBy, string action, ulong executedIn, ulong? userMention = null) | ||
{ | ||
List<(string, string)> queryParams = new List<(string id, string value)>() | ||
{ | ||
("@executedBy", executedBy.ToString()), | ||
("@action", action), | ||
("@executedIn", executedIn.ToString()) | ||
}; | ||
|
||
queryParams.Add(userMention != null | ||
? ("@mentionedUser", userMention.ToString()) | ||
: ("@mentionedUser", null)); | ||
|
||
int rowsUpdated = DatabaseActivity.ExecuteNonQueryCommand( | ||
"INSERT IGNORE INTO " + | ||
"admin_log(logId,executedBy,action,executedAt,executedIn,userMentioned) " + | ||
"VALUES (NULL, @executedBy, @action, CURRENT_TIMESTAMP, @executedIn, @mentionedUser);", queryParams); | ||
|
||
return rowsUpdated == 1; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.