Skip to content

Commit

Permalink
feat(LoginSound): horror
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico040 committed Jun 11, 2024
1 parent d312a26 commit 9c44493
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
14 changes: 14 additions & 0 deletions plugins/login-sound/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "LoginSound",
"description": "ディスコード!",
"authors": [
{
"name": "Rico040",
"id": "619474349845643275"
}
],
"main": "src/index.ts",
"vendetta": {
"icon": "ic_voice_channel_24px"
}
}
49 changes: 49 additions & 0 deletions plugins/login-sound/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { ReactNative } from "@vendetta/metro/common"

const { DCDSoundManager } = ReactNative.NativeModules;

const soundUrl = "https://raw.githubusercontent.com/Rico040/meine-themen/master/sounds/discordo-discord.mp3";
const soundId = 6970;
let soundDuration = -1;

// Function to prepare the sound
const prepareSound = function () {
return new Promise(function (resolve) {
DCDSoundManager.prepare(soundUrl, "notification", soundId, function (error, sound) {
resolve(sound);
});
});
};

// Variables to manage sound playback state
let timeoutId = null;
let isPlaying = false;

// Function to play the sound, thanks to moyai obfuscated code
async function playSound() {
if (isPlaying) {
if (timeoutId != null) clearTimeout(timeoutId);
DCDSoundManager.stop(soundId);
isPlaying = false;
}
isPlaying = true;
await DCDSoundManager.play(soundId);
timeoutId = setTimeout(function () {
isPlaying = false;
DCDSoundManager.stop(soundId);
timeoutId = null;
}, soundDuration);
}
let isPrepared = false;

export default {
onLoad: () => {
if (!isPrepared) {
prepareSound().then(function (sound) {
isPrepared = true;
soundDuration = sound.duration;
playSound()
});
}
}
}

0 comments on commit 9c44493

Please sign in to comment.