@satorijs/adapter-discord 4.0.3 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +2 -42
- package/lib/index.js.map +3 -3
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -2095,26 +2095,9 @@ var _DiscordBot = class _DiscordBot extends import_satori5.Bot {
|
|
|
2095
2095
|
if (!this.config.slash)
|
|
2096
2096
|
return;
|
|
2097
2097
|
this.commands = commands;
|
|
2098
|
-
const
|
|
2099
|
-
const remote = Object.fromEntries((await this.internal.getGlobalApplicationCommands(this.selfId, { with_localizations: true })).filter((cmd) => cmd.type === ApplicationCommand2.Type.CHAT_INPUT).map((cmd) => [cmd.name, cmd]));
|
|
2100
|
-
const updates = [];
|
|
2101
|
-
for (const key in { ...local, ...remote }) {
|
|
2102
|
-
if (!local[key]) {
|
|
2103
|
-
logger3.debug("delete command %s", key);
|
|
2104
|
-
await this.internal.deleteGlobalApplicationCommand(this.selfId, remote[key].id);
|
|
2105
|
-
continue;
|
|
2106
|
-
}
|
|
2107
|
-
const data = encodeCommand(local[key]);
|
|
2108
|
-
logger3.debug(data, remote[key]);
|
|
2109
|
-
if (!remote[key]) {
|
|
2110
|
-
logger3.debug("create command: %s", local[key].name);
|
|
2111
|
-
updates.push(data);
|
|
2112
|
-
} else if (!shapeEqual(data, remote[key])) {
|
|
2113
|
-
logger3.debug("edit command: %s", local[key].name);
|
|
2114
|
-
updates.push(data);
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2098
|
+
const updates = commands.map(encodeCommand);
|
|
2117
2099
|
if (updates.length) {
|
|
2100
|
+
logger3.debug("update %d command(s)", updates.length);
|
|
2118
2101
|
await this.internal.bulkOverwriteGlobalApplicationCommands(this.selfId, updates);
|
|
2119
2102
|
}
|
|
2120
2103
|
}
|
|
@@ -2122,29 +2105,6 @@ var _DiscordBot = class _DiscordBot extends import_satori5.Bot {
|
|
|
2122
2105
|
__name(_DiscordBot, "DiscordBot");
|
|
2123
2106
|
__publicField(_DiscordBot, "MessageEncoder", DiscordMessageEncoder);
|
|
2124
2107
|
var DiscordBot = _DiscordBot;
|
|
2125
|
-
function shapeEqual(a, b) {
|
|
2126
|
-
if (a === b)
|
|
2127
|
-
return true;
|
|
2128
|
-
if ((0, import_satori5.isNullable)(a) && (0, import_satori5.isNullable)(b))
|
|
2129
|
-
return true;
|
|
2130
|
-
if (typeof a !== typeof b)
|
|
2131
|
-
return false;
|
|
2132
|
-
if (typeof a !== "object")
|
|
2133
|
-
return false;
|
|
2134
|
-
if (Object.values(a).every(import_satori5.isNullable) && (0, import_satori5.isNullable)(b))
|
|
2135
|
-
return true;
|
|
2136
|
-
if (!a || !b)
|
|
2137
|
-
return false;
|
|
2138
|
-
if (Array.isArray(a)) {
|
|
2139
|
-
if (!Array.isArray(b) || a.length !== b.length)
|
|
2140
|
-
return false;
|
|
2141
|
-
return a.every((item, index) => shapeEqual(item, b[index]));
|
|
2142
|
-
} else if (Array.isArray(b)) {
|
|
2143
|
-
return false;
|
|
2144
|
-
}
|
|
2145
|
-
return Object.keys(a).every((key) => shapeEqual(a[key], b[key]));
|
|
2146
|
-
}
|
|
2147
|
-
__name(shapeEqual, "shapeEqual");
|
|
2148
2108
|
((DiscordBot2) => {
|
|
2149
2109
|
DiscordBot2.Config = import_satori5.Schema.intersect([
|
|
2150
2110
|
import_satori5.Schema.object({
|