(options: Options, valid: void | Channel[])
| 1338 | com.addSelect( |
| 1339 | I18n.guild.ruleId(), |
| 1340 | "rules_channel_id", |
| 1341 | [...textChannels.map((_) => _.name), "none"], |
| 1342 | { |
| 1343 | defaultIndex, |
| 1344 | }, |
| 1345 | [...textChannels.map((_) => _.id), undefined], |
| 1346 | ); |
| 1347 | } |
| 1348 | { |
| 1349 | const sysmap = [null, ...textChannels.map((e) => e.id)]; |
| 1350 | com.addSelect( |
| 1351 | I18n.guild["systemSelect:"](), |
| 1352 | "system_channel_id", |
| 1353 | ["No system messages", ...textChannels.map((e) => e.name)], |
| 1354 | {defaultIndex: sysmap.indexOf(this.properties.system_channel_id)}, |
| 1355 | sysmap, |
| 1356 | ); |
| 1357 | } |
| 1358 | } |
| 1359 | makeInviteMenu(options: Options, valid: void | Channel[]) { |
| 1360 | if (!valid) { |
| 1361 | valid = this.channels.filter((e) => { |
| 1362 | //TODO there are almost certainly more types. is Voice valid? |
| 1363 | return new Set([0, 5]).has(e.type); |
| 1364 | }); |
| 1365 | } |
| 1366 | let channel = valid[0]; |
| 1367 | const div = document.createElement("div"); |
| 1368 | div.classList.add("invitediv"); |
| 1369 | const text = document.createElement("span"); |
| 1370 | text.classList.add("ellipsis"); |
| 1371 | div.append(text); |
| 1372 | let uses = 0; |
| 1373 | let expires = 1800; |
| 1374 | const copycontainer = document.createElement("div"); |
| 1375 | copycontainer.classList.add("copycontainer"); |
| 1376 | const copy = document.createElement("span"); |
| 1377 | copy.classList.add("copybutton", "svgicon", "svg-copy"); |
| 1378 | copycontainer.append(copy); |
| 1379 | copycontainer.onclick = (_) => { |
| 1380 | if (text.textContent) { |
| 1381 | navigator.clipboard.writeText(text.textContent); |
| 1382 | } |
| 1383 | }; |
| 1384 | div.append(copycontainer); |
| 1385 | const update = () => { |
| 1386 | fetch(`${this.info.api}/channels/${channel.id}/invites`, { |
| 1387 | method: "POST", |
| 1388 | headers: this.headers, |
| 1389 | body: JSON.stringify({ |
| 1390 | flags: 0, |
| 1391 | target_type: null, |
| 1392 | target_user_id: null, |
| 1393 | max_age: expires + "", |
| 1394 | max_uses: uses, |
| 1395 | temporary: uses !== 0, |
| 1396 | }), |
| 1397 | }) |
no test coverage detected