删除自定义表情符号

本指南介绍了如何使用 Google Chat API 的 CustomEmoji 资源的 delete 方法删除 Google Workspace 组织中的自定义表情符号。

默认情况下,用户只能删除自己创建的自定义表情符号。由管理员分配的表情符号管理者可以删除组织中的任何自定义表情符号。

自定义表情符号仅适用于 Google Workspace 账号,并且您的管理员必须为贵组织启用自定义表情符号。如需了解详情,请参阅了解 Google Chat 中的自定义表情符号管理自定义表情符号权限

前提条件

Node.js

删除自定义表情符号

如需删除具有用户身份验证的自定义表情符号,请在请求中传递以下内容:

  • 指定 chat.customemojis 授权范围。
  • 调用 DeleteCustomEmoji() 方法。
    • 在请求正文中,将 name 设置为要删除的自定义表情符号的资源名称。

以下示例演示了如何删除自定义表情符号。

Node.js

chat/client-libraries/cloud/delete-custom-emoji-user-cred.js
import {createClientWithUserCredentials} from './authentication-utils.js';

const USER_AUTH_OAUTH_SCOPES = ['https://www.googleapis.com/auth/chat.customemojis'];

// This sample shows how to delete a custom emoji with user credential
async function main() {
  // Create a client
  const chatClient = await createClientWithUserCredentials(USER_AUTH_OAUTH_SCOPES);

  // Initialize request argument(s)
  const request = {
    // TODO(developer): Replace EMOJI_NAME here.
    name: 'customEmojis/EMOJI_NAME'
  };

  // Make the request
  const response = await chatClient.deleteCustomEmoji(request);

  // Handle the response
  console.log(response);
}

main().catch(console.error);

如需运行此示例,请替换以下内容:

  • EMOJI_NAME:自定义表情符号的唯一名称,位于 emoji_name 字段中。您可以通过调用 ListCustomEmoji 方法获取 ID,也可以通过 Chat API 异步创建自定义表情符号后从返回的响应正文中获取 ID。