Skip to content

Commit

Permalink
Merge pull request #28 from Mimickal/discord-js-v12-legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
Mimickal committed Dec 15, 2021
2 parents da0382b + 6c85f25 commit b0cd7d1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
40 changes: 40 additions & 0 deletions migrations/20211215035000_animated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*******************************************************************************
* This file is part of ReactionRoleBot, a role-assigning Discord bot.
* Copyright (C) 2020 Mimickal (Mia Moretti).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
******************************************************************************/
const REACTS = 'reacts';
const EMOJI_ID = 'emoji_id';

exports.up = function(knex) {
console.error(
'Warning: this is a one-way migration. Animated emoji names cannot ' +
'be restored and will remain as IDs'
);

return knex(REACTS)
.select(EMOJI_ID)
.where(EMOJI_ID, 'like', '<a:%')
.then(rows => Promise.all(
rows.map(row => knex(REACTS)
.where({ [EMOJI_ID]: row[EMOJI_ID] })
.update({ [EMOJI_ID]: row[EMOJI_ID].match(/<a?:.+:(\d{17,21})>/)[1] })
)
));
};

exports.down = function(knex) {
console.error('Cannot restore original animated emoji names');
};

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reactionrolebot",
"version": "1.1.3",
"version": "1.1.4",
"description": "I'm a basic, no BS Discord bot that can assign and unassign roles using message reactions. I am completely free and open source, and always will be.",
"main": "main.js",
"dependencies": {
Expand Down

0 comments on commit b0cd7d1

Please sign in to comment.