fix: sending second non existing message
This commit is contained in:
parent
dbcc2a4338
commit
7cb2d1aa9c
14 changed files with 130 additions and 116 deletions
3
.zed/settings.json
Normal file
3
.zed/settings.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"format_on_save": "off",
|
||||
}
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
import { findByProps } from "@vendetta/metro";
|
||||
import { showToast } from "@vendetta/ui/toasts";
|
||||
import { storage } from "@vendetta/plugin";
|
||||
import { catFact, dogFact, uselessFact } from "../utils/api";
|
||||
|
||||
const MessageActions = findByProps("sendMessage");
|
||||
|
||||
// Helper function to format fact response
|
||||
const formatFactResponse = (fact: { text: string; source?: string }) => {
|
||||
const formatFactResponse = (fact: { text: string; source?: string; length?: number }) => {
|
||||
let response = fact.text;
|
||||
if (storage.factSettings?.includeCitation && fact.source) {
|
||||
response += `\n\nSource: ${fact.source}`;
|
||||
|
|
@ -25,17 +26,22 @@ export const catFactCommand = {
|
|||
try {
|
||||
const fact = await catFact();
|
||||
const fixNonce = Date.now().toString();
|
||||
|
||||
MessageActions.sendMessage(
|
||||
ctx.channel.id,
|
||||
{ content: formatFactResponse(fact) },
|
||||
void 0,
|
||||
{ nonce: fixNonce }
|
||||
);
|
||||
return { type: 4 };
|
||||
|
||||
// return NOTHING - let client handle the acknowledgement
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error("[CatFact] Error:", error);
|
||||
// Silent fail - no error message in chat
|
||||
return { type: 4 };
|
||||
// Show toast on error
|
||||
showToast("Failed to fetch cat fact", 3000);
|
||||
// Return nothing on error too
|
||||
return null;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
@ -52,17 +58,20 @@ export const dogFactCommand = {
|
|||
try {
|
||||
const fact = await dogFact();
|
||||
const fixNonce = Date.now().toString();
|
||||
|
||||
MessageActions.sendMessage(
|
||||
ctx.channel.id,
|
||||
{ content: formatFactResponse(fact) },
|
||||
void 0,
|
||||
{ nonce: fixNonce }
|
||||
);
|
||||
return { type: 4 };
|
||||
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error("[DogFact] Error:", error);
|
||||
// Silent fail - no error message in chat
|
||||
return { type: 4 };
|
||||
// Show toast on error
|
||||
showToast("Failed to fetch dog fact", 3000);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
@ -79,17 +88,20 @@ export const uselessFactCommand = {
|
|||
try {
|
||||
const fact = await uselessFact();
|
||||
const fixNonce = Date.now().toString();
|
||||
|
||||
MessageActions.sendMessage(
|
||||
ctx.channel.id,
|
||||
{ content: formatFactResponse(fact) },
|
||||
void 0,
|
||||
{ nonce: fixNonce }
|
||||
);
|
||||
return { type: 4 };
|
||||
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error("[UselessFact] Error:", error);
|
||||
// Silent fail - no error message in chat
|
||||
return { type: 4 };
|
||||
// Show toast on error
|
||||
showToast("Failed to fetch useless fact", 3000);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { findByProps } from "@vendetta/metro";
|
||||
import { showToast } from "@vendetta/ui/toasts";
|
||||
import { ReactNative as RN } from "@vendetta/metro/common";
|
||||
|
||||
interface CommandOption {
|
||||
|
|
@ -84,7 +85,8 @@ export const firstMessageCommand = {
|
|||
|
||||
// Channel option is not valid in DMs
|
||||
if (isDM && channel) {
|
||||
return { type: 4 };
|
||||
showToast("Channel option cannot be used in DMs", 3000);
|
||||
return null;
|
||||
}
|
||||
|
||||
let result = "https://discord.com/channels/";
|
||||
|
|
@ -114,11 +116,13 @@ export const firstMessageCommand = {
|
|||
RN.Linking.openURL(result);
|
||||
}
|
||||
|
||||
return { type: 4 };
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error("[FirstMessage] Error:", error);
|
||||
// Silent fail - no error message in chat
|
||||
return { type: 4 };
|
||||
// Show toast on error
|
||||
showToast("Failed to fetch first message", 3000);
|
||||
// Silent fail
|
||||
return null;
|
||||
}
|
||||
},
|
||||
applicationId: "-1",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ const inviteModule = findByProps(
|
|||
"createFriendInvite",
|
||||
"revokeFriendInvites",
|
||||
);
|
||||
const api = findByProps("get", "post");
|
||||
const getCurrentUser = findByProps("getCurrentUser")?.getCurrentUser;
|
||||
|
||||
function send(ctx, content) {
|
||||
|
|
@ -33,7 +32,7 @@ export const friendInviteCreateCommand = {
|
|||
"You need a phone number connected to your account!",
|
||||
getAssetIDByName("Small"),
|
||||
);
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
|
||||
// Main method: Create friend invite directly
|
||||
|
|
@ -56,11 +55,11 @@ export const friendInviteCreateCommand = {
|
|||
throw new Error("No invite code generated");
|
||||
}
|
||||
|
||||
return { type: 4 };
|
||||
return null;
|
||||
} catch (e) {
|
||||
console.error("[FriendInvite] Create error:", e);
|
||||
showToast("Error creating friend invite", getAssetIDByName("Small"));
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
@ -77,7 +76,7 @@ export const friendInviteViewCommand = {
|
|||
const invites = await inviteModule.getAllFriendInvites();
|
||||
if (!invites?.length) {
|
||||
showToast("No active friend invites found", getAssetIDByName("Info"));
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
|
||||
const friendInviteList = invites.map((i) => {
|
||||
|
|
@ -89,11 +88,12 @@ export const friendInviteViewCommand = {
|
|||
ctx,
|
||||
`**Your Active Friend Invites:**\n${friendInviteList.join("\n")}`,
|
||||
);
|
||||
return { type: 4 };
|
||||
|
||||
return null;
|
||||
} catch (e) {
|
||||
console.error("[FriendInvite] View error:", e);
|
||||
showToast("Error viewing friend invites", getAssetIDByName("Small"));
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
@ -115,7 +115,7 @@ export const friendInviteRevokeCommand = {
|
|||
"No active friend invites to revoke",
|
||||
getAssetIDByName("Info"),
|
||||
);
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
|
||||
await inviteModule.revokeFriendInvites();
|
||||
|
|
@ -124,27 +124,22 @@ export const friendInviteRevokeCommand = {
|
|||
const invitesAfter = await inviteModule.getAllFriendInvites();
|
||||
|
||||
if (invitesAfter.length === 0) {
|
||||
send(
|
||||
ctx,
|
||||
`✅ Successfully revoked all ${invitesBefore.length} friend invite(s)!`,
|
||||
);
|
||||
showToast(
|
||||
`Revoked ${invitesBefore.length} invite(s)`,
|
||||
`Successfully revoked all ${invitesBefore.length} friend invite(s)!`,
|
||||
getAssetIDByName("Check"),
|
||||
);
|
||||
} else {
|
||||
send(
|
||||
ctx,
|
||||
showToast(
|
||||
`⚠️ Partially revoked invites. ${invitesAfter.length} invite(s) remain active.`,
|
||||
getAssetIDByName("Warning"),
|
||||
);
|
||||
showToast("Partial revocation", getAssetIDByName("Warning"));
|
||||
}
|
||||
|
||||
return { type: 4 };
|
||||
return null;
|
||||
} catch (e) {
|
||||
console.error("[FriendInvite] Revoke error:", e);
|
||||
showToast("Error revoking friend invites", getAssetIDByName("Small"));
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,17 +18,17 @@ export const garyCommand = {
|
|||
}
|
||||
|
||||
const source = storage.garySettings.imageSource || "gary";
|
||||
console.log(`[Gary Command] Using image source: ${source}`); // Debug log
|
||||
console.log(`[Gary Command] Using image source: ${source}`);
|
||||
|
||||
const imageUrl = await getGaryUrl(source);
|
||||
|
||||
if (!imageUrl) {
|
||||
console.log("[Gary Command] No image URL received");
|
||||
// Silent fail - no error message
|
||||
return { type: 4 };
|
||||
// Silent fail
|
||||
return null;
|
||||
}
|
||||
|
||||
console.log(`[Gary Command] Sending image: ${imageUrl}`); // Debug log
|
||||
console.log(`[Gary Command] Sending image: ${imageUrl}`);
|
||||
const fixNonce = Date.now().toString();
|
||||
MessageActions.sendMessage(ctx.channel.id, { content: imageUrl }, void 0, {
|
||||
nonce: fixNonce,
|
||||
|
|
@ -36,8 +36,8 @@ export const garyCommand = {
|
|||
return { type: 4 };
|
||||
} catch (error) {
|
||||
console.error("[Gary] Error:", error);
|
||||
// Silent fail - no error message in chat
|
||||
return { type: 4 };
|
||||
// Silent fail
|
||||
return null;
|
||||
}
|
||||
},
|
||||
applicationId: "-1",
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ export const ipCommand = {
|
|||
};
|
||||
}
|
||||
showToast(errorMsg, getAssetIDByName("CircleXIcon"));
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
|
||||
// Show loading toast
|
||||
|
|
@ -107,7 +107,7 @@ export const ipCommand = {
|
|||
};
|
||||
}
|
||||
showToast(errorMsg, getAssetIDByName("CircleXIcon"));
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
|
||||
// Format the response as code block
|
||||
|
|
@ -129,7 +129,7 @@ export const ipCommand = {
|
|||
} else {
|
||||
// Send as bot message (ephemeral-like)
|
||||
messageUtil.sendBotMessage(ctx.channel.id, content);
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("[IP] Command error:", error);
|
||||
|
|
@ -147,7 +147,7 @@ export const ipCommand = {
|
|||
};
|
||||
}
|
||||
showToast(errorMessage, getAssetIDByName("CircleXIcon"));
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
},
|
||||
applicationId: "-1",
|
||||
|
|
|
|||
|
|
@ -85,25 +85,25 @@ export const konoSelfCommand = {
|
|||
|
||||
if (isNSFW && !ctx.channel.nsfw && !bypassEnabled) {
|
||||
showNSFWWarning();
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
|
||||
const imageUrl = await fetchImage(isNSFW);
|
||||
|
||||
if (!imageUrl) {
|
||||
// Silent fail - no error message
|
||||
return { type: 4 };
|
||||
// Silent fail
|
||||
return null;
|
||||
}
|
||||
|
||||
messageUtil.sendBotMessage(
|
||||
ctx.channel.id,
|
||||
`Here's your random image: ${imageUrl}`,
|
||||
);
|
||||
return { type: 4 };
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error("[KonoSelf] Error:", error);
|
||||
// Silent fail - no error message in chat
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
},
|
||||
applicationId: "-1",
|
||||
|
|
@ -136,14 +136,14 @@ export const konoSendCommand = {
|
|||
|
||||
if (isNSFW && !ctx.channel.nsfw && !bypassEnabled) {
|
||||
showNSFWWarning();
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
|
||||
const imageUrl = await fetchImage(isNSFW);
|
||||
|
||||
if (!imageUrl) {
|
||||
// Silent fail - no error message
|
||||
return { type: 4 };
|
||||
// Silent fail
|
||||
return null;
|
||||
}
|
||||
|
||||
const fixNonce = Date.now().toString();
|
||||
|
|
@ -155,7 +155,7 @@ export const konoSendCommand = {
|
|||
nonce: fixNonce,
|
||||
},
|
||||
);
|
||||
return { type: 4 };
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error("[KonoSend] Error:", error);
|
||||
// Silent fail - no error message in chat
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ export async function themeList(args: any[], ctx: any) {
|
|||
if (!themes || typeof themes !== "object") {
|
||||
const channelID: string = ctx.channel.id;
|
||||
Clyde.sendBotMessage(channelID, "No themes found or themes not loaded yet.");
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
|
||||
const objectValues = Object.values(themes);
|
||||
|
|
@ -162,7 +162,7 @@ export async function themeList(args: any[], ctx: any) {
|
|||
}
|
||||
} catch (error) {
|
||||
console.error("[ThemeList] Error:", error);
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ export async function pluginList(args: any[], ctx: any) {
|
|||
// Ensure plugins is valid
|
||||
if (!plugins || typeof plugins !== "object") {
|
||||
Clyde.sendBotMessage(channelID, "No plugins found or plugins not loaded yet.");
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
|
||||
const pluginList = baseListHeader("Plugin", Object.keys(plugins).length);
|
||||
|
|
@ -223,7 +223,7 @@ export async function pluginList(args: any[], ctx: any) {
|
|||
}
|
||||
} catch (error) {
|
||||
console.error("[PluginList] Error:", error);
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ export const lovefemboysCommand = {
|
|||
});
|
||||
|
||||
if (!shouldProceed) {
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ export const nekoslifeCommand = {
|
|||
};
|
||||
}
|
||||
showToast(errorMsg, getAssetIDByName("CircleXIcon"));
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
|
||||
// Clean and validate category
|
||||
|
|
@ -133,7 +133,7 @@ export const nekoslifeCommand = {
|
|||
};
|
||||
}
|
||||
showToast(errorMsg, getAssetIDByName("CircleXIcon"));
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
|
||||
// Parse and validate limit
|
||||
|
|
@ -164,7 +164,7 @@ export const nekoslifeCommand = {
|
|||
};
|
||||
}
|
||||
showToast(errorMsg, getAssetIDByName("CircleXIcon"));
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
|
||||
const content = urls.join("\n");
|
||||
|
|
@ -182,11 +182,11 @@ export const nekoslifeCommand = {
|
|||
console.log("[NekosLife] Sending to chat");
|
||||
const fixNonce = Date.now().toString();
|
||||
MessageActions.sendMessage(ctx.channel.id, { content }, void 0, { nonce: fixNonce });
|
||||
return { type: 4 };
|
||||
return null;
|
||||
} else {
|
||||
console.log("[NekosLife] Sending as bot message");
|
||||
messageUtil.sendBotMessage(ctx.channel.id, content);
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("[NekosLife] Command error:", error);
|
||||
|
|
@ -204,7 +204,7 @@ export const nekoslifeCommand = {
|
|||
};
|
||||
}
|
||||
showToast(errorMessage, getAssetIDByName("CircleXIcon"));
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
},
|
||||
applicationId: "-1",
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ export const petPetCommand = {
|
|||
void 0,
|
||||
{ nonce: fixNonce }
|
||||
);
|
||||
return { type: 4 };
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error("[PetPet] Error:", error);
|
||||
// Silent fail - no error message in chat
|
||||
return { type: 4 };
|
||||
// Silent fail
|
||||
return null;
|
||||
}
|
||||
},
|
||||
applicationId: "-1",
|
||||
|
|
|
|||
|
|
@ -6,21 +6,21 @@ const SpotifyStore = findByStoreName("SpotifyStore");
|
|||
|
||||
// Individual command functions
|
||||
async function spotifyTrackExecute(args: any[], ctx: any) {
|
||||
if (!storage.enabledCommands?.spotifyTrack) return { type: 4 };
|
||||
if (!storage.enabledCommands?.spotifyTrack) return null;;
|
||||
return handleSpotifyCommand(ctx, (track: any) =>
|
||||
`https://open.spotify.com/track/${track.id}`
|
||||
);
|
||||
}
|
||||
|
||||
async function spotifyAlbumExecute(args: any[], ctx: any) {
|
||||
if (!storage.enabledCommands?.spotifyAlbum) return { type: 4 };
|
||||
if (!storage.enabledCommands?.spotifyAlbum) return null;
|
||||
return handleSpotifyCommand(ctx, (track: any) =>
|
||||
`https://open.spotify.com/album/${track.album.id}`
|
||||
);
|
||||
}
|
||||
|
||||
async function spotifyArtistsExecute(args: any[], ctx: any) {
|
||||
if (!storage.enabledCommands?.spotifyArtists) return { type: 4 };
|
||||
if (!storage.enabledCommands?.spotifyArtists) return null;
|
||||
return handleSpotifyCommand(ctx, (track: any) =>
|
||||
track.artists.map((artist: any) =>
|
||||
`[${artist.name}](${artist.external_urls.spotify})`
|
||||
|
|
@ -29,7 +29,7 @@ async function spotifyArtistsExecute(args: any[], ctx: any) {
|
|||
}
|
||||
|
||||
async function spotifyCoverExecute(args: any[], ctx: any) {
|
||||
if (!storage.enabledCommands?.spotifyCover) return { type: 4 };
|
||||
if (!storage.enabledCommands?.spotifyCover) return null;
|
||||
return handleSpotifyCommand(ctx, (track: any) =>
|
||||
track.album.image.url
|
||||
);
|
||||
|
|
@ -49,7 +49,7 @@ async function handleSpotifyCommand(ctx: any, contentGenerator: (track: any) =>
|
|||
void 0,
|
||||
{ nonce: fixNonce }
|
||||
);
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
|
||||
const content = contentGenerator(track);
|
||||
|
|
@ -62,10 +62,10 @@ async function handleSpotifyCommand(ctx: any, contentGenerator: (track: any) =>
|
|||
{ nonce: fixNonce }
|
||||
);
|
||||
|
||||
return { type: 4 };
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error("[Spotify Command] Error:", error);
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ function executeSysinfoCommand(args: any[], ctx: any) {
|
|||
|
||||
if ((ephemeral || epermit) && !(epermit && !ephemeral)) {
|
||||
messageUtil.sendBotMessage(ctx.channel.id, output.join("\n"));
|
||||
return { type: 4 };
|
||||
return null;
|
||||
} else {
|
||||
const fixNonce = Date.now().toString();
|
||||
MessageActions.sendMessage(
|
||||
|
|
@ -190,12 +190,12 @@ function executeSysinfoCommand(args: any[], ctx: any) {
|
|||
void 0,
|
||||
{ nonce: fixNonce },
|
||||
);
|
||||
return { type: 4 };
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("[Sysinfo] Error:", e);
|
||||
// Silent fail - no chat message
|
||||
return { type: 4 };
|
||||
// Silent fail
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export const sendMessage = (
|
|||
ephemeral?: boolean,
|
||||
) => {
|
||||
// If no content, just acknowledge the command
|
||||
if (!content) return { type: 4 };
|
||||
if (!content) return null;
|
||||
|
||||
// For ephemeral messages, return special format
|
||||
if (ephemeral) {
|
||||
|
|
@ -45,11 +45,11 @@ export const sendMessage = (
|
|||
|
||||
MessageActions.sendMessage(channelId, message, void 0, { nonce });
|
||||
|
||||
return { type: 4 }; // Acknowledge the command
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error("[Commands] Message send failed:", error);
|
||||
// Silent fail - no error message in chat
|
||||
return { type: 4 };
|
||||
// Silent fail
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue