diff options
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/index.js b/index.js new file mode 100644 index 0000000..7cb98dd --- /dev/null +++ b/index.js @@ -0,0 +1,43 @@ +const { Plugin } = require('powercord/entities'); +const Settings = require('./Settings.jsx'); +const manifest = require('./manifest.json'); +const { getModule } = require('powercord/webpack'); +const { + inject, + uninject +} = require('powercord/injector'); +const { lookup } = require('./tz'); + +const { transformMessageArray } = require('./transformation.jsx'); + +const PLUGIN_ID = 'timezone-powercord'; +const INJECTION_ID_MESSAGE_RENDER = PLUGIN_ID + '-message-render'; + +const MessageContent = getModule((m) => m.type && m.type.displayName === 'MessageContent', false); + + +module.exports = class TimezonePowercord extends Plugin { + async startPlugin () { + inject(INJECTION_ID_MESSAGE_RENDER, MessageContent, 'type', (args) => { + let x = transformMessageArray( + () => lookup(this.settings.get('timezone', 'GMT')))(args); + console.log(x); + return x; + }, true); + powercord.api.notices.sendAnnouncement('timezone-request-tz', { + color: 'green', + message: 'Timezone Powercord Plugin has been loaded.' + }); + powercord.api.settings.registerSettings(PLUGIN_ID, { + category: this.entityID, + label: 'Timezone Powercord Plugin', + render: Settings + }); + } + + async pluginWillUnload () { + uninject(INJECTION_ID_MESSAGE_RENDER); + powercord.api.settings.unregisterSettings(this.entityID); + } + +}; |