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) {
|
|
|
|
log('getSlashCommand fetch', result);
|
|
|
|
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) {
|
|
|
|
log('get_slash_command', e);
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
return resolve();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} catch (e) {
|
2019-08-23 13:18:47 +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
|
|
|
}
|