diff options
author | nea <romangraef@gmail.com> | 2021-08-16 23:01:35 +0200 |
---|---|---|
committer | nea <romangraef@gmail.com> | 2021-08-16 23:01:35 +0200 |
commit | 73d29ebbcca1e1e00ad54b7a2f43982dad81e1c2 (patch) | |
tree | f440e76faf1ec2aa98244775be2a679723a434de /index.js | |
download | powercord-timezone-73d29ebbcca1e1e00ad54b7a2f43982dad81e1c2.tar.gz powercord-timezone-73d29ebbcca1e1e00ad54b7a2f43982dad81e1c2.tar.bz2 powercord-timezone-73d29ebbcca1e1e00ad54b7a2f43982dad81e1c2.zip |
Initial commit
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); + } + +}; |