diff --git a/commands/profile.js b/commands/profile.js index 12e09e4..28bd50e 100644 --- a/commands/profile.js +++ b/commands/profile.js @@ -26,9 +26,7 @@ module.exports = { let profile = await user.getProfile(); - let customStatus = profile.customStatus ? profile.customStatus : "A Band Bot user"; - - customStatus = customStatus.replace(/(.{0,40}[\s])/g, '$1'); + let customStatus = profile.customStatus.replace(/(.{0,40}[\s])/g, '$1'); let profileTemplate = fs.readFileSync('/app/assets/profile/profile.svg').toString(); profileTemplate = profileTemplate.replace(/{{USERNAME}}/g, discordUser.username.substr(0,15)+(discordUser.username.length>15?'...':'')); diff --git a/migrations/20220921103647-add-default-custom-status.js b/migrations/20220921103647-add-default-custom-status.js new file mode 100644 index 0000000..c822414 --- /dev/null +++ b/migrations/20220921103647-add-default-custom-status.js @@ -0,0 +1,35 @@ +'use strict'; + +module.exports = { + async up (queryInterface, Sequelize) { + /** + * Add altering commands here. + * + * Example: + * await queryInterface.createTable('users', { id: Sequelize.INTEGER }); + */ + let defaultStatus = "Hello, I'm new here!"; + //Replace existin null values with default + await queryInterface.sequelize.query(`UPDATE Profiles SET customStatus = "${defaultStatus}" WHERE customStatus IS NULL`); + //Update column defaults + await queryInterface.changeColumn('Profiles', 'customStatus', { + type: Sequelize.STRING, + allowNull: false, + defaultValue: defaultStatus + }); + }, + + async down (queryInterface, Sequelize) { + /** + * Add reverting commands here. + * + * Example: + * await queryInterface.dropTable('users'); + */ + await queryInterface.changeColumn('Profiles', 'customStatus', { + type: Sequelize.STRING, + allowNull: true, + defaultValue: null + }); + } +};