Skip to main content
Glama

moderate_message

Delete Discord messages and optionally timeout users to enforce server rules and maintain community standards.

Instructions

Moderate a message by deleting it and optionally timing out the author.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channel_idYes
message_idYes
delete_messageNo
timeout_minutesNo
reasonNo

Implementation Reference

  • The core handler function that implements the moderate_message tool. It fetches the message, deletes it with the given reason, previews the content, and optionally applies a timeout to the author if specified.
    @staticmethod async def handle_moderate_message(discord_client, arguments: Dict[str, Any]) -> List[TextContent]: """Delete a message and optionally timeout the user""" channel = await discord_client.fetch_channel(int(arguments["channel_id"])) message = await channel.fetch_message(int(arguments["message_id"])) # Get the message author before deletion author = message.author content_preview = message.content[:50] + "..." if len(message.content) > 50 else message.content # Delete the message await message.delete(reason=arguments["reason"]) result = f"Deleted message from {author.name}: '{content_preview}'\nReason: {arguments['reason']}" # Apply timeout if specified if "timeout_minutes" in arguments and arguments["timeout_minutes"] > 0: if isinstance(author, discord.Member): timeout_duration = timedelta(minutes=arguments["timeout_minutes"]) await author.timeout(timeout_duration, reason=arguments["reason"]) result += f"\nApplied {arguments['timeout_minutes']} minute timeout to {author.name}" else: result += f"\nCould not timeout {author.name} (user may not be in server)" return [TextContent(type="text", text=result)]
  • The tool registration in the list_tools() function, defining the name, description, and input schema for the moderate_message tool.
    Tool( name="moderate_message", description="Delete a message and optionally timeout the user", inputSchema={ "type": "object", "properties": { "channel_id": { "type": "string", "description": "Channel ID containing the message" }, "message_id": { "type": "string", "description": "ID of message to moderate" }, "reason": { "type": "string", "description": "Reason for moderation" }, "timeout_minutes": { "type": "number", "description": "Optional timeout duration in minutes", "minimum": 0, "maximum": 40320 } }, "required": ["channel_id", "message_id", "reason"] } ),
  • The dispatch logic in call_tool() that routes 'moderate_message' calls to CoreToolHandlers.handle_moderate_message.
    core_tool_names = [ "get_server_info", "list_servers", "get_channels", "list_members", "get_user_info", "send_message", "read_messages", "add_reaction", "add_multiple_reactions", "remove_reaction", "moderate_message", "create_text_channel", "delete_channel", "add_role", "remove_role" ] if name in core_tool_names: handler_method = f"handle_{name}" if hasattr(CoreToolHandlers, handler_method): return await getattr(CoreToolHandlers, handler_method)(discord_client, arguments)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wowjinxy/mcp-discord'

If you have feedback or need assistance with the MCP directory API, please join our Discord server