Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
pylixonly committed Aug 14, 2024
2 parents 652449b + 3eb83ee commit ba70fc4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 6 deletions.
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Bug report
about: Create a report to help us improve
title: 'bug: '
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Device Information (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Discord Version [e.g. 222111]
- Bunny Version [e.g e19e89c-main]

**Checklists**
- [ ] I understand that this is a bug report and not a place to request new features or plugins
- [ ] I understand that this is no place to report bugs produced by a plugin
- [ ] I can reproduce this bug in Bunny's safe mode AND unable to reproduce it in vanilla/unmodded Discord
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@
]
}
}
}
}
5 changes: 5 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions src/lib/api/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ let commands: ApplicationCommand[] = [];
*/
export function patchCommands() {
const unpatch = after("getBuiltInCommands", commandsModule, ([type], res: ApplicationCommand[]) => {
if (type === ApplicationCommandType.CHAT) {
return res.concat(commands.filter(c => c.__bunny?.shouldHide?.() !== false));
}
return [...res, ...commands.filter(c =>
(type instanceof Array ? type.includes(c.type) : type === c.type)
&& c.__bunny?.shouldHide?.() !== false)
];
});

// Register core commands
Expand All @@ -30,13 +31,19 @@ export function patchCommands() {

export function registerCommand(command: BunnyApplicationCommand): () => void {
// Get built in commands
const builtInCommands = commandsModule.getBuiltInCommands(ApplicationCommandType.CHAT, true, false);
let builtInCommands: ApplicationCommand[];
try {
builtInCommands = commandsModule.getBuiltInCommands(ApplicationCommandType.CHAT, true, false);
} catch {
builtInCommands = commandsModule.getBuiltInCommands(Object.values(ApplicationCommandType), true, false);
}

builtInCommands.sort((a: ApplicationCommand, b: ApplicationCommand) => parseInt(b.id!) - parseInt(a.id!));

const lastCommand = builtInCommands[builtInCommands.length - 1];

// Override the new command's id to the last command id - 1
command.id = (parseInt(lastCommand.id, 10) - 1).toString();
command.id = (parseInt(lastCommand.id!, 10) - 1).toString();

// Fill optional args
command.__bunny = {
Expand Down

0 comments on commit ba70fc4

Please sign in to comment.