Update NotificationSounds.plugin.js
This commit is contained in:
parent
d5c9133dc3
commit
5cb12da056
|
@ -2,7 +2,7 @@
|
||||||
* @name NotificationSounds
|
* @name NotificationSounds
|
||||||
* @author DevilBro
|
* @author DevilBro
|
||||||
* @authorId 278543574059057154
|
* @authorId 278543574059057154
|
||||||
* @version 3.8.8
|
* @version 3.8.9
|
||||||
* @description Allows you to replace the native Sounds with custom Sounds
|
* @description Allows you to replace the native Sounds with custom Sounds
|
||||||
* @invite Jx3TjNS
|
* @invite Jx3TjNS
|
||||||
* @donate https://www.paypal.me/MircoWittrien
|
* @donate https://www.paypal.me/MircoWittrien
|
||||||
|
@ -14,7 +14,9 @@
|
||||||
|
|
||||||
module.exports = (_ => {
|
module.exports = (_ => {
|
||||||
const changeLog = {
|
const changeLog = {
|
||||||
|
"added": {
|
||||||
|
"Current Channel": "Added Option to change the sound for the current channel notification, (note: Discord added an option in the THEIR notification settings to play a different sound when a message is sent in the current channel, you need to have this enabled in order to be able to change the sound in the plugin settings"
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
|
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
|
||||||
|
@ -72,13 +74,13 @@ module.exports = (_ => {
|
||||||
let types = {};
|
let types = {};
|
||||||
|
|
||||||
const message1Types = {
|
const message1Types = {
|
||||||
dm: {src: "./message3.mp3", name: "Message (Direct Message)", force: null, focus: true},
|
dm: {src: "./message3.mp3", name: "Message (Direct Message)"},
|
||||||
groupdm: {src: "./message3.mp3", name: "Message (Group Message)", force: null, focus: true},
|
groupdm: {src: "./message3.mp3", name: "Message (Group Message)"},
|
||||||
mentioned: {src: "./message2.mp3", name: "Message Mentioned", force: false, focus: true},
|
mentioned: {src: "./message2.mp3", name: "Message Mentioned"},
|
||||||
reply: {src: "./message2.mp3", name: "Message Mentioned (reply)", force: false, focus: true},
|
reply: {src: "./message2.mp3", name: "Message Mentioned (reply)"},
|
||||||
role: {src: "./mention1.mp3", name: "Message Mentioned (role)", force: false, focus: true},
|
role: {src: "./mention1.mp3", name: "Message Mentioned (role)"},
|
||||||
everyone: {src: "./mention2.mp3", name: "Message Mentioned (@everyone)", force: false, focus: true},
|
everyone: {src: "./mention2.mp3", name: "Message Mentioned (@everyone)"},
|
||||||
here: {src: "./mention3.mp3", name: "Message Mentioned (@here)", force: false, focus: true}
|
here: {src: "./mention3.mp3", name: "Message Mentioned (@here)"}
|
||||||
};
|
};
|
||||||
|
|
||||||
const namePrefixes = {
|
const namePrefixes = {
|
||||||
|
@ -88,6 +90,7 @@ module.exports = (_ => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const nameSynonymes = {
|
const nameSynonymes = {
|
||||||
|
"message3": "Message (Current Channel)",
|
||||||
"reconnect": "Invited To Speak"
|
"reconnect": "Invited To Speak"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -177,7 +180,7 @@ module.exports = (_ => {
|
||||||
|
|
||||||
this.defaults = {
|
this.defaults = {
|
||||||
volumes: {
|
volumes: {
|
||||||
globalVolume: {value: 100, description: "Global Notification Sounds Volume"}
|
globalVolume: {value: 100, description: "Global Notification Sounds Volume"}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -204,9 +207,7 @@ module.exports = (_ => {
|
||||||
src: src,
|
src: src,
|
||||||
mute: id.startsWith("call_") ? null : false,
|
mute: id.startsWith("call_") ? null : false,
|
||||||
streamMute: false,
|
streamMute: false,
|
||||||
invisibleMute: false,
|
invisibleMute: false
|
||||||
force: id == "message1" ? false : null,
|
|
||||||
focus: id == "message1" ? true : false
|
|
||||||
};
|
};
|
||||||
if (id == "message1") {
|
if (id == "message1") {
|
||||||
types[id].mute = true;
|
types[id].mute = true;
|
||||||
|
@ -217,9 +218,7 @@ module.exports = (_ => {
|
||||||
src: BDFDB.LibraryModules.SoundParser(message1Types[subType].src),
|
src: BDFDB.LibraryModules.SoundParser(message1Types[subType].src),
|
||||||
mute: true,
|
mute: true,
|
||||||
streamMute: false,
|
streamMute: false,
|
||||||
invisibleMute: false,
|
invisibleMute: false
|
||||||
force: message1Types[subType].force,
|
|
||||||
focus: message1Types[subType].focus
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,12 +251,10 @@ module.exports = (_ => {
|
||||||
if (BDFDB.ObjectUtils.is(e.methodArguments[0]) && e.methodArguments[0].type == "MESSAGE_CREATE" && e.methodArguments[0].message) {
|
if (BDFDB.ObjectUtils.is(e.methodArguments[0]) && e.methodArguments[0].type == "MESSAGE_CREATE" && e.methodArguments[0].message) {
|
||||||
const message = e.methodArguments[0].message;
|
const message = e.methodArguments[0].message;
|
||||||
const guildId = message.guild_id || null;
|
const guildId = message.guild_id || null;
|
||||||
if (message.author.id != BDFDB.UserUtils.me.id && !BDFDB.LibraryStores.RelationshipStore.isBlocked(message.author.id)) {
|
if (message.author.id != BDFDB.UserUtils.me.id && !BDFDB.LibraryStores.RelationshipStore.isBlocked(message.author.id) && (BDFDB.LibraryStores.SelectedChannelStore.getChannelId() != message.channel_id || !BDFDB.LibraryStores.NotificationSettingsStore.getNotifyMessagesInSelectedChannel())) {
|
||||||
const channel = BDFDB.LibraryStores.ChannelStore.getChannel(message.channel_id);
|
const channel = BDFDB.LibraryStores.ChannelStore.getChannel(message.channel_id);
|
||||||
const isGroupDM = channel.isGroupDM();
|
const isGroupDM = channel.isGroupDM();
|
||||||
const muted = BDFDB.ChannelUtils.isThread(channel) ? BDFDB.LibraryStores.JoinedThreadsStore.isMuted(channel.id) : BDFDB.LibraryStores.UserGuildSettingsStore.isGuildOrCategoryOrChannelMuted(guildId, channel.id);
|
if (!guildId) {
|
||||||
const focused = document.hasFocus() && BDFDB.LibraryStores.SelectedChannelStore.getChannelId() == channel.id;
|
|
||||||
if (!guildId && !muted && !(choices[isGroupDM ? "groupdm" : "dm"].focus && focused)) {
|
|
||||||
this.fireEvent(isGroupDM ? "groupdm" : "dm");
|
this.fireEvent(isGroupDM ? "groupdm" : "dm");
|
||||||
this.playAudio(isGroupDM ? "groupdm" : "dm");
|
this.playAudio(isGroupDM ? "groupdm" : "dm");
|
||||||
return;
|
return;
|
||||||
|
@ -265,18 +262,18 @@ module.exports = (_ => {
|
||||||
else if (guildId) {
|
else if (guildId) {
|
||||||
if (BDFDB.LibraryModules.MentionUtils.isRawMessageMentioned({rawMessage: message, userId: BDFDB.UserUtils.me.id})) {
|
if (BDFDB.LibraryModules.MentionUtils.isRawMessageMentioned({rawMessage: message, userId: BDFDB.UserUtils.me.id})) {
|
||||||
if (message.mentions.length && !this.isSuppressMentionsEnabled(guildId, channel.id)) for (const mention of message.mentions) if (mention.id == BDFDB.UserUtils.me.id) {
|
if (message.mentions.length && !this.isSuppressMentionsEnabled(guildId, channel.id)) for (const mention of message.mentions) if (mention.id == BDFDB.UserUtils.me.id) {
|
||||||
if (message.message_reference && !message.interaction && (!muted || choices.reply.force) && !(choices.reply.focus && focused)) {
|
if (message.message_reference && !message.interaction) {
|
||||||
this.fireEvent("reply");
|
this.fireEvent("reply");
|
||||||
this.playAudio("reply");
|
this.playAudio("reply");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!message.message_reference && (!muted || choices.mentioned.force) && !(choices.mentioned.focus && focused)) {
|
if (!message.message_reference) {
|
||||||
this.fireEvent("mentioned");
|
this.fireEvent("mentioned");
|
||||||
this.playAudio("mentioned");
|
this.playAudio("mentioned");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (message.mention_roles.length && !BDFDB.LibraryStores.UserGuildSettingsStore.isSuppressRolesEnabled(guildId, channel.id) && (!muted || choices.role.force) && !(choices.role.focus && focused)) {
|
if (message.mention_roles.length && !BDFDB.LibraryStores.UserGuildSettingsStore.isSuppressRolesEnabled(guildId, channel.id)) {
|
||||||
const member = BDFDB.LibraryStores.GuildMemberStore.getMember(guildId, BDFDB.UserUtils.me.id);
|
const member = BDFDB.LibraryStores.GuildMemberStore.getMember(guildId, BDFDB.UserUtils.me.id);
|
||||||
if (member && member.roles.length) for (const roleId of message.mention_roles) if (member.roles.includes(roleId)) {
|
if (member && member.roles.length) for (const roleId of message.mention_roles) if (member.roles.includes(roleId)) {
|
||||||
this.fireEvent("role");
|
this.fireEvent("role");
|
||||||
|
@ -285,19 +282,20 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (message.mention_everyone && !BDFDB.LibraryStores.UserGuildSettingsStore.isSuppressEveryoneEnabled(guildId, channel.id)) {
|
if (message.mention_everyone && !BDFDB.LibraryStores.UserGuildSettingsStore.isSuppressEveryoneEnabled(guildId, channel.id)) {
|
||||||
if (message.content.indexOf("@everyone") > -1 && (!muted || choices.everyone.force) && !(choices.everyone.focus && focused)) {
|
if (message.content.indexOf("@everyone") > -1) {
|
||||||
this.fireEvent("everyone");
|
this.fireEvent("everyone");
|
||||||
this.playAudio("everyone");
|
this.playAudio("everyone");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (message.content.indexOf("@here") > -1 && (!muted || choices.here.force) && !(choices.here.focus && focused)) {
|
if (message.content.indexOf("@here") > -1) {
|
||||||
this.fireEvent("here");
|
this.fireEvent("here");
|
||||||
this.playAudio("here");
|
this.playAudio("here");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (BDFDB.LibraryStores.UserGuildSettingsStore.allowAllMessages(channel) && (!muted || choices.message1.force) && !(choices.message1.focus && focused)) {
|
if (BDFDB.LibraryStores.UserGuildSettingsStore.allowAllMessages(channel) && !((channel.type == BDFDB.DiscordConstants.ChannelTypes.PUBLIC_THREAD || channel.type == BDFDB.DiscordConstants.ChannelTypes.PRIVATE_THREAD) && !BDFDB.LibraryStores.JoinedThreadsStore.hasJoined(BDFDB.UserUtils.me.id))) {
|
||||||
|
console.log(channel);
|
||||||
this.fireEvent("message1");
|
this.fireEvent("message1");
|
||||||
this.playAudio("message1");
|
this.playAudio("message1");
|
||||||
return;
|
return;
|
||||||
|
@ -455,7 +453,7 @@ module.exports = (_ => {
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||||
title: "Sound Configuration",
|
title: "Sound Configuration",
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
children: Object.keys(types).map(type => [
|
children: Object.keys(types).map(type => type == "message3" && !BDFDB.LibraryStores.NotificationSettingsStore.getNotifyMessagesInSelectedChannel() ? null : [
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||||
|
@ -464,25 +462,9 @@ module.exports = (_ => {
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsLabel, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsLabel, {
|
||||||
label: types[type].name
|
label: types[type].name
|
||||||
}),
|
}),
|
||||||
["force", "focus", "mute", "streamMute", "invisibleMute"].some(n => types[type][n] !== null) && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
|
["mute", "streamMute", "invisibleMute"].some(n => types[type][n] !== null) && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
|
||||||
onClick: event => BDFDB.ContextMenuUtils.open(this, event, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
|
onClick: event => BDFDB.ContextMenuUtils.open(this, event, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
|
||||||
children: [
|
children: [
|
||||||
{key: "force", label: "Force Play", hint: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
|
||||||
text: "Plays the Message Sound even if the Channel of the Message is muted",
|
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
|
|
||||||
name: BDFDB.LibraryComponents.SvgIcon.Names.QUESTIONMARK,
|
|
||||||
width: 18,
|
|
||||||
height: 18
|
|
||||||
})
|
|
||||||
})},
|
|
||||||
{key: "focus", label: "Focus Mute", hint: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
|
||||||
text: "Does not play the Message Sound when the Channel of the Message is currently opened",
|
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
|
|
||||||
name: BDFDB.LibraryComponents.SvgIcon.Names.QUESTIONMARK,
|
|
||||||
width: 18,
|
|
||||||
height: 18
|
|
||||||
})
|
|
||||||
})},
|
|
||||||
{key: "mute", label: ["Mute in", BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.StatusComponents.Status, {style: {marginLeft: 6}, size: 12, status: BDFDB.LibraryComponents.StatusComponents.Types.DND})]},
|
{key: "mute", label: ["Mute in", BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.StatusComponents.Status, {style: {marginLeft: 6}, size: 12, status: BDFDB.LibraryComponents.StatusComponents.Types.DND})]},
|
||||||
{key: "invisibleMute", label: ["Mute in", BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.StatusComponents.Status, {style: {marginLeft: 6}, size: 12, status: BDFDB.LibraryComponents.StatusComponents.Types.INVISIBLE})]},
|
{key: "invisibleMute", label: ["Mute in", BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.StatusComponents.Status, {style: {marginLeft: 6}, size: 12, status: BDFDB.LibraryComponents.StatusComponents.Types.INVISIBLE})]},
|
||||||
{key: "streamMute", label: ["Mute while", BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.StatusComponents.Status, {style: {marginLeft: 6}, size: 12, status: BDFDB.LibraryComponents.StatusComponents.Types.STREAMING})]}
|
{key: "streamMute", label: ["Mute while", BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.StatusComponents.Status, {style: {marginLeft: 6}, size: 12, status: BDFDB.LibraryComponents.StatusComponents.Types.STREAMING})]}
|
||||||
|
@ -703,8 +685,7 @@ module.exports = (_ => {
|
||||||
volume: 100,
|
volume: 100,
|
||||||
mute: types[type].mute,
|
mute: types[type].mute,
|
||||||
streamMute: types[type].streamMute,
|
streamMute: types[type].streamMute,
|
||||||
invisibleMute: types[type].invisibleMute,
|
invisibleMute: types[type].invisibleMute
|
||||||
focus: types[type].focus
|
|
||||||
};
|
};
|
||||||
choices[type] = choice;
|
choices[type] = choice;
|
||||||
this.saveChoice(type, false);
|
this.saveChoice(type, false);
|
||||||
|
@ -743,7 +724,7 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
isSoundUsedAnywhere (type) {
|
isSoundUsedAnywhere (type) {
|
||||||
return type && type.indexOf("poggermode_") != 0 && type != "human_man" && type != "robot_man" && type != "discodo" && type != "overlayunlock" && type != "call_ringing_beat" && !(type != "message1" && /\d$/.test(type));
|
return type && type.indexOf("poggermode_") != 0 && type != "human_man" && type != "robot_man" && type != "discodo" && type != "overlayunlock" && type != "call_ringing_beat" && !(type != "message1" && type != "message3" && /\d$/.test(type));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog));
|
})(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog));
|
||||||
|
|
Loading…
Reference in New Issue