Skip to content

Commit

Permalink
Merge pull request #3 from Owlvernyte/dev
Browse files Browse the repository at this point in the history
Update May 11 2024
  • Loading branch information
fieztazica authored May 11, 2024
2 parents 007afbc + d1edcb9 commit 28ae249
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 57 deletions.
45 changes: 45 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Bug Report
description: File a bug report
title: "[Bug] "
labels: [bug, "unverified"]
assignees:
- Owlvernyte
- fieztazica
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Also tell us, what did you expect to happen?
placeholder: Tell us what you see!
value: "A bug happened!"
validations:
required: true

- type: textarea
id: reproduction
attributes:
label: Reproduction
description: You should provide a way to reproduce the problem.
placeholder: Repo link or code

- type: textarea
id: logs
attributes:
label: Relevant log output
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: Shell

- type: checkboxes
id: terms
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/Owlvernyte/Hoot/blob/master/CODE_OF_CONDUCT.md)
options:
- label: I agree to follow this project's Code of Conduct
required: true
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Discord Server
url: https://discord.gg/dcpNtKRYs4
about: For questions and support requests, please visit our Discord Server.
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Feature request
description: Request a new feature
title: "[Feature] "
labels: [enhancement]
assignees:
- Owlvernyte
- fieztazica
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this feature request!
- type: textarea
id: feature
attributes:
label: Feature
description: Please describe the feature you are requesting in detail
placeholder: describe....
validations:
required: true
15 changes: 1 addition & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,7 @@ npm install
```

### Define `.env`
Specify a secret file `src/.env` (support `src/.env.*`)

```
# Application node mode (put 'production' to make the bot goes production mode)
NODE_ENV=
# Your Discord Application Bot Token
DISCORD_TOKEN=abcAbc123
# Discord User ID(s) of owner(s) (separate by a comma)
OWNERS=0000000000000,111111111111111
# Your Discord Development Guild Id for development purpose
DEV_GUILD_ID=8888888888888888888
# Support Discord Server ID
SUPPORT_SERVER_ID=
```
Specify a secret file `src/.env` (support `src/.env.*`) using `example.env`

### Development

Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hoot",
"version": "0.2.0",
"version": "0.2.1",
"main": "dist/index.js",
"author": "@Owlvernyte",
"license": "Apache-2.0",
Expand Down Expand Up @@ -56,5 +56,9 @@
"format": "prettier --write \"src/**/*.ts\"",
"type:check": "tsc --pretty --skipLibCheck --noEmit"
},
"repository": {
"type": "git",
"url": "https://github.com/Owlvernyte/Hoot.git"
},
"prettier": "@sapphire/prettier-config"
}
83 changes: 41 additions & 42 deletions src/commands/General/help.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { ApplyOptions } from '@sapphire/decorators';
import { PaginatedMessage } from '@sapphire/discord.js-utilities';
import { Command } from '@sapphire/framework';
import { APIApplicationCommandOptionChoice, ApplicationCommandType, EmbedBuilder, chatInputApplicationCommandMention } from 'discord.js';
import { ApplicationCommandType, EmbedBuilder, chatInputApplicationCommandMention } from 'discord.js';
import { getRandomHoot, replyLoadingChatInputInteraction } from '../../lib/utils';

const dev = process.env.NODE_ENV !== 'production';

const choices: APIApplicationCommandOptionChoice<string>[] = [
{ name: 'Get command list', value: 'commands' },
{ name: 'Support server', value: 'support' }
];

@ApplyOptions<Command.Options>({
description: 'This command will help you out'
})
Expand All @@ -18,27 +15,30 @@ export class UserCommand extends Command {
builder //
.setName(this.name)
.setDescription(this.description)
.addStringOption((option) =>
option
.setName('topic')
.setDescription('Select a topic')
.setRequired(true)
.addChoices(...choices)
)
);
}

public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
const topic = interaction.options.getString('topic');
const response = await replyLoadingChatInputInteraction(interaction);

const paginatedMessage = new PaginatedMessage({
template: new EmbedBuilder()
.setColor('Random')
// Be sure to add a space so this is offset from the page numbers!
.setFooter({ text: ` ${getRandomHoot()}`, iconURL: `${interaction.user.displayAvatarURL()}` })
.setThumbnail(this.container.client.user?.displayAvatarURL() || null)
});

paginatedMessage.addPageEmbed(this.getWelcomeEmbed());
const commandEmbeds = await this.getCommandsEmbeds(interaction);
commandEmbeds.forEach((embed) => paginatedMessage.addPageEmbed(embed));

if (topic === 'commands') {
return this.commandsOptionRun(interaction);
}
await paginatedMessage.run(response, interaction.user);

return this.supportOptionRun(interaction);
return response;
}

private async commandsOptionRun(interaction: Command.ChatInputCommandInteraction) {
private async getCommandsEmbeds(interaction: Command.ChatInputCommandInteraction) {
const { guild } = interaction;
const applicationCommands = (dev ? await guild!.commands.fetch() : await this.container.client.application!.commands.fetch())
.filter((c) => c.type === ApplicationCommandType.ChatInput)
Expand All @@ -57,32 +57,31 @@ export class UserCommand extends Command {
.map((command) => applicationCommands.find((ac) => ac.name === command.name))
}));

const embed = new EmbedBuilder()
.setColor('Random')
.setTitle(`COMMAND LIST`)
.setThumbnail(this.container.client.user?.displayAvatarURL() || null)
.setDescription(
`We use \`/command\` (Slash command) only! For further reason click [here](https://support-dev.discord.com/hc/en-us/articles/4404772028055).`
)
.addFields(
...categorizedCommands.map((category) => ({
name: category.categoryName,
value: category.commands
const embeds = categorizedCommands.map((category) =>
new EmbedBuilder()
.setTitle(`${category.categoryName} Commands`)
.setDescription(
category.commands
.map((command) => chatInputApplicationCommandMention(command?.name || 'unknownName', command?.id || 'unknownId'))
.join(' • ')
}))
);

return interaction.reply({
embeds: [embed]
});
)
);
return embeds;
}

private async supportOptionRun(interaction: Command.ChatInputCommandInteraction) {
const supportGuild = await this.container.client.guilds.fetch(process.env.SUPPORT_SERVER_ID);

return interaction.reply({
content: `${await supportGuild.invites.create(supportGuild.rulesChannelId!)}`
});
private getWelcomeEmbed() {
const linkMardown = (name: string, url: string) => `[${name}](${url})`;
const hootSlashReasonUrl = linkMardown('here', 'https://support-dev.discord.com/hc/en-us/articles/4404772028055');
const hootSupportServerUrl = linkMardown('Support Server', process.env.SUPPORT_SERVER_INVITE_LINK);
const hootFeedbackUrl = linkMardown('Feedback', process.env.SUPPORT_URL);
const embed = new EmbedBuilder()
.setTitle('HELP PANEL')
.setDescription(
[
`Hoot uses \`/command\` (Slash command) only! For further reason click ${hootSlashReasonUrl}.`,
`${hootFeedbackUrl}${hootSupportServerUrl}`
].join('\n\n')
);
return embed;
}
}
4 changes: 4 additions & 0 deletions src/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ OWNERS=0000000000000,111111111111111
DEV_GUILD_ID=8888888888888888888
# Support Discord Server ID
SUPPORT_SERVER_ID=
# Support Discord Server Invite Link
SUPPORT_SERVER_INVITE_LINK="https://discord.gg/dcpNtKRYs4"
# Support URL (GitHub issue)
SUPPORT_URL="https://github.com/Owlvernyte/Hoot/issues"
2 changes: 2 additions & 0 deletions src/lib/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ declare module '@skyra/env-utilities' {
OWNERS: ArrayString;
DEV_GUILD_ID: string;
SUPPORT_SERVER_ID: string;
SUPPORT_SERVER_INVITE_LINK: string;
SUPPORT_URL: string;
}
}
13 changes: 13 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,16 @@ export function setupStatusChanger() {
client.user?.setActivity(status);
});
}

export function getRandomInt(min: number, max: number) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}

export function getRandomHoot(oLength: number = 0, upperH: boolean = false, upperCase: boolean = false) {
const min = 1,
max = oLength <= 0 ? 10 : oLength > 10 ? 10 : oLength;
const randomLength = getRandomInt(min, max);
const oString = new Array(randomLength).fill('o').join('');
const content = `${upperH ? 'H' : 'h'}${oString}t`;
return upperCase ? content.toUpperCase() : content;
}

0 comments on commit 28ae249

Please sign in to comment.