-
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.
- Loading branch information
0 parents
commit 41075ee
Showing
9 changed files
with
124 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"info": { | ||
"name": "MemeSounds", | ||
"authors": [{ | ||
"name": "Lonk#6942", | ||
"discord_id": "557388558017495046", | ||
"github_username": "Lonk12", | ||
"twitter_username": "wolfyypaw12" | ||
}], | ||
"version": "0.6.1", | ||
"description": "Plays Memetastic sounds depending on what is being sent in chat. This was heavily inspired by the idea of Metalloriff's bruh plugin so go check him out!", | ||
"github": "https://github.com/Lonk12/BetterDiscordPlugins/blob/main/MemeSounds/MemeSounds.plugin.js", | ||
"github_raw": "https://raw.githubusercontent.com/Lonk12/BetterDiscordPlugins/main/MemeSounds/MemeSounds.plugin.js" | ||
}, | ||
"changelog": [ | ||
{"title": "New Stuff", "items": ["Added the vine boom sound effect when :moyai: is sent in chat!", "Added changelog!"]}, | ||
{"title": "Bugs Squashed", "type": "fixed", "items": ["No bugs *yet*."]}, | ||
{"title": "Improvements", "type": "improved", "items": ["Improvements to the response time!"]}, | ||
{"title": "On-going", "type": "progress", "items": ["More sounds being added :)", "Other"]} | ||
], | ||
"main": "MemeSounds.index.js" | ||
} |
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,15 @@ | ||
module.exports = (Plugin, Library) => { | ||
const {Patcher} = Library; | ||
return class MemeSounds extends Plugin { | ||
|
||
onStart() { | ||
Patcher.before(Logger, "log", (t, a) => { | ||
a[0] = "Patched Message: Simplified some code." + a[0]; | ||
}); | ||
} | ||
|
||
onStop() { | ||
Patcher.unpatchAll(); | ||
} | ||
}; | ||
}; |
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,87 @@ | ||
/** | ||
* @name MemeSounds | ||
* @version 0.6.1 | ||
* @description Plays Memetastic sounds depending on what is being sent in chat. This was heavily inspired by the idea of Metalloriff's bruh plugin so go check him out! | ||
* @invite SsTkJAP3SE | ||
* @author Lonk#6942 | ||
* @authorId 557388558017495046 | ||
* @authorLink https://github.com/Lonk12/ | ||
* @source https://github.com/Lonk12/BetterDiscordPlugins/blob/main/MemeSounds/MemeSounds.plugin.js | ||
* @updateUrl https://raw.githubusercontent.com/Lonk12/BetterDiscordPlugins/main/MemeSounds/MemeSounds.plugin.js | ||
*/ | ||
|
||
module.exports = (() => { | ||
|
||
/* Configuration */ | ||
const config = {info: {name: "Meme Sounds", authors: [{name: "Lonk#6942", discord_id: "557388558017495046", github_username: "Lonk12", twitter_username: "wolfyypaw"},{name: "FlyMaster#2642", discord_id: "459726660359553025", github_username: "Apceniy"}], version: "0.6.1", description: "Plays Memetastic sounds depending on what is being sent in chat. This was heavily inspired by the idea of Metalloriff's bruh plugin so go check him out!", github: "https://github.com/Lonk12/BetterDiscordPlugins/blob/main/MemeSounds/MemeSounds.plugin.js", github_raw: "https://raw.githubusercontent.com/Lonk12/BetterDiscordPlugins/main/MemeSounds/MemeSounds.plugin.js"}, defaultConfig: [{id: "setting", name: "Sound Settings", type: "category", collapsible: true, shown: true, settings: [{id: "LimitChan", name: "Limit to the current channel only.", note: "When enabled, sound effects will only play within the currently selected channel.", type: "switch", value: true}, {id: "delay", name: "Sound effect delay.", note: "The delay in miliseconds between each sound effect.", type: "slider", value: 200, min: 10, max: 1000, renderValue: v => Math.round(v) + "ms"}, {id: "volume", name: "Sound effect volume.", note: "How loud the sound effects will be.", type: "slider", value: 1, min: 0.01, max: 1, renderValue: v => Math.round(v*100) + "%"}]}], changelog: [{title: "New Stuff", items: ["Added the vine boom sound effect when :moyai: is sent into chat.", "Thanks to Orangenal name#9280 for adding vine boom!"]}]}; | ||
|
||
/* Library Stuff */ | ||
return !global.ZeresPluginLibrary ? class { | ||
constructor() { this._config = config; } | ||
getName() {return config.info.name;} | ||
getAuthor() {return config.info.authors.map(a => a.name).join(", ");} | ||
getDescription() {return config.info.description;} | ||
getVersion() {return config.info.version;} | ||
load() {BdApi.showConfirmationModal("Library Missing", `The library plugin needed for ${config.info.name} is missing. Please click Download Now to install it.`, {confirmText: "Download Now", cancelText: "Cancel", onConfirm: () => {require("request").get("https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js", async (err, res, body) => {if (err) return require("electron").shell.openExternal("https://betterdiscord.app/Download?id=9"); await new Promise(r => require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0PluginLibrary.plugin.js"), body, r));});}});} | ||
start() { } | ||
stop() { } | ||
} : (([Plugin, Api]) => { | ||
|
||
const plugin = (Plugin, Api) => { try { | ||
|
||
/* Constants */ | ||
const {DiscordModules: {Dispatcher, SelectedChannelStore}} = Api; | ||
const sounds = [ | ||
{re: /no?ice/gmi, file: "noice.mp3", duration: 600}, | ||
{re: /bazinga/gmi, file: "bazinga.mp3", duration: 550}, | ||
{re: /oof/gmi, file: "oof.mp3", duration: 250}, | ||
{re: /bruh/gmi, file: "bruh.mp3", duration: 470}, | ||
{re: /🗿/gmi, file: "moyai.mp3", duration: 100} | ||
]; | ||
|
||
/* Double message event fix */ | ||
let lastMessageID = null; | ||
|
||
/* Meme Sounds Class */ | ||
return class MemeSounds extends Plugin { | ||
constructor() { | ||
super(); | ||
} | ||
|
||
getSettingsPanel() { | ||
return this.buildSettingsPanel().getElement(); | ||
} | ||
|
||
onStart() { | ||
Dispatcher.subscribe("MESSAGE_CREATE", this.messageEvent); | ||
} | ||
|
||
messageEvent = async ({ channelId, message, optimistic }) => { | ||
if (this.settings.setting.LimitChan && channelId != SelectedChannelStore.getChannelId()) | ||
return; | ||
|
||
if (!optimistic && lastMessageID != message.id) { | ||
lastMessageID = message.id; | ||
let queue = new Map(); | ||
for (let sound of sounds) { | ||
for (let match of message.content.matchAll(sound.re)) | ||
queue.set(match.index, sound); | ||
} | ||
for (let sound of [...queue.entries()].sort((a, b) => a[0] - b[0])) { | ||
let audio = new Audio("https://github.com/Lonk12/BetterDiscordPlugins/raw/main/MemeSounds/Sounds/"+sound[1].file); | ||
audio.volume = this.settings.setting.volume; | ||
audio.play(); | ||
await new Promise(r => setTimeout(r, sound[1].duration+this.settings.setting.delay)); | ||
} | ||
} | ||
|
||
}; | ||
|
||
onStop() { | ||
Dispatcher.unsubscribe("MESSAGE_CREATE", this.messageEvent); | ||
} | ||
} | ||
} catch (e) { console.error(e); }}; | ||
return plugin(Plugin, Api); | ||
})(global.ZeresPluginLibrary.buildPlugin(config)); | ||
})(); |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.