All New

user:thomas gists created by user

title:mygist gists with given title

description:sync gists with given description

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

all:systemctl search all fields

Register

Login

All New Register Login

nuno

Joined 2 months ago

Recently created
Least recently created
Recently updated
Least recently updated
All gists 570

nuno / .ts

0 likes
0 forks
1 files
Last active 4 weeks ago
1 async function handleSwitchAfterReclaim(btn: ButtonInteraction): Promise<void> {
2 const prefix = btn.customId.startsWith("companion_switch:") ? "companion_switch:" : "switch_after_reclaim:";
3 const withoutPrefix = btn.customId.slice(prefix.length);
4 const firstColon = withoutPrefix.indexOf(":");
5 const userKey = withoutPrefix.slice(0, firstColon);
6 const rest = withoutPrefix.slice(firstColon + 1);
7 const lastColon = rest.lastIndexOf(":");
8 const charName = rest.slice(0, lastColon);
9 const prevVoteType = (rest.slice(lastColon + 1) || "yes") as "yes" | "no";

nuno / switch.ts

0 likes
0 forks
1 files
Last active 4 weeks ago
1 import { ChatInputCommandInteraction, TextChannel } from "discord.js";
2 import { cfg } from "@systems/config";
3 import { resolveUser, hasOfficerRole } from "@systems/users";
4 import { setActiveCharacter, getActiveCharacter, getCharacterByName, getCharacters } from "@systems/characters";
5 import {
6 getEffectiveCharacter,
7 setSessionBorrow,
8 setPersistentPreference,
9 clearPersistentPreference,
10 clearSessionBorrowForUser,

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 4 weeks ago
1 async function handleSwitchAfterReclaim(btn: ButtonInteraction): Promise<void> {
2 const prefix = btn.customId.startsWith("companion_switch:") ? "companion_switch:" : "switch_after_reclaim:";
3 const withoutPrefix = btn.customId.slice(prefix.length);
4 const firstColon = withoutPrefix.indexOf(":");
5 const userKey = withoutPrefix.slice(0, firstColon);
6 const rest = withoutPrefix.slice(firstColon + 1);
7 const lastColon = rest.lastIndexOf(":");
8 const charName = rest.slice(0, lastColon);
9 const prevVoteType = (rest.slice(lastColon + 1) || "yes") as "yes" | "no";

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 4 weeks ago
1 async function handleSwitchAfterReclaim(btn: ButtonInteraction): Promise<void> {
2 const parts = btn.customId.split(":");
3 const userKey = parts[1];
4 const charName = parts[2];
5 const prevVoteType = (parts[3] ?? "yes") as "yes" | "no";
6
7 const chars = JSON.parse(
8 fs.readFileSync(path.join(__dirname, "../../data/characters.json"), "utf8")
9 );

nuno / charSelect.ts

0 likes
0 forks
1 files
Last active 4 weeks ago
1 import {
2 ButtonBuilder,
3 ButtonStyle,
4 ActionRowBuilder,
5 } from "discord.js";
6 import { getCharacters, getCharacterByName } from "@systems/characters";
7 import { getClassEmoji } from "@systems/emojis";
8 import { format } from "@format";
9 import { Character } from "@types";
10 import fs from "fs";

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 4 weeks ago
1 tg-bot-ts-dev | [interactions] interaction btnId: impersonate_page:1
2 tg-bot-ts-dev | Interaction error: DiscordAPIError[50035]: Invalid Form Body
3 tg-bot-ts-dev | data.components[0].components[3].custom_id[COMPONENT_CUSTOM_ID_DUPLICATED]: Component custom id cannot be duplicated
4 tg-bot-ts-dev | at handleErrors (/app/node_modules/@discordjs/rest/src/lib/handlers/Shared.ts:148:10)
5 tg-bot-ts-dev | at processTicksAndRejections (node:internal/process/task_queues:103:5)
6 tg-bot-ts-dev | at async BurstHandler.runRequest (/app/node_modules/@discordjs/rest/src/lib/handlers/BurstHandler.ts:144:20)
7 tg-bot-ts-dev | at async _REST.request (/app/node_modules/@discordjs/rest/src/lib/REST.ts:210:20)
8 tg-bot-ts-dev | at async ButtonInteraction.update (/app/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:354:22)
9 tg-bot-ts-dev | at async handleImpersonateButton (/app/src/subcommands/impersonate.ts:113:5)
10 tg-bot-ts-dev | at async Client.handleInteraction (/app/src/handlers/interactions.ts:132:16) {

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 4 weeks ago
1 export async function showActiveCharSwitching(interaction: ButtonInteraction): Promise<void> {
2 const userId = interaction.user.id;
3 const member = interaction.guild!.members.cache.get(userId)
4 ?? await interaction.guild!.members.fetch(userId);
5 const user = await resolveUser(member);
6
7 const impersonating = getImpersonation(userId);
8 const voteId = impersonating ? `impersonated:${impersonating}` : userId;
9 const clicks = clickCounts.get(voteId)!;

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 4 weeks ago
1 import {
2 EmbedBuilder,
3 ButtonBuilder,
4 ButtonStyle,
5 ActionRowBuilder,
6 TextChannel,
7 GuildMember,
8 } from "discord.js";
9 import { PollState, VoteEntry, Nation, TGSlot } from "@src/types";
10 import { cfg } from "@systems/config";

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 4 weeks ago
1 import {
2 ButtonInteraction,
3 StringSelectMenuBuilder,
4 StringSelectMenuOptionBuilder,
5 ActionRowBuilder,
6 TextChannel
7 } from "discord.js";
8 import { cfg } from "@systems/config";
9 import { pollReplyAndDelete } from "../utils";
10 import { resolveUser } from "@systems/users";

nuno / scores.ts

0 likes
0 forks
1 files
Last active 4 weeks ago
1 import { TGScore, Nation, ClassKey } from "../types";
2 import { cfg } from "./config";
3 import { upsertScore, todayString } from "./history";
4 import { recordScore } from "./wrank";
5
6 // Normalize a slot string to a 24h integer hour
7 // Accepts: "20", "8", "8pm", "20:00", "midnight", "midday", "noon"
8 export function normalizeSlot(input: string): number | null {
9 const s = input.trim().toLowerCase();
10 if (s === "midnight") return 0;
Newer Older

Powered by Opengist ⋅ Load: 115ms⋅

English
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文
⋅ KrilHub