-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mirabellier
committed
Feb 22, 2024
1 parent
ca49bc5
commit d5ebcc8
Showing
2 changed files
with
201 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,52 @@ | ||
const Battle = require("../../utils/rpg"); | ||
const { getMemberFromArguments } = require("../../utils/getters"); | ||
|
||
module.exports = { | ||
name: "battle", | ||
aliases: ["bt"], | ||
description: "Battle with another user", | ||
category: "rpg", | ||
usage: "[member]", | ||
run: async (client, message) => { | ||
new Battle(message, message.author).startRandom(); | ||
run: async (client, message, args) => { | ||
if (!args.length) { | ||
new Battle(message, message.author).startRandom(); | ||
} else { | ||
const target = await getMemberFromArguments(message, args.join(" ")); | ||
|
||
if (!target) { | ||
return message.reply("I didn't found the user with this name"); | ||
} | ||
|
||
const opponent = target.user; | ||
|
||
if (opponent.id === message.author.id) { | ||
return message.reply("You can't battle yourself"); | ||
} | ||
|
||
new Battle(message, message.author).startOpponent(opponent); | ||
} | ||
}, | ||
interaction: { | ||
data: { | ||
name: "battle", | ||
type: 1, | ||
description: "Battle with another user", | ||
options: [ | ||
{ | ||
name: "opponent", | ||
description: "Battle with your friend", | ||
type: 6, | ||
}, | ||
], | ||
}, | ||
run: async (client, interaction) => { | ||
new Battle(interaction, interaction.user).startRandom(); | ||
run: (client, interaction) => { | ||
const opponent = interaction.options.getUser("opponent"); | ||
|
||
if (!opponent) { | ||
new Battle(interaction, interaction.user).startRandom(); | ||
} else { | ||
new Battle(interaction, interaction.user).startOpponent(opponent); | ||
} | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters