feat(plugins): Moyai ignore bots setting (#130)

This commit is contained in:
Nuckyz 2022-10-20 19:05:08 -03:00 committed by GitHub
parent a15d5de493
commit d8afde2b4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,7 +5,7 @@ import { Devs } from "../utils/constants";
import { sleep } from "../utils/misc"; import { sleep } from "../utils/misc";
import definePlugin, { OptionType } from "../utils/types"; import definePlugin, { OptionType } from "../utils/types";
import { Settings } from "../Vencord"; import { Settings } from "../Vencord";
import { FluxDispatcher, SelectedChannelStore } from "../webpack/common"; import { FluxDispatcher, SelectedChannelStore, UserStore } from "../webpack/common";
interface IMessageCreate { interface IMessageCreate {
type: "MESSAGE_CREATE"; type: "MESSAGE_CREATE";
@ -28,9 +28,6 @@ const MOYAI = "🗿";
const MOYAI_URL = const MOYAI_URL =
"https://raw.githubusercontent.com/MeguminSama/VencordPlugins/main/plugins/moyai/moyai.mp3"; "https://raw.githubusercontent.com/MeguminSama/VencordPlugins/main/plugins/moyai/moyai.mp3";
// Implement once Settings are a thing
const ignoreBots = true;
export default definePlugin({ export default definePlugin({
name: "Moyai", name: "Moyai",
authors: [Devs.Megu, Devs.Nuckyz], authors: [Devs.Megu, Devs.Nuckyz],
@ -39,7 +36,7 @@ export default definePlugin({
async onMessage(e: IMessageCreate) { async onMessage(e: IMessageCreate) {
if (e.optimistic || e.type !== "MESSAGE_CREATE") return; if (e.optimistic || e.type !== "MESSAGE_CREATE") return;
if (e.message.state === "SENDING") return; if (e.message.state === "SENDING") return;
if (ignoreBots && e.message.author?.bot) return; if (Settings.plugins.Moyai.ignoreBots && e.message.author?.bot) return;
if (!e.message.content) return; if (!e.message.content) return;
if (e.channelId !== SelectedChannelStore.getChannelId()) return; if (e.channelId !== SelectedChannelStore.getChannelId()) return;
@ -53,6 +50,7 @@ export default definePlugin({
onReaction(e: IReactionAdd) { onReaction(e: IReactionAdd) {
if (e.optimistic || e.type !== "MESSAGE_REACTION_ADD") return; if (e.optimistic || e.type !== "MESSAGE_REACTION_ADD") return;
if (Settings.plugins.Moyai.ignoreBots && UserStore.getUser(e.userId)?.bot) return;
if (e.channelId !== SelectedChannelStore.getChannelId()) return; if (e.channelId !== SelectedChannelStore.getChannelId()) return;
const name = e.emoji.name.toLowerCase(); const name = e.emoji.name.toLowerCase();
@ -84,6 +82,12 @@ export default definePlugin({
type: OptionType.BOOLEAN, type: OptionType.BOOLEAN,
default: true, default: true,
restartNeeded: false, restartNeeded: false,
},
ignoreBots: {
description: "Ignore bots",
type: OptionType.BOOLEAN,
default: true,
restartNeeded: false,
} }
} }
}); });