(id: string, fields: EditWebhookFields)
| 1245 | } |
| 1246 | |
| 1247 | export async function editWebhook(id: string, fields: EditWebhookFields) { |
| 1248 | let imageData: string | null | undefined = undefined; |
| 1249 | if (fields.avatar) { |
| 1250 | if (fields.avatar instanceof Image) { |
| 1251 | imageData = fields.avatar.dataUri() |
| 1252 | } else { |
| 1253 | imageData = fields.avatar |
| 1254 | } |
| 1255 | } else if (fields.avatar === null) { |
| 1256 | imageData = null |
| 1257 | } |
| 1258 | |
| 1259 | let resp = await OpWrappers.callAsyncOp({ |
| 1260 | kind: "discord_webhook_edit", |
| 1261 | arg: { |
| 1262 | webhook_id: id, |
| 1263 | channel_id: fields.channel_id ?? null, |
| 1264 | icon: imageData, |
| 1265 | name: fields.name ?? null, |
| 1266 | } |
| 1267 | }) |
| 1268 | |
| 1269 | return Webhook.fromInternal(resp) |
| 1270 | } |
| 1271 | |
| 1272 | export async function editWebhookWithToken(id: string, token: string, fields: Omit<EditWebhookFields, "channel_id">) { |
| 1273 | let imageData: string | null | undefined = undefined; |
no test coverage detected