rearrange commands folder
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const torn = require('../../torn.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('api')
|
||||
.setDescription('Directly request the Torn API')
|
||||
.addStringOption(option =>
|
||||
option.setName('url')
|
||||
.setDescription('Full URL excluding API key')),
|
||||
async execute(interaction) {
|
||||
const url = interaction.options.getString('url');
|
||||
const res = await torn.api(url)
|
||||
console.log(JSON.stringify(res))
|
||||
await interaction.reply("```json\n" + JSON.stringify(res) + "\n```");
|
||||
},
|
||||
};
|
||||
@@ -1,36 +0,0 @@
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const torn = require('../../torn.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('calcpayout')
|
||||
.setDescription('[WIP] Calculate war payout based on participation')
|
||||
.addIntegerOption(option =>
|
||||
option.setName('total')
|
||||
.setDescription('Full war earnings total before cuts')),
|
||||
async execute(interaction) {
|
||||
const total = interaction.options.getInteger('total');
|
||||
const lastWarRaw = await torn.api('https://api.torn.com/v2/faction/rankedwars?offset=0&limit=1&sort=DESC');
|
||||
const lastWarID = lastWarRaw.rankedwars[0].id
|
||||
const lastWar = await torn.api(`https://api.torn.com/v2/faction/${lastWarID}/rankedwarreport?`);
|
||||
const ourMembers = lastWar.rankedwarreport.factions.find(faction => faction.id === 53026).members; // TODO: dont hardcore faction ID
|
||||
let totalParticipants = 0;
|
||||
let message = `# War Payout Calculation for War against ${lastWar.rankedwarreport.factions.find(faction => faction.id !== 53026).name} with total earnings of $${total.toLocaleString()}:\n`;
|
||||
ourMembers.forEach(member => {
|
||||
if (member.id == 2993713) {
|
||||
console.log(`User ${member.name} is calculated separately.`);
|
||||
} else if (member.attacks > 0) {
|
||||
console.log(`${member.name} participated with ${member.attacks} attacks.`);
|
||||
totalParticipants++;
|
||||
message += `- ${member.name}: Participated with a score of ${member.score} from ${member.attacks} attacks.\n`;
|
||||
} else {
|
||||
console.log(`${member.name} did not participate.`);
|
||||
}
|
||||
});
|
||||
message += `## OseanWorld. earned $${total.toLocaleString()} with Yameii earning 10% off the top for a total of $${Math.ceil(total * 0.1).toLocaleString()}, leaving ${Math.floor(total * 0.9).toLocaleString()} for ${totalParticipants} participants.\n`;
|
||||
message += `## Dividing that out gives each participant approximately $${Math.floor((total * 0.9) / totalParticipants).toLocaleString()} each.`;
|
||||
console.log(`there were ${totalParticipants} participants`);
|
||||
console.log(message)
|
||||
interaction.reply(message);
|
||||
},
|
||||
};
|
||||
@@ -1,56 +0,0 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const torn = require('../../torn.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('profile')
|
||||
.setDescription('Get your Torn profile')
|
||||
.addIntegerOption(option =>
|
||||
option.setName('id')
|
||||
.setDescription('User ID')),
|
||||
async execute(interaction) {
|
||||
let id
|
||||
if (!interaction.options.getInteger('id')) {
|
||||
id = await torn.self.id()
|
||||
console.log(`Profile: Looking up "${id}"`)
|
||||
} else {
|
||||
id = interaction.options.getInteger('id');
|
||||
console.log(`Profile: Looking up "${id}"`)
|
||||
}
|
||||
let userdata = await torn.user.profile(id).catch(console.error);
|
||||
if (!userdata.name) {
|
||||
console.log("Profile: Unable to resolve profile")
|
||||
await interaction.reply("Failed to get profile data :(").catch(console.error);
|
||||
return
|
||||
}
|
||||
console.log(`Profile: Resolved as "${userdata.name}"`)
|
||||
switch (userdata.status.color) {
|
||||
case 'green':
|
||||
userdata.status.hex = 0x69A829
|
||||
break
|
||||
case 'orange':
|
||||
userdata.status.hex = 0xF6B200
|
||||
break
|
||||
case 'red':
|
||||
userdata.status.hex = 0xF78483
|
||||
break
|
||||
case 'blue':
|
||||
userdata.status.hex = 0x4A91B2
|
||||
}
|
||||
|
||||
const userEmbed = new EmbedBuilder()
|
||||
.setColor(userdata.status.hex)
|
||||
.setTitle(`${userdata.name} [${userdata.player_id}]`)
|
||||
.setURL(`https://torn.com/profiles.php?XID=${userdata.player_id}`)
|
||||
.setImage(userdata.profile_image)
|
||||
.setDescription(userdata.rank)
|
||||
.addFields(
|
||||
{ name: userdata.status.description, value: userdata.status.details },
|
||||
{ name: 'Level', value: `${userdata.level}`, inline: true },
|
||||
{ name: 'Age', value: `${userdata.age} days`, inline: true },
|
||||
{ name: `${userdata.last_action.status}`, value: `${userdata.last_action.relative}`, inline: true },
|
||||
)
|
||||
|
||||
await interaction.reply({ embeds: [userEmbed] }).catch(console.error);
|
||||
},
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('task')
|
||||
.setDescription('Execute a task.'),
|
||||
async execute(interaction) {
|
||||
await interaction.reply('todo');
|
||||
},
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('tasks')
|
||||
.setDescription('List tasks'),
|
||||
async execute(interaction) {
|
||||
await interaction.reply('todo');
|
||||
},
|
||||
};
|
||||
@@ -1,11 +0,0 @@
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const torn = require('../../torn.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('test')
|
||||
.setDescription('Test the Torn API'),
|
||||
async execute(interaction) {
|
||||
await interaction.reply(await torn.test());
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user