generated from crowbartools/firebot-custom-script-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Oceanity/feature/better-class-structure
Feature/better class structure
- Loading branch information
Showing
18 changed files
with
704 additions
and
506 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"tabWidth": 2, | ||
"useTabs": false | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"bracketSameLine": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/firebot/effects/spotifyGetCurrentlyPlayingTrackEffect.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { spotify } from "@/main"; | ||
import { Firebot } from "@crowbartools/firebot-custom-scripts-types"; | ||
import { getErrorMessage } from "@/utils/errors"; | ||
|
||
export const spotifyGetCurrentlyPlayingEffect: Firebot.EffectType<{}> = { | ||
definition: { | ||
id: "oceanity-spotify:get-currently-playing-track", | ||
name: "Spotify: Get Now Playing", | ||
description: | ||
"Gets all details of the currently playing track on active Spotify device", | ||
icon: "fab fa-spotify", | ||
categories: ["integrations"], | ||
//@ts-expect-error ts2353 | ||
outputs: [ | ||
{ | ||
label: "Now Playing", | ||
description: | ||
"Will be currently playing track details if Spotify is playing, null if not.", | ||
defaultName: "nowPlaying", | ||
}, | ||
{ | ||
label: "Error Message", | ||
description: | ||
"If getting currently playing track failed, will contain an error message.", | ||
defaultName: "error", | ||
}, | ||
], | ||
}, | ||
|
||
optionsTemplate: ``, | ||
|
||
// @ts-expect-error ts6133: Variables must be named consistently | ||
optionsController: ($scope: any, backendCommunicator: any, $q: any) => {}, | ||
|
||
optionsValidator: () => [], | ||
|
||
onTriggerEvent: async () => { | ||
try { | ||
const track = await spotify.player.getCurrentlyPlaying(); | ||
|
||
return { | ||
success: true, | ||
outputs: { | ||
nowPlaying: track.item, | ||
}, | ||
}; | ||
} catch (error) { | ||
return { | ||
success: false, | ||
outputs: { | ||
nowPlaying: null, | ||
error: getErrorMessage(error), | ||
}, | ||
}; | ||
} | ||
}, | ||
}; |
Oops, something went wrong.