Discord: eigener Kanal fuer Beitritte, Spielvorschlaege und Reactions als Forum
Beitrittsmeldungen liefen nach #allgemein, weil Discord ohne Angabe den ersten Kanal nimmt. Jetzt gehen sie nach #begruessung (SYSTEM_CHANNEL). Die von Abdu angelegten Textkanaele spielvorschlaege und reaction-einsendungen sind jetzt Foren im Bauplan: ein Beitrag je Spiel bzw. Clip, 👍 als Standard-Reaktion, Stand-Tags nur fuer Mods. apply.ts kann dafuer Tags und Standard-Reaktion anlegen und nachziehen; fremde Tags bleiben mit ihrer ID stehen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
81ab865de0
commit
5494c6d24d
7 files changed
+211
-9
No files matched your search
@@ -7,7 +7,7 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { CH, type ApiChannel, type ApiGuild, type ApiOverwrite, type ApiRole, type ApiWebhook, type Rest } from './api.ts';
|
||||
import { applyPlan, type Step } from './apply.ts';
|
||||
import { applyPlan, mergeTags, type Step } from './apply.ts';
|
||||
import { CATEGORIES, CHANNELS, EVERYONE, ROLES } from './plan.ts';
|
||||
import { str } from './permissions.ts';
|
||||
|
||||
@@ -504,3 +504,41 @@ test('eine Nachricht ohne Knopfleiste bekommt sie nachgereicht', async () => {
|
||||
assert.equal((api.messages.get(kanal)![0]!.components as unknown[]).length, 1);
|
||||
assert.equal(api.messages.get(kanal)!.length, 1, 'nicht neu posten');
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------- Foren
|
||||
|
||||
test('ein Forum bekommt Tags und Standard-Reaktion aus dem Bauplan', async () => {
|
||||
const api = new FakeDiscord();
|
||||
await run(api);
|
||||
const plan = CHANNELS.find((c) => c.key === 'spielvorschlaege')!;
|
||||
const forum = live(api, 'spielvorschlaege')!;
|
||||
assert.equal(forum.type, CH.FORUM);
|
||||
assert.deepEqual(forum.available_tags?.map((t) => t.name), plan.tags?.map((t) => t.name));
|
||||
assert.equal(forum.default_reaction_emoji?.emoji_name, plan.reaction);
|
||||
});
|
||||
|
||||
test('ein Textkanal gleichen Namens wird nicht fuer das Forum gehalten', async () => {
|
||||
// Discord kann einen Textkanal nicht in ein Forum umwandeln. Der alte steht
|
||||
// also daneben, bis ihn jemand loescht - angepasst werden darf er nicht.
|
||||
const api = new FakeDiscord();
|
||||
api.channels.push({ id: '1', name: '🎮│spielvorschläge', type: CH.TEXT, position: 0, parent_id: null });
|
||||
await run(api);
|
||||
assert.equal(api.channels.filter((c) => c.name === '🎮│spielvorschläge').length, 2);
|
||||
assert.equal(api.channels.find((c) => c.id === '1')?.available_tags, undefined);
|
||||
});
|
||||
|
||||
test('von Hand angelegte Tags bleiben mit ihrer ID stehen', async () => {
|
||||
const fremd = { id: '77', name: 'Horror', emoji_name: '👻', moderated: false };
|
||||
const eigen = { id: '78', name: 'gespielt', emoji_name: '✔️', moderated: false };
|
||||
const out = mergeTags([fremd, eigen], [
|
||||
{ name: 'Gespielt', emoji: '✅', moderated: true },
|
||||
{ name: 'Eher nicht', emoji: '❌', moderated: true },
|
||||
]);
|
||||
assert.ok(out);
|
||||
assert.deepEqual(out.find((t) => t.name === 'Horror'), fremd);
|
||||
const g = out.find((t) => t.name === 'Gespielt')!;
|
||||
assert.equal(g.id, '78', 'ohne ID verlieren die Beitraege ihre Markierung');
|
||||
assert.equal(g.emoji_name, '✅');
|
||||
assert.ok(out.find((t) => t.name === 'Eher nicht'));
|
||||
assert.equal(mergeTags(out, [{ name: 'Gespielt', emoji: '✅', moderated: true }]), null);
|
||||
});
|
||||
Reference in new issue
Block a user