Commit 987a5e0d authored by nanahira's avatar nanahira

format

parent babcff1e
...@@ -59,7 +59,7 @@ export function KoishiPlugin<T = any>( ...@@ -59,7 +59,7 @@ export function KoishiPlugin<T = any>(
return function < return function <
C extends { C extends {
new (...args: any[]): any; new (...args: any[]): any;
} & KoishiPluginRegistrationOptions<any> } & KoishiPluginRegistrationOptions<any>,
>(originalClass: C) { >(originalClass: C) {
const addUsingList = reflector.getArray(KoishiAddUsingList, originalClass); const addUsingList = reflector.getArray(KoishiAddUsingList, originalClass);
const newClass = class extends originalClass implements PluginClass { const newClass = class extends originalClass implements PluginClass {
...@@ -122,17 +122,15 @@ export function KoishiPlugin<T = any>( ...@@ -122,17 +122,15 @@ export function KoishiPlugin<T = any>(
} }
break; break;
case 'channel': case 'channel':
const { const { data: channelFields } =
data: channelFields, config as CommandPutConfig<'channel'>;
} = config as CommandPutConfig<'channel'>;
if (channelFields) { if (channelFields) {
cmd.channelFields(channelFields); cmd.channelFields(channelFields);
} }
break; break;
case 'username': case 'username':
const { const { data: useDatabase } =
data: useDatabase, config as CommandPutConfig<'username'>;
} = config as CommandPutConfig<'username'>;
if (useDatabase) { if (useDatabase) {
cmd.userFields(['name']); cmd.userFields(['name']);
} }
...@@ -163,9 +161,8 @@ export function KoishiPlugin<T = any>( ...@@ -163,9 +161,8 @@ export function KoishiPlugin<T = any>(
case 'channel': case 'channel':
return argv.session.channel; return argv.session.channel;
case 'username': case 'username':
const { const { data: useDatabase } =
data: useDatabase, config as CommandPutConfig<'username'>;
} = config as CommandPutConfig<'username'>;
if (useDatabase) { if (useDatabase) {
const user = argv.session.user as User.Observed<'name'>; const user = argv.session.user as User.Observed<'name'>;
if (user?.name) { if (user?.name) {
...@@ -196,9 +193,8 @@ export function KoishiPlugin<T = any>( ...@@ -196,9 +193,8 @@ export function KoishiPlugin<T = any>(
); );
switch (regData.type) { switch (regData.type) {
case 'middleware': case 'middleware':
const { const { data: midPrepend } =
data: midPrepend, regData as DoRegisterConfig<'middleware'>;
} = regData as DoRegisterConfig<'middleware'>;
baseContext.middleware( baseContext.middleware(
(session, next) => this[methodKey](session, next), (session, next) => this[methodKey](session, next),
midPrepend, midPrepend,
...@@ -230,9 +226,8 @@ export function KoishiPlugin<T = any>( ...@@ -230,9 +226,8 @@ export function KoishiPlugin<T = any>(
pluginCtx.plugin(pluginDesc.plugin, pluginDesc.options); pluginCtx.plugin(pluginDesc.plugin, pluginDesc.options);
break; break;
case 'command': case 'command':
const { const { data: commandData } =
data: commandData, regData as DoRegisterConfig<'command'>;
} = regData as DoRegisterConfig<'command'>;
let command = baseContext.command( let command = baseContext.command(
commandData.def, commandData.def,
commandData.desc, commandData.desc,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment