Run a giveaway from a bsky post. Choose from those who interacted with it

I think that's it?

Changed files
+25 -6
+23 -4
Index.html
··· 21 21 import { 22 22 CompositeHandleResolver, 23 23 DohJsonHandleResolver, 24 - WellKnownHandleResolver 24 + WellKnownHandleResolver, 25 + CompositeDidDocumentResolver, 26 + PlcDidDocumentResolver, 27 + WebDidDocumentResolver 25 28 } from 'https://esm.sh/@atcute/identity-resolver'; 26 29 27 30 const handleResolver = new CompositeHandleResolver({ ··· 33 36 }); 34 37 35 38 window.resolveHandle = async (handle) => await handleResolver.resolve(handle); 39 + 40 + const docResolver = new CompositeDidDocumentResolver({ 41 + methods: { 42 + plc: new PlcDidDocumentResolver(), 43 + web: new WebDidDocumentResolver(), 44 + }, 45 + }); 46 + 47 + window.resolveDidDocument = async (did) => await docResolver.resolve(did); 36 48 37 49 </script> 38 50 ··· 194 206 // Randomly select winners 195 207 for (let i = 0; i < winnerCount; i++) { 196 208 const randomIndex = Math.floor(Math.random() * uniqueDids.length); 197 - this.winners.push(uniqueDids[randomIndex]); 209 + try { 210 + const didDoc = await window.resolveDidDocument(uniqueDids[randomIndex]); 211 + const handle = didDoc.alsoKnownAs[0].replace("at://", "") ?? uniqueDids[randomIndex]; 212 + this.winners.push(handle); 213 + } catch (e) { 214 + console.log(e); 215 + this.winners.push(uniqueDids[randomIndex]); 216 + } 217 + 198 218 // Remove the winner to avoid duplicates 199 219 uniqueDids.splice(randomIndex, 1); 200 220 } ··· 284 304 <ul class="list-disc pl-5"> 285 305 <template x-for="winner in winners"> 286 306 <li class="mb-1"> 287 - <span x-text="winner"></span> 307 + <a class="link" x-bind:href="`https://bsky.app/profile/${winner}`" x-text="winner"></a> 288 308 </li> 289 309 </template> 290 310 </ul> ··· 298 318 </div> 299 319 </body> 300 320 </html> 301 -
+2 -2
README.md
··· 1 1 # at://giveaways 🎉 2 2 3 - # WIP as in it's not acutally doing anything yet, plan to be done tonight 4 - 5 3 Host a giveaway from a Bluesky post. 4 + 5 + Public instance at:// [https://giveaways.baileytownsend.dev](https://giveaways.baileytownsend.dev) 6 6 7 7 ![](./images/cover.jpg) 8 8