Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
danielguirra committed Mar 25, 2024
1 parent 52a8e73 commit 802dc33
Show file tree
Hide file tree
Showing 17 changed files with 268 additions and 99 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ node_modules
logs.txt
database.sqlite
users.json
.vscode
.vscode
.vs
4 changes: 2 additions & 2 deletions data/json/newbible.json
Original file line number Diff line number Diff line change
Expand Up @@ -12534,7 +12534,7 @@
"E dispôs todo o povo, a cada um com as suas armas na mão, desde o lado direito da casa até o lado esquerdo da casa, do lado do altar e da casa, em redor do rei.",
"Então tiraram para fora ao filho do rei, e lhe puseram a coroa; deram-lhe o testemunho, e o fizeram rei; e Joiada e seus filhos o ungiram, e disseram: Viva o rei!",
"Ouvindo, pois, Atalia a voz do povo que concorria e louvava o rei, veio ao povo, à casa do Senhor.",
"E olhou, e eis que o rei estava junto à coluna, à entrada, e os pri…ncipes e as trombetas junto ao rei; e todo o povo da terra estava alegre e tocava as trombetas; e também os cantores tocavam instrumentos musicais, e dirigiam o cantar de louvores; então Atalia rasgou os seus vestidos, e clamou: Traição, traição!",
"E olhou, e eis que o rei estava junto à coluna, à entrada, e os principes e as trombetas junto ao rei; e todo o povo da terra estava alegre e tocava as trombetas; e também os cantores tocavam instrumentos musicais, e dirigiam o cantar de louvores; então Atalia rasgou os seus vestidos, e clamou: Traição, traição!",
"Porém o sacerdote Joiada trouxe para fora os centuriões que estavam postos sobre o exército e disse-lhes: Tirai-a para fora das fileiras, e o que a seguir, morrerá à espada; porque dissera o sacerdote: Não a mateis na casa do Senhor.",
"E lançaram mão dela; e ela foi pelo caminho da entrada da porta dos cavalos, à casa do rei, e ali a mataram.",
"E Joiada fez aliança entre si e o povo e o rei, para que fossem o povo do Senhor.",
Expand Down Expand Up @@ -33885,4 +33885,4 @@
}
]
}
]
]
2 changes: 2 additions & 0 deletions src/command/allComands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { advice } from './commandAdvice';
import { allSkinsLol } from './commandAllSkinsOfChampLol';
import { avatar } from './commandAvatar';
import { ban } from './commandBan';
import { bible } from './commandBible';
Expand Down Expand Up @@ -70,4 +71,5 @@ export const allComands = [
deleteUser,
editUser,
climateDaily,
allSkinsLol,
];
23 changes: 7 additions & 16 deletions src/command/commandAdvice.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import axios from 'axios';
import {
CommandInteraction,
Interaction,
Message,
SlashCommandBuilder,
CommandInteraction,
Interaction,
Message,
SlashCommandBuilder,
} from 'discord.js';

import { embedBuilder } from '../../src/util/getEmbed';
import { translateText } from '../util/translate';
import { Command } from '../interfaces/Command';
import { translateText } from '../util/translate';

/**
* Don't forget to export
* Não esqueça de exportar
* @param Command
* @danielguirra
*/
export const advice: Command = {
data: new SlashCommandBuilder()
.setName('conselho')
Expand All @@ -42,14 +36,11 @@ export const advice: Command = {
});
},
};
/**
*
* @returns Conselho um em portugues
*/

async function getRandomAdvice() {
const url = `https://api.adviceslip.com/advice`;
const advice = await axios.get(url);
const text = advice.data.slip.advice;
const result: any = (await translateText(text)).text || '';
const result = (await translateText(text)).text || '';
return result;
}
119 changes: 110 additions & 9 deletions src/command/commandAllSkinsOfChampLol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import {
Message,
SlashCommandBuilder,
} from 'discord.js';

import names from '../../data/json/nameslol.json';
import { Command } from '../interfaces/Command';
import axios from 'axios';
import { loadinCreator } from '../util/loadin';

