Example #1
0
        public static bool starboardExists(this StarboardMessage message)
        {
            using MySqlConnection connection = MySQL.getConnection();
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            string query  = $"SELECT COUNT(1) FROM Starboards WHERE MsgID={message.message.Id}";
            bool   result = connection.ExecuteScalar <bool>(query);

            return(result);
        }
Example #2
0
        public static async Task Save(this StarboardMessage message)
        {
            using MySqlConnection connection = MySQL.getConnection();
            string query = "";

            if (message.stars >= Config.StarboardMin && !message.starboardExists())
            {
                query = $"INSERT INTO Starboards (MsgID, ChannelID, UserID, SBMessageID) " +
                        $"VALUES ({message.message.Id}, {message.channel.Id}, {message.author.Id}, {message.starboardid})";
            }
            else
            {
                query = $"DELETE FROM Starboards WHERE MsgID={message.message.Id}";
            }
            await connection.ExecuteAsync(query);
        }