diff --git a/server/chat-jsx.tsx b/server/chat-jsx.ts similarity index 71% rename from server/chat-jsx.tsx rename to server/chat-jsx.ts index 369cdf31fd..697b60d09f 100644 --- a/server/chat-jsx.tsx +++ b/server/chat-jsx.ts @@ -28,7 +28,6 @@ export interface PSElements extends preact.JSX.IntrinsicElements { spotify: {src: string}; username: {name?: string, class?: string}; psicon: {pokemon: string} | {item: string} | {type: string} | {category: string}; - center: {class?: string}; } export {render}; @@ -37,13 +36,3 @@ export type VNode = preact.VNode; export const h = preact.h; export const Fragment = preact.Fragment; - -export class FormatText extends preact.Component<{isTrusted?: boolean, replaceLinebreaks?: boolean}> { - render() { - const child = this.props.children; - if (typeof child !== 'string') throw new Error(`Invalid props.children type: ${!child ? child : typeof child}`); - return ; - } -} diff --git a/server/chat-plugins/wifi.tsx b/server/chat-plugins/wifi.ts similarity index 61% rename from server/chat-plugins/wifi.tsx rename to server/chat-plugins/wifi.ts index 7d475e675b..4a66dad996 100644 --- a/server/chat-plugins/wifi.tsx +++ b/server/chat-plugins/wifi.ts @@ -141,32 +141,21 @@ class Giveaway extends Rooms.RoomGame { super.destroy(); } - generateReminder(joined?: boolean): string | Chat.VNode; - generateReminder() { - return ''; - } + generateReminder() {} getStyle() { - const css: {[k: string]: string | {[k: string]: string}} = {class: "broadcast-blue"}; - if (this.game === 'BDSP') css.style = {background: '#aa88a9', color: '#fff'}; - return css; + if (this.game === 'BDSP') return `style="background-color: #aa66a9;color: #fff;padding: 2px 4px;"`; + return `class="broadcast-blue"`; } - sendToUser(user: User, content: string | Chat.VNode) { - user.sendTo( - this.room, - Chat.html`|uhtmlchange|giveaway${this.gaNumber}${this.phase}|${
{content}
}` - ); - } - - send(content: string | Chat.VNode, isStart = false) { - this.room.add(Chat.html`|uhtml|giveaway${this.gaNumber}${this.phase}|${
{content}
}`); + send(content: string, isStart = false) { + this.room.add(`|uhtml|giveaway${this.gaNumber}${this.phase}|
${content}
`); if (isStart) this.room.add(`|c:|${Math.floor(Date.now() / 1000)}|&|It's ${this.game} giveaway time!`); this.room.update(); } - changeUhtml(content: string | Chat.VNode) { - this.room.uhtmlchange(`giveaway${this.gaNumber}${this.phase}`, Chat.html`${
{content}
}`); + changeUhtml(content: string) { + this.room.uhtmlchange(`giveaway${this.gaNumber}${this.phase}`, `
${content}
`); this.room.update(); } @@ -188,7 +177,10 @@ class Giveaway extends Rooms.RoomGame { kickUser(user: User) { for (const [ip, id] of this.joined) { if (user.latestIp === ip && !Config.noipchecks || user.previousIDs.includes(id)) { - this.sendToUser(user, this.generateReminder()); + user.sendTo( + this.room, + `|uhtmlchange|giveaway${this.gaNumber}${this.phase}|
${this.generateReminder()}
` + ); this.joined.delete(ip); } } @@ -244,7 +236,7 @@ class Giveaway extends Rooms.RoomGame { 'weavile', 'wobbuffet', 'wooper', 'xatu', 'zubat', ]; if (set.gender === 'F' && validFemale.includes(species.id)) spriteid += '-f'; - const output = ; + const output = ``; return [species.id, output]; } @@ -288,39 +280,22 @@ class Giveaway extends Rooms.RoomGame { return set; } - generateWindow(rightSide: Chat.VNode | string): Chat.VNode { + generateWindow(rightSide: string) { + let buf = `

It's ${this.game} giveaway time!

`; + buf += Utils.html`Giveaway started by ${this.host.name}`; + buf += ``; + buf += Utils.html``; + buf += ``; + buf += ``; + if (this.extraInfo?.trim().length) { + this.extraInfo = this.extraInfo.trim().replace(/
/g, '\n'); + buf += ``; + } + buf += `
Giver: ${this.giver.name}
OT: ${this.ot}, TID: ${this.tid}
${this.sprite} `; const set = Giveaway.convertIVs(this.prize, this.ivs); - return
-

It's {this.game} giveaway time!

- Giveaway started by {this.host.name} - - - - - - - - - {!!this.extraInfo?.trim().length && - - } -
- Giver: {this.giver.name}
- OT: {this.ot}, TID: {this.tid} -
- {this.sprite} - {set} - {rightSide}
- Extra Information
- {this.extraInfo.trim().replace(/
/g, '\n')}
-
-

- Note: You must have a Switch, Pokémon {gameName[this.game]}, {} - and Nintendo Switch Online to receive the prize. {} - Do not join if you are currently unable to trade. Do not enter if you have already won this exact Pokémon, {} - unless it is explicitly allowed. -

-
; + buf += `

${Chat.formatText(set, true)}

${rightSide}
Extra Information
${Chat.formatText(this.extraInfo, true)}
`; + buf += `

Note: You must have a Switch, Pokémon ${gameName[this.game]}, and Nintendo Switch Online to receive the prize. Do not join if you are currently unable to trade. Do not enter if you have already won this exact Pokémon, unless it is explicitly allowed.

`; + return buf; } } @@ -394,16 +369,11 @@ export class QuestionGiveaway extends Giveaway { } generateQuestion() { - return this.generateWindow(<> -

Giveaway Question: {this.question}

-

use /guess to answer.

- ); + return this.generateWindow(`

Giveaway Question: ${this.question}

use /guess to answer.

`); } start() { - this.changeUhtml(

- The giveaway has started! Scroll down to see the question. -

); + this.changeUhtml('

The giveaway has started! Scroll down to see the question.

'); this.phase = 'started'; this.send(this.generateQuestion()); this.timer = setTimeout(() => this.end(false), 1000 * 60 * 5); @@ -465,17 +435,16 @@ export class QuestionGiveaway extends Giveaway { } end(force: boolean) { - const style = {textAlign: 'center', fontSize: '13pt', fontWeight: 'bold'}; if (force) { this.clearTimer(); - this.changeUhtml(

The giveaway was forcibly ended.

); + this.changeUhtml('

The giveaway was forcibly ended.

'); this.room.send("The giveaway was forcibly ended."); } else { if (!this.winner) { - this.changeUhtml(

The giveaway was forcibly ended.

); + this.changeUhtml('

The giveaway was forcibly ended.

'); this.room.send("The giveaway has been forcibly ended as no one has answered the question."); } else { - this.changeUhtml(

The giveaway has ended! Scroll down to see the answer.

); + this.changeUhtml('

The giveaway has ended! Scroll down to see the answer.

'); this.phase = 'ended'; this.clearTimer(); this.room.modlog({ @@ -483,15 +452,10 @@ export class QuestionGiveaway extends Giveaway { userid: this.winner.id, note: `${this.giver.name}'s giveaway for a "${this.prize.species}" (OT: ${this.ot} TID: ${this.tid})`, }); - this.send(this.generateWindow(<> -

- {this.winner.name} won the giveaway! Congratulations! -

-

- {this.question}
- Correct answer{Chat.plural(this.answers)}: {this.answers.join(', ')} -

- )); + this.send(this.generateWindow( + `

${Utils.escapeHTML(this.winner.name)} won the giveaway! Congratulations!

` + + `

${this.question}
Correct answer${Chat.plural(this.answers)}: ${this.answers.join(', ')}

` + )); this.winner.sendTo( this.room, `|raw|You have won the giveaway. PM ${Utils.escapeHTML(this.giver.name)} to claim your prize!` @@ -602,10 +566,8 @@ export class LotteryGiveaway extends Giveaway { generateReminder(joined = false) { const cmd = (joined ? 'Leave' : 'Join'); - return this.generateWindow(<> - The lottery drawing will occur in 2 minutes, and with {Chat.count(this.maxWinners, "winners")}!
- - ); + const button = ``; + return this.generateWindow(`The lottery drawing will occur in 2 minutes, and with ${Chat.count(this.maxWinners, "winners")}!
${button}

`); } display() { @@ -615,9 +577,15 @@ export class LotteryGiveaway extends Giveaway { for (const i in this.room.users) { const thisUser = this.room.users[i]; if (this.checkJoined(thisUser)) { - this.sendToUser(thisUser, joined); + thisUser.sendTo( + this.room, + `|uhtmlchange|giveaway${this.gaNumber}${this.phase}|
${joined}
` + ); } else { - this.sendToUser(thisUser, notJoined); + thisUser.sendTo( + this.room, + `|uhtmlchange|giveaway${this.gaNumber}${this.phase}|
${notJoined}
` + ); } } } @@ -631,7 +599,10 @@ export class LotteryGiveaway extends Giveaway { if (this.checkExcluded(user)) return user.sendTo(this.room, "You are disallowed from entering the giveaway."); this.joined.set(user.latestIp, user.id); - this.sendToUser(user, this.generateReminder(true)); + user.sendTo( + this.room, + `|uhtmlchange|giveaway${this.gaNumber}${this.phase}|
${this.generateReminder(true)}
` + ); user.sendTo(this.room, "You have successfully joined the lottery giveaway."); } @@ -643,7 +614,10 @@ export class LotteryGiveaway extends Giveaway { this.joined.delete(ip); } } - this.sendToUser(user, this.generateReminder(false)); + user.sendTo( + this.room, + `|uhtmlchange|giveaway${this.gaNumber}${this.phase}|
${this.generateReminder(false)}
` + ); user.sendTo(this.room, "You have left the lottery giveaway."); } @@ -652,9 +626,7 @@ export class LotteryGiveaway extends Giveaway { const userlist = [...this.joined.values()]; if (userlist.length === 0) { - this.changeUhtml(

- The giveaway was forcibly ended. -

); + this.changeUhtml('

The giveaway was forcibly ended.

'); this.room.send("The giveaway has been forcibly ended as there are no participants."); return this.destroy(); } @@ -668,26 +640,23 @@ export class LotteryGiveaway extends Giveaway { } end(force = false) { - const style = {textAlign: 'center', fontSize: '13pt', fontWeight: 'bold'}; if (force) { this.clearTimer(); - this.changeUhtml(

The giveaway was forcibly ended.

); + this.changeUhtml('

The giveaway was forcibly ended.

'); this.room.send("The giveaway was forcibly ended."); } else { - this.changeUhtml(

- The giveaway has ended! Scroll down to see the winner{Chat.plural(this.winners)}. -

); + this.changeUhtml(`

The giveaway has ended! Scroll down to see the winner${Chat.plural(this.winners)}.

`); this.phase = 'ended'; const winnerNames = this.winners.map(winner => winner.name).join(', '); this.room.modlog({ action: 'GIVEAWAY WIN', note: `${winnerNames} won ${this.giver.name}'s giveaway for "${this.prize}" (OT: ${this.ot} TID: ${this.tid})`, }); - this.send(this.generateWindow(<> -

Lottery Draw

-

{this.joined.size} users joined the giveaway.
- Our lucky winner{Chat.plural(this.winners)}: {winnerNames}!
Congratulations!

- )); + this.send(this.generateWindow( + `

Lottery Draw

` + + `

${this.joined.size} users joined the giveaway.
` + + `Our lucky winner${Chat.plural(this.winners)}: ${Utils.escapeHTML(winnerNames)}!
Congratulations!

` + )); for (const winner of this.winners) { winner.sendTo( this.room, @@ -745,12 +714,12 @@ export class GTS extends Rooms.RoomGame { } send(content: string) { - this.room.add(Chat.html`|uhtml|gtsga${this.gtsNumber}|${
{content}
}`); + this.room.add(`|uhtml|gtsga${this.gtsNumber}|
${content}
`); this.room.update(); } changeUhtml(content: string) { - this.room.uhtmlchange(`gtsga${this.gtsNumber}`, Chat.html`${
{content}
}`); + this.room.uhtmlchange(`gtsga${this.gtsNumber}`, `
${content}
`); this.room.update(); } @@ -764,33 +733,18 @@ export class GTS extends Rooms.RoomGame { generateWindow() { const sentModifier = this.sent.length ? 5 : 0; const rightSide = this.noDeposits ? - - More Pokémon have been deposited than there are prizes in this giveaway and new deposits will not be accepted. {} - If you have already deposited a Pokémon, please be patient, and do not withdraw your Pokémon. - : <> - To participate, deposit {this.deposit} into the GTS and look for {this.lookfor} - ; - return <> -

- There is a GTS giveaway going on! -

-

- Hosted by: {this.giver.name} | Left: {this.left} -

- - - {!!sentModifier && } - - - - -
- Last winners:
- {this.sent.join(
)} -
{this.sprite} - {this.summary} - {rightSide}
- ; + `More Pokémon have been deposited than there are prizes in this giveaway and new deposits will not be accepted. + If you have already deposited a Pokémon, please be patient, and do not withdraw your Pokémon. + ` : + `To participate, deposit ${this.deposit} into the GTS and look for ${Utils.escapeHTML(this.lookfor)}`; + return `

There is a GTS giveaway going on!

` + + `

Hosted by: ${Utils.escapeHTML(this.giver.name)} | Left: ${this.left}

` + + `` + + (sentModifier ? + `` : + '') + + `` + + `
Last winners:
${this.sent.join('
')}
${this.sprite}${Chat.formatText(this.summary, true)}${rightSide}
`; } updateLeft(num: number) { @@ -804,7 +758,7 @@ export class GTS extends Rooms.RoomGame { this.left--; if (this.left < 1) return this.end(); - this.sent.push(ign); + this.sent.push(Utils.escapeHTML(ign)); if (this.sent.length > 5) this.sent.shift(); this.changeUhtml(this.generateWindow()); @@ -813,33 +767,24 @@ export class GTS extends Rooms.RoomGame { stopDeposits() { this.noDeposits = true; - this.room.send(Chat.html`|html|${

- More Pokémon have been deposited than there are prizes in this giveaway and new deposits will not be accepted. {} - If you have already deposited a Pokémon, please be patient, and do not withdraw your Pokémon. -

}`); + this.room.send(`|html|

More Pokémon have been deposited than there are prizes in this giveaway and new deposits will not be accepted. If you have already deposited a Pokémon, please be patient, and do not withdraw your Pokémon.

`); this.changeUhtml(this.generateWindow()); } end(force = false) { if (force) { this.clearTimer(); - this.changeUhtml( -

The GTS giveaway was forcibly ended.

- ); + this.changeUhtml('

The GTS giveaway was forcibly ended.

'); this.room.send("The GTS giveaway was forcibly ended."); } else { this.clearTimer(); - this.changeUhtml( -

The GTS giveaway has finished.

- ); + this.changeUhtml(`

The GTS giveaway has finished.

`); this.room.modlog({ action: 'GTS FINISHED', userid: this.giver.id, note: `their GTS giveaway for "${this.summary}"`, }); - this.send(

- The GTS giveaway for a "{this.lookfor}" has finished. -

); + this.send(`

The GTS giveaway for a "${Utils.escapeHTML(this.lookfor)}" has finished.

`); Giveaway.updateStats(new Set([this.pokemonID])); } this.room.subGame = null; @@ -858,13 +803,7 @@ export class GTS extends Rooms.RoomGame { const res = regexp.exec(parsed); if (res) { const num = String(species.num).padStart(3, '0'); - return <> - {text.slice(0, res.index)} - - {text.slice(res.index, res.index + res[0].length)} - - {text.slice(res.index + res[0].length)} - ; + return `${text.slice(0, res.index)}${text.slice(res.index, res.index + res[0].length)}${text.slice(res.index + res[0].length)}`; } } return text; @@ -1238,10 +1177,8 @@ export const commands: Chat.ChatCommands = { `|${user.name} has requested to start a question giveaway for ${set.species}.|new question giveaway request`; room.sendRankedUsers(message, '%'); room.sendMods( - Chat.html`|uhtml|giveaway-request-${user.id}|${
- {user.name} wants to start a question giveaway for {set.species}
- -
}` + Utils.html`|uhtml|giveaway-request-${user.id}|
${user.name} wants to start a question giveaway for ${set.species}
` + + `
` ); }, lottery(target, room, user) { @@ -1264,10 +1201,10 @@ export const commands: Chat.ChatCommands = { const message = `|tempnotify|pendingapprovals|Pending lottery giveaway request!` + `|${user.name} has requested to start a lottery giveaway for ${set.species}.|new lottery giveaway request`; room.sendRankedUsers(message, '%'); - room.sendMods(Chat.html`|uhtml|giveaway-request-${user.id}|${
- {user.name} wants to start a lottery giveaway for {set.species}
- -
}`); + room.sendMods( + Utils.html`|uhtml|giveaway-request-${user.id}|
${user.name} wants to start a lottery giveaway for ${set.species}
` + + `
` + ); }, }, approve(target, room, user) { @@ -1398,36 +1335,34 @@ export const commands: Chat.ChatCommands = { this.runBroadcast(); const buf = []; if (user.can('show', null, room)) { - buf.push(
Staff commands - /giveaway create - Pulls up a page to create a giveaway. Requires: + % @ # &
- - /giveaway create question Giver | OT | TID | Game | Question | Answer 1, Answer 2, Answer 3 | IV/IV/IV/IV/IV/IV | Poké Ball | Extra Info | Prize - - Start a new question giveaway (voices can only host their own). Requires: + % @ # &
- - /giveaway create lottery Giver | OT | TID | Game | # of Winners | IV/IV/IV/IV/IV/IV | Poké Ball | Extra Info | Prize - - Start a new lottery giveaway (voices can only host their own). Requires: + % @ # &
- - /giveaway changequestion/changeanswer - - Changes the question/answer of a question giveaway. Requires: Being giveaway host
- /giveaway viewanswer - Shows the answer of a question giveaway. Requires: Being giveaway host/giver
- - /giveaway ban [user], [reason] - - Temporarily bans [user] from entering giveaways. Requires: % @ # &
- /giveaway end - Forcibly ends the current giveaway. Requires: % @ # &
- /giveaway count [pokemon] - Shows how frequently a certain Pokémon has been given away. -
); + buf.push( + `
Staff commands` + + `/giveaway create - Pulls up a page to create a giveaway. Requires: + % @ # &` + ); + buf.push( + `/giveaway create question Giver | OT | TID | Game | Question | Answer 1, Answer 2, Answer 3 | IV/IV/IV/IV/IV/IV | Poké Ball | Extra Info | Prize` + + ` - Start a new question giveaway (voices can only host their own). Requires: + % @ # &`, + ); + buf.push( + `/giveaway create lottery Giver | OT | TID | Game | # of Winners | IV/IV/IV/IV/IV/IV | Poké Ball | Extra Info | Prize` + + ` - Start a new lottery giveaway (voices can only host their own). Requires: + % @ # &`, + ); + buf.push(`/giveaway changequestion/changeanswer - Changes the question/answer of a question giveaway. Requires: Being giveaway host`); + buf.push(`/giveaway viewanswer - Shows the answer of a question giveaway. Requires: Being giveaway host/giver`); + buf.push(`/giveaway ban [user], [reason] - Temporarily bans [user] from entering giveaways. Requires: % @ # &`); + buf.push(`/giveaway end - Forcibly ends the current giveaway. Requires: % @ # &`); + buf.push(`/giveaway count [pokemon] - Shows how frequently a certain Pokémon has been given away.
`); } // Giveaway stuff - buf.push(
Giveaway participation commands - /guess [target] - Guesses an answer for a question giveaway.
- - /giveaway submit - - Allows users to submit giveaways. They must remain online after submitting for it to go through.
- /giveaway viewanswer - Guesses an answer for a question giveaway. Requires: Giveaway host/giver
- /giveaway remind - Shows the details of the current giveaway.
- /giveaway join/leave - Joins/leaves a lottery giveaway. -
); - this.sendReplyBox(<>{buf}); + buf.push( + `
Giveaway participation commands` + + `/guess [target] - Guesses an answer for a question giveaway.` + ); + buf.push(`/giveaway submit - Allows users to submit giveaways. They must remain online after submitting for it to go through.`); + buf.push(`/giveaway viewanswer - Guesses an answer for a question giveaway. Requires: Giveaway host/giver`); + buf.push(`/giveaway remind - Shows the details of the current giveaway.`); + buf.push(`/giveaway join/leave - Joins/leaves a lottery giveaway.
`); + this.sendReplyBox(buf.join('
')); }, }; @@ -1439,454 +1374,317 @@ function makePageHeader(user: User, pageid?: string) { submitted: `View Submitted`, 'submitted-add': `Submit`, }; - const icons: Record = { - create: , - stored: , - 'stored-add': , - submitted: , - 'submitted-add': , + const icons: Record = { + create: ``, + stored: ``, + 'stored-add': ``, + submitted: ``, + 'submitted-add': ``, }; - const buf = []; - buf.push(); - buf.push(

Wi-Fi Giveaways

); + let buf = ``; + buf += `

Wi-Fi Giveaways

`; const urls = []; const room = Rooms.get('wifi')!; // we validate before using that wifi exists for (const i in titles) { - if (urls.length) urls.push(' / '); if (!user.can('mute', null, room) && i !== 'submitted-add') { continue; } const title = titles[i]; const icon = icons[i]; if (pageid === i) { - urls.push(<>{icon} {title}); + urls.push(`${icon} ${title}`); } else { - urls.push(<>{icon} {title}); + urls.push(`${icon} ${title}`); } } - buf.push(<>{[urls]},
); - return
{buf}
; + buf += urls.join(` / `); + buf += `
`; + return `
${buf}
`; } -function formatFakeButton(url: string, text: Chat.VNode): Chat.VNode { - return {text}; +function formatFakeButton(url: string, text: string) { + return `${text}`; } function generatePokeballDropdown() { const pokeballs = Dex.items.all().filter(item => item.isPokeball).sort((a, b) => a.num - b.num); - const pokeballsObj = []; + let buf = `{pokeballsObj}; + buf += ``; + return buf; } export const pages: Chat.PageTable = { giveaways: { ''() { this.title = `[Giveaways]`; - if (!Rooms.search('wifi')) return

There is no Wi-Fi room on this server.

; + if (!Rooms.search('wifi')) return `

There is no Wi-Fi room on this server.

`; this.checkCan('warn', null, Rooms.search('wifi')!); - return
{makePageHeader(this.user)}
; + return `
${makePageHeader(this.user)}
`; }, create(args, user) { this.title = `[Create Giveaways]`; - if (!Rooms.search('wifi')) return

There is no Wi-Fi room on this server.

; + if (!Rooms.search('wifi')) return `

There is no Wi-Fi room on this server.

`; if (!user.can('show', null, Rooms.get('wifi')!)) this.checkCan('warn', null, Rooms.search('wifi')!); const [type] = args; - return
{makePageHeader(this.user, 'create')}{(() => { - if (!type || !['lottery', 'question'].includes(type)) { - return
-

Pick a Giveaway type

- { - formatFakeButton(`/view-giveaways-create-lottery`, <> Lottery) - } | { - formatFakeButton(`/view-giveaways-create-question`, <> Question) - } -
; - } + let buf = `
`; + buf += makePageHeader(this.user, 'create'); + if (!type || !['lottery', 'question'].includes(type)) { + buf += `

Pick a Giveaway type

`; + buf += formatFakeButton(`/view-giveaways-create-lottery`, ` Lottery`); + buf += ` | `; + buf += formatFakeButton(`/view-giveaways-create-question`, ` Question`); + buf += `
`; + } else { switch (type) { case 'lottery': - return <> -

Make a Lottery Giveaway

-
-

-

-

- Game:
- - -

-

- {generatePokeballDropdown()}

-

-
-

-
- -

- -
- ; + buf += `

Make a Lottery Giveaway

`; + buf += `
`; + buf += `

`; + buf += `

`; + buf += `

`; + buf += `Game:
`; + buf += `


`; + buf += generatePokeballDropdown(); + buf += `

`; + buf += `


`; + buf += `


`; + buf += `

`; + buf += `
`; + break; case 'question': - return <> -

Make a Question Giveaway

-
-

-

-

- Game:
- - -

-

-

- {generatePokeballDropdown()}

-

- - -

-
- -

- -
- ; + buf += `

Make a Question Giveaway

`; + buf += `
`; + buf += `

`; + buf += `

`; + buf += `

`; + buf += `Game:
`; + buf += `


`; + buf += `

`; + buf += generatePokeballDropdown(); + buf += `

`; + buf += `

`; + buf += `


`; + buf += `

`; + buf += `
`; + break; } - })()}
; + } + buf += `
`; + return buf; }, stored(args, user) { this.title = `[Stored Giveaways]`; - if (!Rooms.search('wifi')) return

There is no Wi-Fi room on this server.

; + if (!Rooms.search('wifi')) return `

There is no Wi-Fi room on this server.

`; this.checkCan('warn', null, Rooms.search('wifi')!); + let buf = `
${makePageHeader(this.user, args[0] === 'add' ? 'stored-add' : 'stored')}`; const [add, type] = args; const giveaways = [ ...((wifiData.storedGiveaways || {}).lottery || []), ...((wifiData.storedGiveaways || {}).question || []), ]; const adding = add === 'add'; - if (!giveaways.length && !adding) { - return
- {makePageHeader(this.user, adding ? 'stored-add' : 'stored')} -

There are no giveaways stored

-
; - } - return
- {makePageHeader(this.user, adding ? 'stored-add' : 'stored')} - {(() => { - if (!adding) { - const buf = []; - for (let giveaway of giveaways) { - if (wifiData.storedGiveaways.lottery.includes(giveaway as LotteryGiveawayData)) { - giveaway = giveaway as LotteryGiveawayData; - const targetUser = Users.get(giveaway.targetUserID); - buf.push(
-

Lottery

-
- Game: {gameName[giveaway.game]}
- Giver: {giveaway.targetUserID}, {} - OT: {giveaway.ot}, TID: {giveaway.tid}
- # of winners: {giveaway.winners}
- Poké Ball: -
- Prize - {Giveaway.convertIVs(giveaway.prize, giveaway.ivs)} -
- {!!giveaway.extraInfo?.trim() && <> -
-
- Extra Info - {giveaway.extraInfo.trim()} -
- } -
- - {!targetUser?.connected ? - : - - } -
); - } else { - giveaway = giveaway as QuestionGiveawayData; - const targetUser = Users.get(giveaway.targetUserID); - buf.push(
-

Lottery

-
- Game: {gameName[giveaway.game]}
- Giver: {giveaway.targetUserID}, {} - OT: {giveaway.ot}, TID: {giveaway.tid}
- Question: {giveaway.question}
- Answer{Chat.plural(giveaway.answers.length, "s")}: {giveaway.answers.join(', ')}
- Poké Ball: -
- Prize - {Giveaway.convertIVs(giveaway.prize, giveaway.ivs)} -
- {!!giveaway.extraInfo?.trim() && <> -
-
- Extra Info - {giveaway.extraInfo.trim()} -
- } -
- - {!targetUser?.connected ? - : - - } -
); - } + if (!giveaways.length && !adding) return `${buf}

There are no giveaways stored

`; + if (!adding) { + buf += `

Stored Giveaways

`; + for (let giveaway of giveaways) { + if (wifiData.storedGiveaways.lottery.includes(giveaway as any)) { + giveaway = giveaway as LotteryGiveawayData; + buf += `

Lottery


`; + buf += Utils.html`Game: ${gameName[giveaway.game]}, Giver: ${giveaway.targetUserID}, OT: ${giveaway.ot}, TID: ${giveaway.tid}, # of winners: ${giveaway.winners}`; + buf += `
Poké Ball: `; + buf += `
Prize`; + buf += `${Chat.formatText(Giveaway.convertIVs(giveaway.prize, giveaway.ivs), true)}
`; + if (giveaway.extraInfo?.trim()) { + buf += `
Extra Info${Chat.formatText(giveaway.extraInfo.trim(), true)}
`; } - return <>

Stored Giveaways

{buf}; + buf += `
`; + buf += ``; + const targetUser = Users.get(giveaway.targetUserID); + if (!targetUser?.connected) { + buf += ``; + } else { + buf += ``; + } + buf += `
`; } else { - return <>

Store a Giveaway

- {(() => { - if (!type || !['question', 'lottery'].includes(type)) { - return
-

Pick a giveaway type

- { - formatFakeButton(`/view-giveaways-stored-add-lottery`, <> Lottery) - } | { - formatFakeButton(`/view-giveaways-stored-add-question`, <> Question) - } -
; - } - switch (type) { - case 'lottery': - return
-

-

-

- Game:
- - -

-

- {generatePokeballDropdown()}

-

-
-

-
- -

- -
; - case 'question': - return
-

-

-

- Game:
- - -

-

-

- {generatePokeballDropdown()}

-

- - -

-
- -

- -
; - } - })()} - ; + giveaway = giveaway as QuestionGiveawayData; + buf += `

Lottery


`; + buf += Utils.html`Game: ${gameName[giveaway.game]}, Giver: ${giveaway.targetUserID}, OT: ${giveaway.ot}, TID: ${giveaway.tid}`; + buf += Utils.html`
Question: ${giveaway.question}`; + buf += `
Answer${Chat.plural(giveaway.answers.length, "s")}: ${giveaway.answers.join(', ')}`; + buf += `
Poké Ball: `; + buf += `
Prize`; + buf += `${Chat.formatText(Giveaway.convertIVs(giveaway.prize, giveaway.ivs), true)}
`; + if (giveaway.extraInfo?.trim()) { + buf += `
Extra Info${Chat.formatText(giveaway.extraInfo.trim(), true)}
`; + } + buf += `
`; + buf += ``; + const targetUser = Users.get(giveaway.targetUserID); + if (!targetUser?.connected || targetUser.id !== user.id) { + buf += ``; + } else { + buf += ``; + } + buf += `
`; } - })()} -
; + } + } else { + buf += `

Store a Giveaway

`; + if (!type || !['question', 'lottery'].includes(type)) { + buf += `

Pick a giveaway type

`; + buf += formatFakeButton(`/view-giveaways-stored-add-lottery`, ` Lottery`); + buf += ` | `; + buf += formatFakeButton(`/view-giveaways-stored-add-question`, ` Question`); + buf += `
`; + } else { + switch (type) { + case 'lottery': + buf += `
`; + buf += `

`; + buf += `

`; + buf += `

`; + buf += `Game:
`; + buf += `


`; + buf += generatePokeballDropdown(); + buf += `

`; + buf += `


`; + buf += `


`; + buf += `

`; + buf += `
`; + break; + case 'question': + buf += `

Make a Question Giveaway

`; + buf += `
`; + buf += `

`; + buf += `

`; + buf += `

`; + buf += `Game:
`; + buf += `


`; + buf += `

`; + buf += generatePokeballDropdown(); + buf += `

`; + buf += `

`; + buf += `


`; + buf += `

`; + buf += `
`; + break; + } + } + } + buf += ``; + return buf; }, submitted(args, user) { this.title = `[Submitted Giveaways]`; - if (!Rooms.search('wifi')) return

There is no Wi-Fi room on this server.

; + if (!Rooms.search('wifi')) return `

There is no Wi-Fi room on this server.

`; const [add, type] = args; const adding = add === 'add'; if (!adding) this.checkCan('warn', null, Rooms.get('wifi')!); + let buf = `
${makePageHeader(this.user, args[0] === 'add' ? 'submitted-add' : 'submitted')}`; const giveaways = [ ...((wifiData.submittedGiveaways || {}).lottery || []), ...((wifiData.submittedGiveaways || {}).question || []), ]; - if (!giveaways.length && !adding) { - return
- {makePageHeader(this.user, args[0] === 'add' ? 'submitted-add' : 'submitted')} -

There are no submitted giveaways.

-
; - } - return
- {makePageHeader(this.user, args[0] === 'add' ? 'submitted-add' : 'submitted')} - {(() => { - if (!adding) { - const buf = []; - for (let giveaway of giveaways) { - const claimCmd = giveaway.claimed === user.id ? - `/giveaway unclaim ${giveaway.targetUserID}` : - `/giveaway claim ${giveaway.targetUserID}`; - const claimedTitle = giveaway.claimed === user.id ? - "Unclaim" : giveaway.claimed ? - `Claimed by ${giveaway.claimed}` : `Claim`; - const disabled = giveaway.claimed && giveaway.claimed !== user.id ? " disabled" : ""; - buf.push(
- {(() => { - if (wifiData.submittedGiveaways.lottery.includes(giveaway as LotteryGiveawayData)) { - giveaway = giveaway as LotteryGiveawayData; - return <> -

Lottery

-
- Game: {gameName[giveaway.game]}, Giver: {giveaway.targetUserID}, {} - OT: {giveaway.ot}, TID: {giveaway.tid}, {} - # of winners: {giveaway.winners} - {!!giveaway.claimed && <>
Claimed: {giveaway.claimed}}
- Poké Ball: -
- Prize - {Giveaway.convertIVs(giveaway.prize, giveaway.ivs)} -
- {!!giveaway.extraInfo?.trim() && <> -
-
- Extra Info - {giveaway.extraInfo.trim()} -
- } - ; - } else { - giveaway = giveaway as QuestionGiveawayData; - return <> -

Question

-
- Game: {gameName[giveaway.game]}, Giver: {giveaway.targetUserID}, {} - OT: {giveaway.ot}, TID: {giveaway.tid} - {!!giveaway.claimed && <>
Claimed: {giveaway.claimed}}
- Question: {giveaway.question}
- Answer{Chat.plural(giveaway.answers.length, "s")}: {giveaway.answers.join(', ')}
- Poké Ball: -
- Prize - {Giveaway.convertIVs(giveaway.prize, giveaway.ivs)} -
- {!!giveaway.extraInfo?.trim() && <> -
-
- Extra Info - {giveaway.extraInfo.trim()} -
- } - ; - } - })()} -
- {!Users.get(giveaway.targetUserID)?.connected ? <> - - - - : <> - - - - } -
); + if (!giveaways.length && !adding) return `${buf}

There are no submitted giveaways.

`; + if (!adding) { + buf += `

Submitted Giveaways

`; + for (let giveaway of giveaways) { + if (wifiData.submittedGiveaways.lottery.includes(giveaway as any)) { + giveaway = giveaway as LotteryGiveawayData; + buf += `

Lottery


`; + buf += Utils.html`Game: ${gameName[giveaway.game]}, Giver: ${giveaway.targetUserID}, OT: ${giveaway.ot}, TID: ${giveaway.tid}, # of winners: ${giveaway.winners}`; + if (giveaway.claimed) { + buf += Utils.html`
Claimed: ${giveaway.claimed}`; + } + buf += `
Poké Ball: `; + buf += `
Prize`; + buf += `${Chat.formatText(Giveaway.convertIVs(giveaway.prize, giveaway.ivs), true)}
`; + if (giveaway.extraInfo?.trim()) { + buf += `
Extra Info${Chat.formatText(giveaway.extraInfo.trim(), true)}
`; } - return <>

Submitted Giveaways

{buf}; } else { - return <> -

Submit a Giveaway

- {(() => { - if (!type || !['question', 'lottery'].includes(type)) { - return
-

Pick a giveaway type

- { - formatFakeButton(`/view-giveaways-submitted-add-lottery`, <> Lottery) - } | { - formatFakeButton(`/view-giveaways-submitted-add-question`, <> Question) - } -
; - } - switch (type) { - case 'lottery': - return
-

-

-

- Game:
- - -

-

- {generatePokeballDropdown()}

-

-
-

-
- -

- -
; - case 'question': - return
-

-

-

- Game:
- - -

-

-

- {generatePokeballDropdown()}

-

- -

-
- -

- -
; - } - })()} - ; + giveaway = giveaway as QuestionGiveawayData; + buf += `

Question


`; + buf += Utils.html`Game: ${gameName[giveaway.game]}, Giver: ${giveaway.targetUserID}, OT: ${giveaway.ot}, TID: ${giveaway.tid}`; + if (giveaway.claimed) { + buf += Utils.html`
Claimed: ${giveaway.claimed}`; + } + buf += Utils.html`
Question: ${giveaway.question}`; + buf += `
Answer${Chat.plural(giveaway.answers.length, "s")}: ${giveaway.answers.join(', ')}`; + buf += `
Poké Ball: `; + buf += `
Prize`; + buf += `${Chat.formatText(Giveaway.convertIVs(giveaway.prize, giveaway.ivs), true)}
`; + if (giveaway.extraInfo?.trim()) { + buf += `
Extra Info${Chat.formatText(giveaway.extraInfo.trim(), true)}
`; + } } - })()} -
; + buf += `
`; + const claimCmd = giveaway.claimed === user.id ? + `/giveaway unclaim ${giveaway.targetUserID}` : + `/giveaway claim ${giveaway.targetUserID}`; + const claimedTitle = giveaway.claimed === user.id ? + "Unclaim" : + giveaway.claimed ? `Claimed by ${giveaway.claimed}` : `Claim`; + const disabled = giveaway.claimed && giveaway.claimed !== user.id ? " disabled" : ""; + if (!Users.get(giveaway.targetUserID)?.connected) { + buf += ``; + buf += ``; + buf += ``; + } else { + buf += ``; + buf += ``; + buf += ``; + } + buf += `
`; + } + } else { + buf += `

Submit a Giveaway

`; + if (!type || !['question', 'lottery'].includes(type)) { + buf += `

Pick a giveaway type

`; + buf += formatFakeButton(`/view-giveaways-submitted-add-lottery`, ` Lottery`); + buf += ` | `; + buf += formatFakeButton(`/view-giveaways-submitted-add-question`, ` Question`); + buf += `
`; + } else { + switch (type) { + case 'lottery': + buf += `
`; + buf += `

`; + buf += `

`; + buf += `

`; + buf += `Game:
`; + buf += `


`; + buf += generatePokeballDropdown(); + buf += `

`; + buf += `


`; + buf += `


`; + buf += `

`; + buf += `
`; + break; + case 'question': + buf += `
`; + buf += `

`; + buf += `

`; + buf += `

`; + buf += `Game:
`; + buf += `


`; + buf += `

`; + buf += generatePokeballDropdown(); + buf += `

`; + buf += `

`; + buf += `


`; + buf += `

`; + buf += `
`; + break; + } + } + } + buf += `
`; + return buf; }, }, };