Skip to content

Commit

Permalink
chore: rename completion to input
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Oct 8, 2023
1 parent 6027e23 commit d83c00e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions adapters/discord/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ export class DiscordMessageEncoder extends MessageEncoder<DiscordBot> {
label,
style: 1,
}
} else if (attrs.type === 'completion') {
} else if (attrs.type === 'input') {
return {
type: ComponentType.BUTTON,
custom_id: 'completion:' + attrs.text,
custom_id: 'input:' + attrs.text,
label,
style: 1,
}
Expand Down
6 changes: 3 additions & 3 deletions adapters/discord/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export async function adaptSession(bot: DiscordBot, input: Discord.Gateway.Paylo
session.event.argv = decodeArgv(data, command)
} else if (input.t === 'INTERACTION_CREATE' && input.d.type === Discord.Interaction.Type.MODAL_SUBMIT) {
const data = input.d.data as Discord.InteractionData.ModalSubmit
if (!data.custom_id.startsWith('completion:')) return
if (!data.custom_id.startsWith('input:')) return
// @ts-ignore
const user_input = data.components[0].components[0].value
await bot.internal.createInteractionResponse(input.d.id, input.d.token, {
Expand All @@ -264,7 +264,7 @@ export async function adaptSession(bot: DiscordBot, input: Discord.Gateway.Paylo
session.content = user_input
} else if (input.t === 'INTERACTION_CREATE' && input.d.type === Discord.Interaction.Type.MESSAGE_COMPONENT) {
const id = (input.d.data as Discord.InteractionData.MessageComponent).custom_id
if (id.startsWith('completion:')) {
if (id.startsWith('input:')) {
await bot.internal.createInteractionResponse(input.d.id, input.d.token, {
type: Discord.Interaction.CallbackType.MODAL,
data: {
Expand All @@ -276,7 +276,7 @@ export async function adaptSession(bot: DiscordBot, input: Discord.Gateway.Paylo
custom_id: id,
type: Discord.ComponentType.TEXT_INPUT,
label: 'auto complete',
value: id.slice('completion:'.length),
value: id.slice('input:'.length),
style: 1,
}],
}],
Expand Down
2 changes: 1 addition & 1 deletion adapters/qq/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export class QQMessageEncoder extends MessageEncoder<QQBot> {
style: 0,
},
action: {
type: attrs.type === 'completion' ? 2
type: attrs.type === 'input' ? 2
: (attrs.type === 'link' ? 0 : 1),
permission: {
type: 2,
Expand Down
2 changes: 1 addition & 1 deletion adapters/telegram/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class TelegramMessageEncoder extends MessageEncoder<TelegramBot> {
text: label,
callback_data: attrs.id,
}
} else if (attrs.type === 'completion') {
} else if (attrs.type === 'input') {
return {
text: label,
switch_inline_query_current_chat: attrs.text,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ export abstract class Bot<T = any> implements Login {
return `${this.platform}:${this.selfId}`
}

session(body: Partial<Event> = {}) {
return new Session(this, body)
session(event: Partial<Event> = {}) {
return new Session(this, event)
}

dispatch(session: Session) {
Expand Down

0 comments on commit d83c00e

Please sign in to comment.