2019-06-10 18:36:56 +00:00
|
|
|
import { InteractionManager } from 'react-native';
|
|
|
|
|
|
|
|
import database from '../realm';
|
|
|
|
import log from '../../utils/log';
|
|
|
|
|
2019-06-17 13:57:07 +00:00
|
|
|
export default function() {
|
|
|
|
return new Promise(async(resolve) => {
|
|
|
|
try {
|
|
|
|
// RC 0.60.2
|
|
|
|
const result = await this.sdk.get('commands.list');
|
2019-06-10 18:36:56 +00:00
|
|
|
|
2019-06-17 13:57:07 +00:00
|
|
|
if (!result.success) {
|
2019-09-03 19:27:57 +00:00
|
|
|
console.log(result);
|
2019-06-17 13:57:07 +00:00
|
|
|
return resolve();
|
|
|
|
}
|
2019-06-10 18:36:56 +00:00
|
|
|
|
2019-06-17 13:57:07 +00:00
|
|
|
const { commands } = result;
|
2019-06-10 18:36:56 +00:00
|
|
|
|
2019-06-17 13:57:07 +00:00
|
|
|
if (commands && commands.length) {
|
|
|
|
InteractionManager.runAfterInteractions(() => {
|
|
|
|
database.write(() => commands.forEach((command) => {
|
|
|
|
try {
|
|
|
|
database.create('slashCommand', command, true);
|
|
|
|
} catch (e) {
|
2019-09-03 19:27:57 +00:00
|
|
|
log(e);
|
2019-06-17 13:57:07 +00:00
|
|
|
}
|
|
|
|
}));
|
|
|
|
return resolve();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} catch (e) {
|
2019-09-03 19:27:57 +00:00
|
|
|
log(e);
|
2019-06-17 13:57:07 +00:00
|
|
|
return resolve();
|
2019-06-10 18:36:56 +00:00
|
|
|
}
|
2019-06-17 13:57:07 +00:00
|
|
|
});
|
2019-06-10 18:36:56 +00:00
|
|
|
}
|