/**
* Don't forget to export
Expand All @@ -15,14 +17,14 @@ import { Command } from '../interfaces/Command';
*/
export const allSkinsLol: Command = {
data: new SlashCommandBuilder()
.setName('avatar')
.setName('skinlol')
.setDescription(
'Obtenha a URL do avatar do usuário selecionado ou do seu próprio avatar.'
'Obtenha todas skins do personagem do jogo league of legends'
)
.addUserOption((options) =>
.addStringOption((options) =>
options
.setName('user')
.setDescription('usuário para retornar')
.setName('champion')
.setDescription('Campeão do League retornar as skins')
.setRequired(true)
),
async executeMessageCommand(commandMessage: Message) {
Expand All @@ -36,10 +38,109 @@ export const allSkinsLol: Command = {
},
async executeSlashCommand(commandSlash: CommandInteraction | Interaction) {
if (!commandSlash.isChatInputCommand()) return;
const user = commandSlash.options.getUser('user');
if (user) {
return commandSlash.reply(user.displayAvatarURL({ extension: 'png' }));
const championName = commandSlash.options.getString('champion');
if (championName) {
return loadinCreator(
commandSlash,
async () => {
return await LeagueOfLegendsSkins.SkinsBasedInChampName(
championName
);
},
undefined
);
}
return;
},
};

class LeagueOfLegendsSkins {
static async SkinsBasedInChampName(champName: string) {
try {
const version = await axios.get(
'https://ddragon.leagueoflegends.com/api/versions.json'
);

const champ = capitalizeChampionName(champName);

const json = `http://ddragon.leagueoflegends.com/cdn/${version['data'][0]}/data/pt_BR/champion/${champ}.json`;

const responseApi = await axios.get(json);
const dataChampion = await responseApi.data.data;
const key = Object.keys(dataChampion)[0];
const skinsArray: Skin[] = dataChampion[key].skins;

for (let index = 0; index < skinsArray.length; index++) {
skinsArray[index].championName = dataChampion[key].name;
const num = skinsArray[index].num;
skinsArray[
index
].skinUrl = `https://ddragon.leagueoflegends.com/cdn/img/champion/splash/${key}_${num}.jpg`;

skinsArray[
index
].loading = `https://ddragon.leagueoflegends.com/cdn/img/champion/loading/${key}_${num}.jpg`;

if (skinsArray[index].chromas) {
skinsArray[index].chromas = 'A skin possui chromas';
} else {
skinsArray[index].chromas = 'A skin não possui chromas';
}

if (skinsArray[index].name == 'default') {
skinsArray[index].name =
dataChampion[key].name + ' ' + dataChampion[key].title;
skinsArray[
index
].chromas = `${dataChampion[key].name} possui um total de ${skinsArray.length} skins`;
}
}
const icon = `http://ddragon.leagueoflegends.com/cdn/${version['data'][0]}/img/champion/${champ}.png`;
return {
icon,
skinsArray,
};
} catch (error) {
return `Não foi possivel achar o Campeão **${champName}**`;
}
}
}
export type SkinChampToEmbed = {
icon: string;
skinsArray: Skin[];
};
type Skin = {
championName: string;
idSkin: string;
num: number;
name: string;
chromas: string;
skinUrl: string;
loading: string;
};

function capitalizeChampionName(champName: any) {
const nameChamp = names;
let x;
if (champName in names) {
let finder: keyof typeof names = champName;
x = nameChamp[finder];
}

function capitalizeFirstLetter(inputString: string) {
if (typeof inputString !== 'string' || inputString.length === 0) {
return inputString;
}

return (
inputString.charAt(0).toUpperCase() +
inputString.slice(1).toLowerCase()
);
}

let champ = capitalizeFirstLetter(champName);
if (x) {
champ = x;
}
return champ;
}
8 changes: 4 additions & 4 deletions src/command/commandAvatar.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
CommandInteraction,
Interaction,
Message,
SlashCommandBuilder,
CommandInteraction,
Interaction,
Message,
SlashCommandBuilder,
} from 'discord.js';

import { Command } from '../interfaces/Command';
Expand Down
26 changes: 12 additions & 14 deletions src/command/commandBible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ import * as fs from 'fs';
import { embedBuilder } from '../../src/util/getEmbed';
import { Command } from '../interfaces/Command';

/**
* Don't forget to export
* Não esqueça de exportar
* @param Command
* @danielguirra
*/

export const bible: Command = {
data: new SlashCommandBuilder()
.setName('bible')
Expand Down Expand Up @@ -53,10 +48,14 @@ export const bible: Command = {
.setName('verse')
.setRequired(true)
.setDescription('verse for search')
),
),


async executeMessageCommand(commandMessage: Message) {
return commandMessage.reply('Use somente no slash');
},
},


async executeSlashCommand(commandSlash: CommandInteraction | Interaction) {
if (!commandSlash.isChatInputCommand()) return;
const BibleVersion = commandSlash.options.getString('version');
Expand Down Expand Up @@ -95,12 +94,11 @@ export const bible: Command = {
};

export class Bible {
private urlForGet: string | undefined =
'https://raw.githubusercontent.com/danielguirra/bible-json/main';
version: string | undefined;
book: string | undefined;
chapter: number | undefined;
verse: number | undefined;
private urlForGet: string = 'https://raw.githubusercontent.com/danielguirra/bible-json/main';
version!: string;
book!: string ;
chapter!: number ;
verse!: number ;

static json: BibleJson = JSON.parse(
fs.readFileSync('./data/json/newbible.json', 'utf-8')
Expand Down
14 changes: 4 additions & 10 deletions src/command/commandClearChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const clearChannel: Command = {
.setRequired(true)
),
async executeMessageCommand(commandMessage: Message) {
const numberMessageToDelete: number = stringForNumber(
const numberMessageToDelete: number = parseInt(
commandMessage.content.replace('*cls ', '')
);
const channel = await channelItsGuildTextChannel(commandMessage.channel);
Expand All @@ -41,11 +41,10 @@ export const clearChannel: Command = {
},
async executeSlashCommand(commandSlash: CommandInteraction | Interaction) {
if (!commandSlash.isChatInputCommand()) return;
const numberMessageToDelete: number = stringForNumber(
commandSlash.options.get('value')
);
const numberMessageToDelete = commandSlash.options.getInteger('value');

const channel = await channelItsGuildTextChannel(commandSlash.channel);
if (channel) {
if (channel && numberMessageToDelete) {
const del = await channel.bulkDelete(numberMessageToDelete);
if (del) {
commandSlash.reply('Foi apagado ' + numberMessageToDelete);
Expand All @@ -56,8 +55,3 @@ export const clearChannel: Command = {
return commandSlash.reply({ embeds: [embedBuilder('', '')] });
},
};

function stringForNumber(numberString: any) {
const number: number = numberString;
return number;
}
6 changes: 3 additions & 3 deletions src/command/commandDice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const dice: Command = {
.setRequired(true)
),
async executeMessageCommand(commandMessage: Message) {
const num: any = commandMessage.content.replace('*sorteio ', '');
const num = parseInt(commandMessage.content.replace('*sorteio ', ''));
if (num >= 2) {
const resultado = sorteador(num);
return commandMessage.reply({
Expand All @@ -35,8 +35,8 @@ export const dice: Command = {
},
async executeSlashCommand(commandSlash) {
if (!commandSlash.isChatInputCommand()) return;
const num: any = commandSlash.options.get('value');
if (num >= 2) {
const num = commandSlash.options.getInteger('value');
if (num && num >= 2) {
const resultado = sorteador(num);
return commandSlash.reply({
embeds: [embedBuilder('D20', `Seu valor foi:**${resultado}** `)],
Expand Down
11 changes: 8 additions & 3 deletions src/command/commandGoogleImage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { CommandInteraction, Message, SlashCommandBuilder } from 'discord.js';
import {
CommandInteraction,
Message,
SlashCommandBuilder,
TextBasedChannel,
} from 'discord.js';

import { googleImage } from '../util/googleImage';
import { channelItsGuildTextChannel } from '../util/channelItsGuildTextChannel';
Expand All @@ -20,15 +25,15 @@ export const ime: Command = {
async executeSlashCommand(commandSlash) {
if (!commandSlash.isChatInputCommand()) return;
const text = commandSlash.options.getString('text');
if (text) {
if (text && commandSlash.channel) {
await sendSearch(text, commandSlash.channel, commandSlash);
}
},
};

async function sendSearch(
text: string,
channel: any,
channel: TextBasedChannel,
command: CommandInteraction | Message
) {
const channela = await channelItsGuildTextChannel(channel);
Expand Down
4 changes: 2 additions & 2 deletions src/command/commandHour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function hourNow() {
var dia_sem = data.getDay(); // 0-6 (zero=domingo)
var mes = data.getMonth(); // 0-11 (zero=janeiro)
var ano4 = data.getFullYear(); // 4 dígitos
var hora: any = data.getHours();
var hora = data.getHours();
var min = data.getMinutes(); // 0-59
var seg = data.getSeconds(); // 0-59

Expand All @@ -57,7 +57,7 @@ export function hourNow() {
return { getNameWeek, dia_sem, str_data, str_hora };
}

export const getNameWeek = (x: any) => {
export const getNameWeek = (x: number) => {
return [
'Domingo',
'Segunda-Feira',
Expand Down
Loading

0 comments on commit 802dc33

Please sign in to comment.