Skip to content

Commit

Permalink
v65
Browse files Browse the repository at this point in the history
  • Loading branch information
FJrodafo committed Feb 9, 2024
1 parent 38cfbdf commit a4ccdcf
Show file tree
Hide file tree
Showing 18 changed files with 238 additions and 279 deletions.
4 changes: 1 addition & 3 deletions App/src/commands/fun/8ball.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('8ball')
.setDescription('🎱 Get your 8ball answer!')
.setDescription('Get your 8ball answer!')
.addStringOption(option => option
.setName('question')
.setDescription('Type your question')
.setRequired(true),
),
async execute(interaction) {
const question = interaction.options.getString('question');

const msg = [
'It is certain.', 'It is decidely so.', 'Without a doubt.', 'Yes definitely.',
'You may rely on it.', 'As I see it, yes.', 'Most likely.', 'Outlook good.',
Expand All @@ -21,7 +20,6 @@ module.exports = {
'Very doubtful.',
];
const randomMessage = () => msg[Math.floor(Math.random() * msg.length)];

const embed = new EmbedBuilder()
.setColor(0xFFFFFF)
.addFields(
Expand Down
2 changes: 1 addition & 1 deletion App/src/commands/fun/echo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('echo')
.setDescription('🗣️ Replies with your text!')
.setDescription('Replies with your text!')
.addStringOption(option => option
.setName('text')
.setDescription('Type your message')
Expand Down
2 changes: 1 addition & 1 deletion App/src/commands/fun/f.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('f')
.setDescription('Press 🇫 to pay respect.'),
.setDescription('Press F to pay respect.'),
async execute(interaction) {
const message = await interaction.reply({ content: 'Press F to pay respect.', fetchReply: true });
message.react('🇫');
Expand Down
63 changes: 25 additions & 38 deletions App/src/commands/fun/fml.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,32 @@ module.exports = {
.setDescription('📒 Your everyday life stories!'),
async execute(interaction) {
await interaction.deferReply();

const browser = await puppeteer.launch({ headless: 'new' });
const page = await browser.newPage();

try {
await page.goto('https://www.fmylife.com/random', { waitUntil: 'networkidle2' });

const articleData = await page.$eval('article', el => {
const anchors = el.querySelectorAll('a');
const lastAnchor = anchors[anchors.length - 1];

return {
author: el.querySelector('p').innerText,
text: lastAnchor.innerText,
url: 'https://www.fmylife.com' + lastAnchor.getAttribute('href'),
};
});

const embed = new EmbedBuilder()
.setColor(0xFC8CB4)
.setTitle(articleData.author)
.setDescription(articleData.text)
.setThumbnail('https://www.fmylife.com/images/header/logo-fml.png')
.setImage('https://www.fmylife.com/images/header/baseline-fml.png');
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel('LINK')
.setStyle(ButtonStyle.Link)
.setURL(articleData.url),
);
await interaction.editReply({ embeds: [embed], components: [row] });
}
catch (error) {
console.error('Unexpected error:', error);
await interaction.reply({ content: 'Unexpected error. Please try again later.', ephemeral: true });
}
finally {
await browser.close();
}
await page.goto('https://www.fmylife.com/random', { waitUntil: 'networkidle2' });
const articleData = await page.$eval('article', el => {
const anchors = el.querySelectorAll('a');
const lastAnchor = anchors[anchors.length - 1];
return {
author: el.querySelector('p').innerText,
text: lastAnchor.innerText,
url: 'https://www.fmylife.com' + lastAnchor.getAttribute('href'),
};
});
const embed = new EmbedBuilder()
.setColor(0xFC8CB4)
.setTitle(articleData.author)
.setDescription(articleData.text)
.setThumbnail('https://www.fmylife.com/images/header/logo-fml.png')
.setImage('https://www.fmylife.com/images/header/baseline-fml.png');
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel('LINK')
.setStyle(ButtonStyle.Link)
.setURL(articleData.url),
);
await interaction.editReply({ embeds: [embed], components: [row] });
await browser.close();
},
};
2 changes: 1 addition & 1 deletion App/src/commands/fun/ping.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('🏓 Replies with Pong!'),
.setDescription('Replies with pong!'),
async execute(interaction) {
// const sent = await interaction.reply({ content: 'Pinging...', fetchReply: true });
const sent = await interaction.reply({ content: 'pinging...', fetchReply: true });
Expand Down
6 changes: 1 addition & 5 deletions App/src/commands/moderation/clear.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('clear')
.setDescription('🧹 Clear up to 99 messages!')
.setDescription('Clear up to 99 messages!')
.setDefaultMemberPermissions(0)
.addIntegerOption(option => option
.setName('amount')
Expand All @@ -12,15 +12,13 @@ module.exports = {
),
async execute(interaction) {
const amount = interaction.options.getInteger('amount');

if (amount < 1 || amount > 99) {
return interaction.reply({ content: 'You need to input a number between 1 and 99.', ephemeral: true });
}
await interaction.channel.bulkDelete(amount, true).catch(error => {
console.error(error);
interaction.reply({ content: 'There was an error trying to clear messages in this channel!', ephemeral: true });
});

const embed = new EmbedBuilder()
.setColor(0xFF005C)
.setDescription(`🧹 Successfully cleared \`${amount}\` messages.`);
Expand All @@ -43,15 +41,13 @@ module.exports = {
),
async execute(interaction) {
const amount = interaction.options.getInteger('amount');
if (amount < 1 || amount > 99) {
return interaction.reply({ content: 'You need to input a number between 1 and 99.', ephemeral: true });
}
await interaction.channel.bulkDelete(amount, true).catch(error => {
console.error(error);
interaction.reply({ content: 'There was an error trying to prune messages in this channel!', ephemeral: true });
});
return interaction.reply({ content: `Successfully pruned \`${amount}\` messages.`, ephemeral: true });
},
};
Expand Down
25 changes: 9 additions & 16 deletions App/src/commands/moderation/direct-message-remover.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,23 @@ const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('direct-message-remover')
.setDescription('🧹 Delete a specific direct message sent by the bot by its ID.')
.setDescription('Delete a specific direct message sent by the bot by its ID.')
.setDefaultMemberPermissions(0)
.addStringOption(option => option
.setName('message_id')
.setDescription('Message ID to delete')
.setRequired(true),
),
async execute(interaction) {
try {
const messageId = interaction.options.getString('message_id');
const channel = await interaction.user.createDM();
const message = await channel.messages.fetch(messageId);

if (message && message.author.id === interaction.client.user.id) {
await message.delete();
interaction.reply({ content: 'The message was successfully deleted.', ephemeral: true });
}
else {
interaction.reply({ content: 'Message not found or cannot be deleted.', ephemeral: true });
}
const messageId = interaction.options.getString('message_id');
const channel = await interaction.user.createDM();
const message = await channel.messages.fetch(messageId);
if (message && message.author.id === interaction.client.user.id) {
await message.delete();
interaction.reply({ content: 'The message was successfully deleted.', ephemeral: true });
}
catch (error) {
console.error(error);
interaction.reply({ content: 'An error occurred while trying to delete the message.', ephemeral: true });
else {
interaction.reply({ content: 'Message not found or cannot be deleted.', ephemeral: true });
}
},
};
2 changes: 1 addition & 1 deletion App/src/commands/moderation/kick.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('kick')
.setDescription('🚫 Select a member and kick them (but not really).')
.setDescription('Select a member and kick them (but not really).')
.setDefaultMemberPermissions(0)
.addUserOption(option => option
.setName('target')
Expand Down
2 changes: 1 addition & 1 deletion App/src/commands/utility/avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('avatar')
.setDescription('👤 Get the avatar URL of the selected user, or your own avatar!')
.setDescription('Get the avatar URL of the selected user, or your own avatar!')
.addUserOption(option => option
.setName('target')
.setDescription('The user\'s avatar to show')
Expand Down
3 changes: 1 addition & 2 deletions App/src/commands/utility/bot-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('bot-check')
.setDescription('👤 Are you a bot?')
.setDescription('Are you a bot?')
.addUserOption(option => option
.setName('user')
.setDescription('Type a user!')
.setRequired(false),
),
async execute(interaction) {
const user = interaction.options.getUser('user') || interaction.user;

const embed = new EmbedBuilder()
.setAuthor({ name: `${user.tag} botcheck ${user.bot}!`, iconURL: `${user.displayAvatarURL({ dynamic: true, size: 512 })}` })
.setColor(0xFFFFFF);
Expand Down
52 changes: 14 additions & 38 deletions App/src/commands/utility/dauntless-gauntlet-leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,22 @@ const puppeteer = require('puppeteer');
module.exports = {
data: new SlashCommandBuilder()
.setName('dauntless-gauntlet-leaderboard')
.setDescription('🦖 Provides information on the top 5 in Gauntlet.'),
.setDescription('Provides information on the top 5 in Gauntlet.'),
async execute(interaction) {
await interaction.deferReply();

const browser = await puppeteer.launch({ headless: 'new' });
const page = await browser.newPage();

try {
await page.setViewport({ width: 1920, height: 1080 });
await page.goto('https://playdauntless.com/gauntlet/leaderboard/', { waitUntil: 'networkidle2' });

await page.screenshot({
path: 'dauntless-gauntlet-leaderboard.png',
type: 'png',
clip: { x: 761, y: 440, width: 600, height: 421 },
});

const imagePath = './dauntless-gauntlet-leaderboard.png';
const imageFile = new AttachmentBuilder(imagePath);
await interaction.editReply({ files: [imageFile] });
}
catch (error) {
console.error('Unexpected error:', error);
interaction.reply({ content: 'Unexpected error. Please try again later.', ephemeral: true });
}
finally {
await browser.close();
}
await page.setViewport({ width: 1920, height: 1080 });
await page.goto('https://playdauntless.com/gauntlet/leaderboard/', { waitUntil: 'networkidle2' });
await page.screenshot({
path: 'dauntless-gauntlet-leaderboard.png',
type: 'png',
clip: { x: 761, y: 440, width: 600, height: 421 },
});
const imagePath = './dauntless-gauntlet-leaderboard.png';
const imageFile = new AttachmentBuilder(imagePath);
await interaction.editReply({ files: [imageFile] });
await browser.close();
},
};

Expand All @@ -43,27 +31,22 @@ const puppeteer = require('puppeteer');
module.exports = {
data: new SlashCommandBuilder()
.setName('dauntless-gauntlet-leaderboard')
.setDescription('🦖 Provides information on the top 5 in Gauntlet.'),
.setDescription('Provides information on the top 5 in Gauntlet.'),
async execute(interaction) {
await interaction.deferReply();
const browser = await puppeteer.launch({ headless: 'new' });
const page = await browser.newPage();
try {
await page.goto('https://playdauntless.com/gauntlet/leaderboard/', { waitUntil: 'networkidle2' });
const topGuilds = await page.$eval('.leaderboard__entries', el => {
const entries = el.querySelectorAll('.leaderboard__entry');
const guilds = [];
entries.forEach((entry) => {
const rank = entry.querySelector('.rank').innerText;
const guildName = entry.querySelector('.guild-name').innerText;
const guildTag = entry.querySelector('.guild-tag').innerText;
const level = entry.querySelector('.level span').innerText;
const timeLeft = entry.querySelector('.time-left span').innerText;
guilds.push({
rank,
guildName,
Expand All @@ -72,10 +55,8 @@ module.exports = {
timeLeft,
});
});
return guilds.slice(0, 5);
});
const topGuildsInfo = topGuilds.map((guild, index) => (`\n${getRankEmoji(index + 1)} **${guild.guildName}** [${guild.guildTag}]\nLevel: **${guild.level}** Time Left: **${guild.timeLeft}**`)).join('\n');
const iconPath = '../../assets/dauntless/Gauntlet.png';
const iconFile = new AttachmentBuilder(iconPath);
Expand Down Expand Up @@ -117,20 +98,17 @@ const https = require('https');
module.exports = {
data: new SlashCommandBuilder()
.setName('dauntless-gauntlet-leaderboard')
.setDescription('🦖 Provides information on the top 5 in Gauntlet.'),
.setDescription('Provides information on the top 5 in Gauntlet.'),
async execute(interaction) {
try {
https.get('https://storage.googleapis.com/dauntless-gauntlet-leaderboard/production-gauntlet-season10.json', (response) => {
let data = '';
response.on('data', (chunk) => {
data += chunk;
});
response.on('end', () => {
const leaderboardData = JSON.parse(data);
const topGuilds = leaderboardData.leaderboard.slice(0, 5);
const topGuildsInfo = topGuilds.map((guild, index) => (`\n${getRankEmoji(index + 1)} **${guild.guild_name}** [${guild.guild_nameplate}]\nLevel: **${guild.level}** Time Left: **${formatTime(guild.remaining_sec)}**`)).join('\n');
const iconPath = '../../assets/dauntless/Gauntlet.png';
const iconFile = new AttachmentBuilder(iconPath);
Expand Down Expand Up @@ -168,10 +146,8 @@ function getRankEmoji(rank) {
function formatTime(seconds) {
const minutes = Math.floor(seconds / 60);
const remainingSeconds = seconds % 60;
const formattedMinutes = String(minutes).padStart(2, '0');
const formattedSeconds = String(remainingSeconds).padStart(2, '0');
return `${formattedMinutes}:${formattedSeconds}`;
}
*/
Loading

0 comments on commit a4ccdcf

Please sign in to comment.