[PCCompat > Global] api.commands.registerCommand: custom sendMessage impl. (no return)

This commit is contained in:
Ducko 2021-04-05 10:31:08 +01:00 committed by Keanu
parent b658064804
commit 0ba227267a
Signed by: keanucode
GPG Key ID: A7431C0D513CA93B
1 changed files with 17 additions and 5 deletions

View File

@ -1,5 +1,8 @@
// Also set Powercord global var stuff here since entities import is needed to use Plugin (which every PC plugin uses)
const sendMessage = goosemodScope.webpackModules.findByProps('sendMessage', 'receiveMessage').sendMessage;
const getChannelId = goosemod.webpackModules.findByProps('getChannelId').getChannelId;
export const powercord = {
api: {
commands: {
@ -12,12 +15,21 @@ export const powercord = {
console.log(out);
if (!out.send) return goosemodScope.patcher.internalMessage(out.result); // PC impl. sends internal message when out.send === false, so we also do the same via our previous Patcher API function
// When send is true, we send it as a message via returning obj with content
if (!out.send) {
goosemodScope.patcher.internalMessage(out.result); // PC impl. sends internal message when out.send === false, so we also do the same via our previous Patcher API function
return {
content: out.result
};
return;
}
// When send is true, we send it as a message via sendMessage
sendMessage(getChannelId(), {
content: out.result,
tts: false,
invalidEmojis: [],
validNonShortcutEmojis: []
});
}, [
{ type: 3, required: false, name: 'args', description: 'Arguments for PC command' } // Argument for any string for compat. with PC's classical commands
]);