You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,22 +52,24 @@ These rules are what to follow when working and developing on Feedr. There aren'
52
52
53
53
### Database Function Return Guidelines
54
54
55
-
Each database function should **always** return a success indicator (`true`/`false`) along with associated data. To avoid confusion, here are the expected return types:
55
+
Each database function (located in `/src/utils/db`) should **always** return a success indicator (`true`/`false`) along with associated data. To avoid confusion, here are the expected return types:
56
56
57
57
-**Success with data:**`true` should always return populated data, even if the data is not used. For example:
58
-
```ts
59
-
return { success: true, data: DataasData };
60
-
```
58
+
59
+
```ts
60
+
return { success: true, data: DataasData };
61
+
```
61
62
62
63
-**Success without data:**`true` can also indicate a successful operation where no data is returned. In this case, an empty array (`[]`) should be provided:
63
-
```ts
64
-
return { success: true, data: [] };
65
-
```
64
+
65
+
```ts
66
+
return { success: true, data: [] };
67
+
```
66
68
67
69
-**Failure:**`false` should indicate an error or unsuccessful operation. This should always return an empty array (`[]`) to ensure consistency:
68
-
```ts
69
-
return { success: false, data: [] };
70
-
```
70
+
```ts
71
+
return { success: false, data: [] };
72
+
```
71
73
72
74
These guidelines ensure predictable behavior and simplify error handling across the application.
// Check if the channel is already being tracked in the guild
374
374
console.log(trackedChannels);
375
-
if(trackedChannels){
375
+
if(!trackedChannels||!trackedChannels.success){
376
+
// TODO: Embed
376
377
awaitinteraction.reply({
377
378
flags: MessageFlags.Ephemeral,
378
-
content: `This channel is already being tracked in ${trackedChannels.map((channel,index)=>`${index>0&&index===trackedChannels.length-1 ? "and " : ""}<#${channel.guild_channel_id}>`).join(", ")}!`,
379
+
content:
380
+
"An error occurred while trying to check if the channel is already being tracked in this guild! Please report this error!",
381
+
});
382
+
383
+
return;
384
+
}elseif(
385
+
trackedChannels.success&&
386
+
trackedChannels.data
387
+
){
388
+
// If the channel is already being tracked in the guild, we can just return
389
+
awaitinteraction.reply({
390
+
flags: MessageFlags.Ephemeral,
391
+
content: `This channel is already being tracked in ${trackedChannels.data.map((channel,index)=>`${index>0&&index===trackedChannels.data.length-1 ? "and " : ""}<#${channel.guild_channel_id}>`).join(", ")}!`,
0 commit comments