mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-21 20:54:58 +05:00
update to new url shortener
This commit is contained in:
parent
91d1e37be0
commit
7130632844
4 changed files with 28 additions and 11 deletions
|
@ -137,12 +137,12 @@ class JaBaClient extends Client {
|
|||
}
|
||||
|
||||
try {
|
||||
if (this.config.production) await rest.put(Routes.applicationCommands(this.user.id), { body: commands });
|
||||
else await rest.put(Routes.applicationGuildCommands(this.user.id, this.config.support.id), { body: commands });
|
||||
if (this.config.production) await rest.put(Routes.applicationCommands(this.config.userId), { body: commands });
|
||||
else await rest.put(Routes.applicationGuildCommands(this.config.userId, this.config.support.id), { body: commands });
|
||||
|
||||
this.logger.log("Successfully registered application commands.");
|
||||
} catch (err) {
|
||||
this.logger.error(`Error during commands registration!\n${err.message}`);
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,10 +55,17 @@ class LMGTFY extends BaseCommand {
|
|||
url = `https://letmegooglethat.com/?q=${encodeURIComponent(query)}`;
|
||||
|
||||
if (short) {
|
||||
const res = await fetch(`https://plsgo.ru/yourls-api.php?signature=${client.config.apiKeys.jababot_yourls}&action=shorturl&url=${encodeURIComponent(url)}&format=json`).then(res => res.json());
|
||||
const res = await fetch("https://plsgo.ru/rest/v3/short-urls", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"X-Api-Key": client.config.apiKeys.shlink,
|
||||
},
|
||||
body: new URLSearchParams({ longUrl: url }),
|
||||
}).then(res => res.json());
|
||||
|
||||
interaction.editReply({
|
||||
content: `<${res.shorturl}>`,
|
||||
content: `<${res.shortUrl}>`,
|
||||
});
|
||||
} else {
|
||||
interaction.editReply({
|
||||
|
|
|
@ -38,12 +38,20 @@ class Shorturl extends BaseCommand {
|
|||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const url = interaction.options.getString("url");
|
||||
const res = await fetch(`https://plsgo.ru/yourls-api.php?signature=${client.config.apiKeys.jababot_yourls}&action=shorturl&url=${encodeURIComponent(url)}&format=json`).then(res => res.json());
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
||||
interaction.reply({
|
||||
content: `<${res.shorturl}>`,
|
||||
ephemeral: true,
|
||||
const url = interaction.options.getString("url");
|
||||
const res = await fetch("https://plsgo.ru/rest/v3/short-urls", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"X-Api-Key": client.config.apiKeys.shlink,
|
||||
},
|
||||
body: new URLSearchParams({ longUrl: url }),
|
||||
}).then(res => res.json());
|
||||
|
||||
interaction.editReply({
|
||||
content: `<${res.shortUrl}>`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
module.exports = {
|
||||
/* The token of your Discord Bot */
|
||||
token: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
||||
/* UserID of your Discord Bot */
|
||||
userId: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
||||
/* The URL of the MongoDB database */
|
||||
mongoDB: "mongodb://127.0.0.1:27017/discordbot",
|
||||
/* Set to true for production */
|
||||
|
@ -34,6 +36,6 @@ module.exports = {
|
|||
},
|
||||
/* Add your own API keys here */
|
||||
apiKeys: {
|
||||
|
||||
shlink: "12345678-1234-1234-1234-123456789098", /* Shlink.io REST API key */
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue