(
msg: Api.Message,
text: string,
options?: MessageOptions,
)
| 1159 | class MessageSender { |
| 1160 | static async sendOrEdit( |
| 1161 | msg: Api.Message, |
| 1162 | text: string, |
| 1163 | options?: MessageOptions, |
| 1164 | ): Promise<Api.Message> { |
| 1165 | try { |
| 1166 | const edited = await msg.edit({ text, ...options }); |
| 1167 | if (edited) return edited; |
| 1168 | } catch (error: any) { |
| 1169 | if (isMessageNotModifiedError(error)) { |
| 1170 | return msg; |
| 1171 | } |
| 1172 | if (shouldFallbackToReplyOnEditError(error)) { |
| 1173 | const replied = await msg.reply({ message: text, ...options }); |
| 1174 | if (replied) return replied; |
| 1175 | } |
| 1176 | throw error; |
| 1177 | } |
| 1178 | |
| 1179 | const replied = await msg.reply({ message: text, ...options }); |
| 1180 | if (replied) return replied; |
| 1181 | throw new Error("消息发送失败"); |
| 1182 | } |
| 1183 | |
| 1184 | static async sendNew( |
| 1185 | msg: Api.Message, |
| 1186 | text: string, |
no test coverage detected