4 lines
1.4 KiB
JavaScript
4 lines
1.4 KiB
JavaScript
(function(i,d,c,r,f){"use strict";function a(t){return(t??"").replace(/[[\]]/g,"").trim()}async function m(t){const n=(await(await f.safeFetch(`https://api.urbandictionary.com/v0/define?term=${encodeURIComponent(t)}`)).json())?.list?.[0];if(n)return{word:n.word,definition:a(n.definition).slice(0,800),example:a(n.example).slice(0,400),thumbsUp:n.thumbs_up??0,thumbsDown:n.thumbs_down??0}}const l=3,u=c.findByProps("sendMessage","sendBotMessage");function h(){return[d.registerCommand({name:"urban",description:"Look up a term on Urban Dictionary",options:[{name:"term",description:"What to look up",type:l,required:!0}],execute:async function(t,n){const o=t.find(function(b){return b.name==="term"})?.value;if(!o)return;let e;try{e=await m(o)}catch{r.showToast(`Couldn't reach Urban Dictionary for "${o}"`,void 0);return}if(!e){r.showToast(`No definition found for "${o}"`,void 0);return}if(!u?.sendMessage){r.showToast("Couldn't send the definition - message action not found",void 0);return}const w=`**${e.word}** (\u{1F44D} ${e.thumbsUp} \u{1F44E} ${e.thumbsDown})
|
|
${e.definition}`+(e.example?`
|
|
|
|
*${e.example}*`:"");u.sendMessage(n.channel.id,{content:w})}})]}let s=[];var p={onLoad:function(){s=h()},onUnload:function(){return s.forEach(function(t){return t()})}};return i.default=p,Object.defineProperty(i,"__esModule",{value:!0}),i})({},vendetta.commands,vendetta.metro,vendetta.ui.toasts,vendetta.utils);
|