> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sageprotocol.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Moderating Channels

>  

Channel owners can assign and remove moderators to help maintain content quality, enforce guidelines, and manage user interactions effectively.

## Adding Moderators

**React Hook Example for Adding Moderators**:

```typescript theme={null}
import { useChannel } from '@sageprotocol/sdk/react';
import { useWallet } from '@suiet/wallet-kit';

function AddModerator({ channelId, moderatorSharedUserId }) {
  const { addModerator } = useChannel();
  const { account, signAndExecuteTransaction } = useWallet();

  async function handleAddModerator() {
    const result = await addModerator({
      amounts: [0, 0],                           // Required protocol fees
      appId: 'your-app-id',                      // Explicitly required application ID
      network: 'testnet',                        // 'testnet' or 'mainnet'
      channelId,                                 // Channel ID to moderate
      sharedUserId: moderatorSharedUserId,       // User's shared ID to grant moderator role
      self: account.address                      // Channel owner's wallet address
    });

    if (result.ok) {
      await signAndExecuteTransaction({ transaction: result.transaction });
      console.log("Moderator added successfully!");
    } else {
      console.error("Error adding moderator:", result.err);
    }
  }

  return <button onClick={handleAddModerator}>Add Moderator</button>;
}

export default AddModerator;
```

<Accordion title="Direct Javascript Example for Adding Moderators" icon="rectangle-code" iconType="sharp-solid">
  ```javascript theme={null}
  import { SageClient } from '@sageprotocol/sdk';

  const sageClient = new SageClient({
    appId: 'your-app-id',                   // Explicitly required application ID
    channelRegistryId: 'your-registry-id',  // Required channel registry ID
    network: 'testnet'                      // 'testnet' or 'mainnet'
  });

  await sageClient.initialize();

  async function addModerator(channelId, moderatorSharedUserId, walletAddress) {
    const result = await sageClient.addChannelModerator({
      amounts: [0, 0],                       // Required protocol fees
      channelId,                             // Channel ID to moderate
      sharedUserId: moderatorSharedUserId,   // Shared user ID to grant moderator role
      self: walletAddress                    // Channel owner's wallet address
    });

    if (result.ok) {
      await signAndExecuteTransaction({ transaction: result.transaction });
      console.log("Moderator added successfully!");
    } else {
      console.error("Error adding moderator:", result.err);
    }
  }

  addModerator('your-channel-id', 'moderator-shared-user-id', walletAddress);
  ```
</Accordion>

## Removing Moderators

**React Hook Example for Removing Moderators**:

```typescript theme={null}
import { useChannel } from '@sageprotocol/sdk/react';
import { useWallet } from '@suiet/wallet-kit';

function RemoveModerator({ channelId, moderatorSharedUserId }) {
  const { removeModerator } = useChannel();
  const { account, signAndExecuteTransaction } = useWallet();

  async function handleRemoveModerator() {
    const result = await removeModerator({
      amounts: [0, 0],          // Required protocol fees
      appId: 'your-app-id',     // Explicitly required application ID
      network: 'testnet',       // 'testnet' or 'mainnet'
      channelId,                // Channel ID to moderate
      sharedUserId: moderatorSharedUserId,      // User's shared ID whose moderator role will be revoked
      self: account.address     // Channel owner's wallet address
    });

    if (result.ok) {
      await signAndExecuteTransaction({ transaction: result.transaction });
      console.log("Moderator removed successfully!");
    } else {
      console.error("Error removing moderator:", result.err);
    }
  }

  return <button onClick={handleRemoveModerator}>Remove Moderator</button>;
}

export default RemoveModerator;
```

<Accordion title="Direct Javascript Example for Removing Moderators" icon="rectangle-code" iconType="sharp-solid">
  ```javascript theme={null}
  import { SageClient } from '@sageprotocol/sdk';

  const sageClient = new SageClient({
    appId: 'your-app-id',                   // Explicitly required application ID
    channelRegistryId: 'your-registry-id',  // Required channel registry ID
    network: 'testnet'                      // 'testnet' or 'mainnet'
  });

  await sageClient.initialize();

  async function removeModerator(channelId, moderatorSharedUserId, walletAddress) {
    const result = await sageClient.removeChannelModerator({
      amounts: [0, 0],                       // Required protocol fees
      channelId,                             // Channel ID to moderate
      sharedUserId: moderatorSharedUserId,   // Shared user ID whose moderator role will be revoked
      self: walletAddress                    // Channel owner's wallet address
    });

    if (result.ok) {
      await signAndExecuteTransaction({ transaction: result.transaction });
      console.log("Moderator removed successfully!");
    } else {
      console.error("Error removing moderator:", result.err);
    }
  }

  removeModerator('your-channel-id', 'moderator-shared-user-id', walletAddress);
  ```
</Accordion>

##
