gaber-elsayed

probot short

Aug 23rd, 2021
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1.  
  2. const { default: axios } = require("axios");
  3.  
  4. module.exports = {
  5. name: "short",
  6. description: "Short a long url",
  7. options: [
  8. {
  9. name: "url",
  10. description: "Url to short",
  11. type: 3,
  12. required: true
  13. }
  14. ],
  15. timeout: 5000,
  16. run: async(interaction) => {
  17. const url = interaction.options.getString('url');
  18. const apiToken = ''; // Get your api key from <https://i8.ae/user/tools#api>
  19. try {
  20. const req = await axios({
  21. url: "https://i8.ae/api/url/add",
  22. method: "POST",
  23. headers: {
  24. Authorization: apiToken
  25. },
  26. data: {
  27. url: url
  28. }
  29. })
  30. const data = req.data;
  31. interaction.reply(data.short)
  32. } catch (e) {
  33. console.error(e);
  34. return interaction.reply({ content: `:x: ${e}` })
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment