mirror of
https://github.com/NovaGM/Modules.git
synced 2024-08-14 22:47:01 +00:00
Compare commits
No commits in common. "04e817908e7564a5bba01f82fa1ff77600143df6" and "4676a8d90e0e943afa40b9d46d3b22707dd6b2c8" have entirely different histories.
04e817908e
...
4676a8d90e
5 changed files with 5 additions and 126 deletions
|
@ -1,11 +0,0 @@
|
||||||
{
|
|
||||||
"main": "index.js",
|
|
||||||
|
|
||||||
"name": "SnowflakeInfo",
|
|
||||||
"description": "Returns info about a given snowflake.",
|
|
||||||
"tags": ["commands"],
|
|
||||||
|
|
||||||
"authors": ["717352467280691331"],
|
|
||||||
|
|
||||||
"version": "1.0.0"
|
|
||||||
}
|
|
|
@ -1,87 +0,0 @@
|
||||||
import { commands, internalMessage } from '@goosemod/patcher';
|
|
||||||
|
|
||||||
const discordEpoch = Number(1420070400000);
|
|
||||||
|
|
||||||
const idToBinary = (num) => {
|
|
||||||
let bin = '';
|
|
||||||
let high = parseInt(num.slice(0, -10)) || 0;
|
|
||||||
let low = parseInt(num.slice(-10));
|
|
||||||
try {
|
|
||||||
while (low > 0 || high > 0) {
|
|
||||||
bin = String(low & 1) + bin;
|
|
||||||
low = Math.floor(low / 2);
|
|
||||||
if (high > 0) {
|
|
||||||
low += 5000000000 * (high % 2);
|
|
||||||
high = Math.floor(high / 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
return bin;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
goosemodHandlers: {
|
|
||||||
onImport: () => {
|
|
||||||
commands.add(
|
|
||||||
'echo',
|
|
||||||
"Prints out all of the message's text in an internal message.",
|
|
||||||
(args) => {
|
|
||||||
internalMessage(args.text[0].text);
|
|
||||||
console.log(args);
|
|
||||||
},
|
|
||||||
[
|
|
||||||
{
|
|
||||||
type: 3,
|
|
||||||
name: 'text',
|
|
||||||
description: 'Text to be printed in an internal message.',
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
commands.add(
|
|
||||||
'snowflake',
|
|
||||||
'Returns info about a given snowflake.',
|
|
||||||
(args) => {
|
|
||||||
// Check if the supplied argument is actually a snowflake or not
|
|
||||||
if (!/\d{1,20}/.test(args.snowflake[0].text)) {
|
|
||||||
internalMessage('The provided argument is not a snowflake.');
|
|
||||||
} else {
|
|
||||||
const binary = idToBinary(args.snowflake[0].text).toString(2).padStart(64, '0');
|
|
||||||
|
|
||||||
const res = {
|
|
||||||
timestamp: parseInt(binary.substring(0, 42), 2) + discordEpoch,
|
|
||||||
workerID: parseInt(binary.substring(42, 47), 2),
|
|
||||||
processID: parseInt(binary.substring(47, 52), 2),
|
|
||||||
increment: parseInt(binary.substring(52, 64), 2),
|
|
||||||
binary: binary,
|
|
||||||
};
|
|
||||||
|
|
||||||
internalMessage(
|
|
||||||
`Snowflake info for \`${args.snowflake[0].text}\`\n\n` +
|
|
||||||
`**Timestamp**: ${new Date(res.timestamp).toUTCString()} (${res.timestamp})\n` +
|
|
||||||
`**Worker ID**: ${res.workerID}\n` +
|
|
||||||
`**Process ID**: ${res.processID}\n` +
|
|
||||||
`**Increment**: ${res.increment}\n` +
|
|
||||||
`**Binary**: ${res.binary}\n`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[
|
|
||||||
{
|
|
||||||
type: 3,
|
|
||||||
name: 'snowflake',
|
|
||||||
description: 'Snowflake to decrypt.',
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
onRemove: () => {
|
|
||||||
commands.remove('echo');
|
|
||||||
commands.remove('snowflake');
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -22,6 +22,7 @@ export function textInputField(text, subtext, placeholder, onApply, initialValue
|
||||||
inputEl.classList.add('inputDefault-_djjkz', 'input-cIJ7To');
|
inputEl.classList.add('inputDefault-_djjkz', 'input-cIJ7To');
|
||||||
inputEl.placeholder = placeholder;
|
inputEl.placeholder = placeholder;
|
||||||
inputEl.type = 'text';
|
inputEl.type = 'text';
|
||||||
|
inputEl.value = initialValue ? initialValue : '';
|
||||||
|
|
||||||
inputWrapEl.appendChild(inputEl);
|
inputWrapEl.appendChild(inputEl);
|
||||||
|
|
||||||
|
@ -46,16 +47,6 @@ export function textInputField(text, subtext, placeholder, onApply, initialValue
|
||||||
dividerEl.classList.add('divider-3573oO', 'dividerDefault-3rvLe-');
|
dividerEl.classList.add('divider-3573oO', 'dividerDefault-3rvLe-');
|
||||||
dividerEl.style.marginTop = subtext ? '20px' : '45px';
|
dividerEl.style.marginTop = subtext ? '20px' : '45px';
|
||||||
|
|
||||||
// Insertion checker
|
|
||||||
// A bit hacky...
|
|
||||||
// But works :)
|
|
||||||
let insertCheckId = setInterval(() => {
|
|
||||||
if (el.parentNode != null) {
|
|
||||||
inputEl.value = initialValue != undefined ? initialValue() : '';
|
|
||||||
clearInterval(insertCheckId);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
el.appendChild(textEl);
|
el.appendChild(textEl);
|
||||||
el.appendChild(buttonEl);
|
el.appendChild(buttonEl);
|
||||||
el.appendChild(inputWrapEl);
|
el.appendChild(inputWrapEl);
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
|
|
||||||
"authors": ["186496078273708033"],
|
"authors": ["186496078273708033"],
|
||||||
|
|
||||||
"version": "1.1.0"
|
"version": "1.0.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import { textInputField } from './custom-settings.js';
|
||||||
let settingsPage = "Settings Experiment";
|
let settingsPage = "Settings Experiment";
|
||||||
let settings;
|
let settings;
|
||||||
let defaultSettings = {
|
let defaultSettings = {
|
||||||
inputText: "Default value"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -131,26 +130,13 @@ export default {
|
||||||
{
|
{
|
||||||
type: "custom",
|
type: "custom",
|
||||||
element: textInputField(
|
element: textInputField(
|
||||||
"Text Input (static initial value)",
|
"Text Input",
|
||||||
"Prototype",
|
"Prototype",
|
||||||
"Placeholder",
|
"Placeholder",
|
||||||
value => {
|
value => {
|
||||||
showToast(`Text Input: ${value}`);
|
showToast(`Text Input: ${value}`);
|
||||||
},
|
},
|
||||||
() => "Preset value"
|
"Preset value"
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "custom",
|
|
||||||
element: textInputField(
|
|
||||||
"Text Input (loading from and saving to settings)",
|
|
||||||
"Prototype",
|
|
||||||
"Placeholder",
|
|
||||||
value => {
|
|
||||||
showToast(`Text Input: ${value}`);
|
|
||||||
settings.inputText = value;
|
|
||||||
},
|
|
||||||
() => settings.inputText
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in a new issue