Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New commands and bugs fix #286

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"common-tags": "^1.8.2",
"connect-mongo": "^5.0.0",
"country-emoji-languages": "^1.0.0",
"discord-gamecord": "^4.1.0",
"discord-giveaways": "^6.0.1",
"discord-together": "^1.3.31",
"discord.js": "^14.11.0",
Expand Down
98 changes: 98 additions & 0 deletions src/commands/fun/hangman.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
const { ApplicationCommandOptionType, EmbedBuilder } = require("discord.js");
const { Hangman } = require("discord-gamecord");
const choices = ["nature", "sport", "color", "camp", "fruit", "discord", "winter", "pokemon"];

module.exports = {
name: "hangman",
description: "Play hangman in discord",
cooldown: 15,
category: "FUN",
botPermissions: ["SendMessages", "EmbedLinks", "AddReactions", "ReadMessageHistory", "ManageMessages"],
command: {
enabled: true,
},
slashCommand: {
enabled: true,
ephermal: true,
options: [
{
name: "theme",
description: "Select a theme",
type: ApplicationCommandOptionType.String,
required: true,
choices: choices.map((choice) => {
return {
name: choice,
value: choice,
};
}),
},
],
},

async messageRun(message, args) {
const choice = args[0];

if (!choice) {
const embed = new EmbedBuilder();
embed.setTitle("Hangman");
embed.setColor("#5865F2");
embed.setDescription(
`Please select a theme from the list below:\n\n${choices.map((choice) => `\`${choice}\``).join(", ")}`
);
return message.reply({ embeds: [embed] });
}

if (!choices.includes(choice)) {
const embed = new EmbedBuilder();
embed.setTitle("Hangman");
embed.setColor("#5865F2");
embed.setDescription(
`Please select a theme from the list below:\n\n${choices.map((choice) => `\`${choice}\``).join(", ")}`
);
return message.reply({ embeds: [embed] });
}
const Game = new Hangman({
message: message,
isSlashGame: false,
embed: {
title: "Hangman",
color: "#5865F2",
},
hangman: { hat: "🎩", head: "😟", shirt: "👕", pants: "🩳", boots: "👞👞" },
timeoutTime: 60000,
theme: choice,
winMessage: "You won! The word was **{word}**.",
loseMessage: "You lost! The word was **{word}**.",
playerOnlyMessage: "Only {player} can use these buttons.",
});

Game.startGame();
Game.on("gameOver", (result) => {
console.log(result); // => { result... }
});
},

async interactionRun(interaction) {
const choice = interaction.options.getString("theme");
const Game = new Hangman({
message: interaction,
isSlashGame: true,
embed: {
title: "Hangman",
color: "#5865F2",
},
hangman: { hat: "🎩", head: "😟", shirt: "👕", pants: "🩳", boots: "👞👞" },
timeoutTime: 60000,
theme: choice,
winMessage: "You won! The word was **{word}**.",
loseMessage: "You lost! The word was **{word}**.",
playerOnlyMessage: "Only {player} can use these buttons.",
});

Game.startGame();
Game.on("gameOver", (result) => {
console.log(result); // => { result... }
});
},
};
97 changes: 97 additions & 0 deletions src/commands/fun/love.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
const { EmbedBuilder, ApplicationCommandOptionType } = require("discord.js");

/**
* @type {import("@structures/Command")}
*/

module.exports = {
name: "love",
description: "Get the love percentage of two users.",
cooldown: 10,
category: "FUN",
botPermissions: ["EmbedLinks"],
command: {
enabled: true,
aliases: [],
usage: "love <user1> <user2>",
minArgsCount: 1,
},
slashCommand: {
enabled: true,
options: [
{
name: "user1",
description: "The first user",
type: ApplicationCommandOptionType.User,
required: true,
},

{
name: "user2",
description: "The second user",
type: ApplicationCommandOptionType.User,
required: true,
},
],
},

async messageRun(message, args) {
const user1 = args[0];
const user2 = args[1];
const response = await getUserLove(user1, user2, message.author);
await message.safeReply(response);
},

async interactionRun(interaction) {
const user1 = interaction.options.getUser("user1");
const user2 = interaction.options.getUser("user2");
const response = await getUserLove(user1, user2, interaction.user);
await interaction.followUp(response);
},
};

async function getUserLove(user1, user2, mauthor) {
// Calculate random love percentage
const result = Math.ceil(Math.random() * 100);

// Determine love status based on percentage
let loveStatus;
if (result <= 20) {
loveStatus = ":broken_heart: Not a good match :broken_heart:";
} else if (result <= 50) {
loveStatus = ":yellow_heart: Could be better :yellow_heart:";
} else if (result <= 80) {
loveStatus = ":heartpulse: Pretty good match :heartpulse:";
} else {
loveStatus = ":heart_eyes: Perfect match :heart_eyes:";
}

// Determine love image based on percentage
const loveImage = result >= 51 ? "https://media1.giphy.com/media/TmngSmlDjzJfO/giphy.gif?cid=ecf05e47brm0fzk1kan0ni753jmvvik6h27sp13fkn8a9kih&rid=giphy.gif&ct=g" : "https://media4.giphy.com/media/SIPIe590rx6iA/giphy.gif?cid=ecf05e476u1ciogyg7rjw1aaoh29s912axi5r7b5r46fczx6&rid=giphy.gif&ct=g";

// Create embed
const embed = new EmbedBuilder()
.setTitle("Love Meter")
.setDescription("See how much you match with someone! :heart:")
.addFields({
name: "Result",
value: `**${user1}** and **${user2}** match **${result}%**!`,
inline: false,
})
.addFields({
name: "Love Status",
value: loveStatus,
inline: false,
})
.setColor("LuminousVividPink")
.setFooter({
text: `Requested by ${mauthor.tag}`,
})
.setImage(loveImage)
.setTimestamp()
.setThumbnail("https://www.wownow.net.in/assets/images/love.gif")
.setFooter({ text: `Requested by ${mauthor.tag}` });

return { embeds: [embed] };
}

80 changes: 80 additions & 0 deletions src/commands/fun/tictactoe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const { TicTacToe } = require("discord-gamecord");
const { ApplicationCommandOptionType, EmbedBuilder} = require("discord.js");

/**
* @type {import("@structures/Command")}
*/

module.exports = {
name: "tictactoe",
description: "Play Tic Tac Toe with your friends",
cooldown: 15,
category: "FUN",
botPermissions: ["SendMessages", "EmbedLinks", "AddReactions", "ReadMessageHistory", "ManageMessages"],
command: {
enabled: false,
},
slashCommand: {
enabled: true,
ephermal: true,
options: [
{
name: "user",
description: "Select a user to play",
type: ApplicationCommandOptionType.User,
required: true,
},
],
},

async interactionRun(interaction) {
const Game = new TicTacToe({
message: interaction,
isSlashGame: true,
opponent: interaction.options.getUser("user"),
embed: {
title: "Tic Tac Toe",
color: "#5865F2",
statusTitle: "Status",
overTitle: "Game Over",
},
emojis: {
xButton: "❌",
oButton: "🔵",
blankButton: "➖",
},
mentionUser: true,
timeoutTime: 60000,
xButtonStyle: "DANGER",
oButtonStyle: "PRIMARY",
turnMessage: "{emoji} | Its turn of player **{player}**.",
winMessage: "{emoji} | **{player}** won the TicTacToe Game.",
tieMessage: "The Game tied! No one won the Game!",
timeoutMessage: "The Game went unfinished! No one won the Game!",
playerOnlyMessage: "Only {player} and {opponent} can use these buttons.",
});

Game.startGame();
Game.on("gameOver", (result) => {
console.log(result); // => { result... }
const winners = result.winner;
const winner = `<@${winners}>`;
if (result.result === "tie") {
const embed = new EmbedBuilder()
.setTitle("Tic Tac Toe")
.setDescription("The Game tied! No one won the Game!")
.setColor("Red")
.setTimestamp();
interaction.followUp({ embeds: [embed] });
} else if (result.result === "win") {
const embed = new EmbedBuilder()
.setTitle("Tic Tac Toe")
.setDescription(`${winner} won the TicTacToe Game.`)
.setColor("Green")
.setTimestamp();

interaction.followUp({ embeds: [embed] });
}
});
},
};
64 changes: 64 additions & 0 deletions src/commands/owner/reload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const { EmbedBuilder } = require("discord.js");
const { BotClient } = require("@src/structures");
/**
* @type {import("@structures/Command")}
*/

module.exports = {
name: "reload",
description: "Reloads a command that's been modified",
category: "OWNER",
botPermissions: [],
command: {
enabled: true,
aliases: [],
usage: "[reload]",
},
slashCommand: {
enabled: false,
},
async messageRun(message, args) {
const client = new BotClient();

try {
switch (args[0]?.toLowerCase()) {
case "commands":
{
client.loadCommands("src/commands");
}
break;
case "events":
{
client.loadEvents("src/events");
}
break;
case "contexts":
{
client.loadContexts("src/contexts");
}
break;
case "all":
{
client.loadCommands("src/commands");
client.loadContexts("src/contexts");
client.loadEvents("src/events");
}
break;
default:
const embed = new EmbedBuilder();
embed.setTitle("error");
embed.setDescription(`command not selected`);
embed.setColor("Red");
message.reply({ embeds: [embed] });
return;
}
} catch (e) {
console.log(e);
}
const embed = new EmbedBuilder();
embed.setTitle("Reloaded");
embed.setDescription(`Reloaded ${args[0]}`);
embed.setColor("Green");
message.reply({ embeds: [embed] });
},
};
Loading