Skip to content

Commit

Permalink
test: playground
Browse files Browse the repository at this point in the history
  • Loading branch information
nethriis committed May 17, 2024
1 parent c64e65e commit b48d895
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 19 deletions.
5 changes: 2 additions & 3 deletions playground/commands/moderations/ban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { defineCommand } from '../../../src'

export default defineCommand(
{
slash: true,
description: 'Ban a user from the server',
args: {
options: {
user: {
type: 'User',
description: 'The user to ban'
Expand All @@ -17,7 +16,7 @@ export default defineCommand(
userPermissions: ['Administrator']
},
(_, interaction, context) => {
const { user, reason } = context.args
const { user, reason } = context.options

interaction.reply(`Banned user ${user} for ${reason}`)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineCommand } from '../../../src'
export default defineCommand(
{
description: 'Kick a user from the server',
args: {
options: {
user: {
type: 'User',
description: 'The user to ban'
Expand All @@ -15,7 +15,7 @@ export default defineCommand(
}
},
(_, interaction, context) => {
const { user, reason } = context.args
const { user, reason } = context.options

interaction.reply(`Kicked user ${user} for ${reason}`)
}
Expand Down
27 changes: 22 additions & 5 deletions playground/commands/utils/noop.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
import { defineCommand } from '../../../src'
import { defineCommand, defineEmbed } from '../../../src'

export default defineCommand(
{
slash: false,
description: 'NOOP!'
description: 'NOOP!',
options: {
noop: {
type: 'User',
description: 'Noop user',
required: false
}
}
},
(_, message) => {
message.reply('NOOP')
(_, interaction, context) => {
const { noop } = context.options

const embed = defineEmbed({
color: 0x0099ff,
title: 'Noop title',
description: `Noop description here ${noop}`,
thumbnail:
'https://tr.rbxcdn.com/dd80ef8b8f6ecc3ffd54b4bffbb91af4/420/420/Image/Png',
timestamp: new Date()
})

interaction.reply({ embeds: [embed] })
}
)
5 changes: 2 additions & 3 deletions playground/commands/utils/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { defineCommand } from '../../../src'

export default defineCommand(
{
slash: false,
description: 'Pong!'
},
(client, message) => {
message.reply(`Pong ${client.ws.ping}ms!`)
(client, interaction) => {
interaction.reply(`Pong ${client.ws.ping}ms!`)
}
)
2 changes: 1 addition & 1 deletion playground/commands/utils/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { defineCommand, defineModal } from '../../../src'

export default defineCommand(
{
slash: true,
description: 'Test the bot',
guildOnly: true,
preconditions: ['ownerOnly']
},
async (_, interaction) => {
Expand Down
3 changes: 2 additions & 1 deletion playground/harmonix.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineHarmonixConfig } from '../src'

export default defineHarmonixConfig({
ownerId: ['556083802628161546']
ownerId: ['556083802628161546'],
guildId: ['725902714311278643']
})
7 changes: 3 additions & 4 deletions playground/preconditions/ownerOnly.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { definePrecondition, useHarmonix } from '../../src'

export default definePrecondition(({ type, message, interaction }) => {
export default definePrecondition(({ interaction }) => {
const harmonix = useHarmonix()
const entity = type === 'message' ? message : interaction
const authorId = entity.member?.user.id
const authorId = interaction.member?.user.id

if (authorId && !harmonix.options.ownerId.includes(authorId)) {
entity?.reply('You are not the owner of this bot!')
interaction?.reply('You are not the owner of this bot!')
return false
}
return true
Expand Down

0 comments on commit b48d895

Please sign in to comment.