Profile: Add initial default customStatus and allow empty values
Fixes #20
This commit is contained in:
@@ -26,9 +26,7 @@ module.exports = {
|
|||||||
|
|
||||||
let profile = await user.getProfile();
|
let profile = await user.getProfile();
|
||||||
|
|
||||||
let customStatus = profile.customStatus ? profile.customStatus : "A Band Bot user";
|
let customStatus = profile.customStatus.replace(/(.{0,40}[\s])/g, '<tspan x="443" dy="1.2em">$1</tspan>');
|
||||||
|
|
||||||
customStatus = customStatus.replace(/(.{0,40}[\s])/g, '<tspan x="443" dy="1.2em">$1</tspan>');
|
|
||||||
|
|
||||||
let profileTemplate = fs.readFileSync('/app/assets/profile/profile.svg').toString();
|
let profileTemplate = fs.readFileSync('/app/assets/profile/profile.svg').toString();
|
||||||
profileTemplate = profileTemplate.replace(/{{USERNAME}}/g, discordUser.username.substr(0,15)+(discordUser.username.length>15?'...':''));
|
profileTemplate = profileTemplate.replace(/{{USERNAME}}/g, discordUser.username.substr(0,15)+(discordUser.username.length>15?'...':''));
|
||||||
|
|||||||
35
migrations/20220921103647-add-default-custom-status.js
Normal file
35
migrations/20220921103647-add-default-custom-status.js
Normal file
@@ -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
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user